• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            張樹坤的學習博客

            天下難事必做于易,天下大事必做于細

              C++博客 :: 首頁 :: 聯系 :: 聚合  :: 管理
              9 Posts :: 1 Stories :: 4 Comments :: 0 Trackbacks

            公告

            http://www.zhangsk.cn

            常用鏈接

            留言簿(1)

            我參與的團隊

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            被Delphi慣壞了,發現寫一個原生的Form這么麻煩
            vc版本
            #include <windows.h>

            LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;

            int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                                PSTR szCmdLine, 
            int iCmdShow)
            {
                 
            static TCHAR szAppName[] = TEXT ("HelloWin") ;
                 HWND         hwnd ;
                 MSG          msg ;
                 WNDCLASS     wndclass ;

                 wndclass.style         
            = CS_HREDRAW | CS_VREDRAW ;
                 wndclass.lpfnWndProc   
            = WndProc ;
                 wndclass.cbClsExtra    
            = 0 ;
                 wndclass.cbWndExtra    
            = 0 ;
                 wndclass.hInstance     
            = hInstance ;
                 wndclass.hIcon         
            = LoadIcon (NULL, IDI_APPLICATION) ;
                 wndclass.hCursor       
            = LoadCursor (NULL, IDC_ARROW) ;
                 wndclass.hbrBackground 
            = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
                 wndclass.lpszMenuName  
            = NULL ;
                 wndclass.lpszClassName 
            = szAppName ;

                 
            if (!RegisterClass (&wndclass))
                 {
                      MessageBox (NULL, TEXT (
            "This program requires Windows NT!"), 
                                  szAppName, MB_ICONERROR) ;
                      
            return 0 ;
                 }
                 
                 hwnd 
            = CreateWindow (szAppName,                  // window class name
                                      TEXT ("The Hello Program"), // window caption
                                      WS_OVERLAPPEDWINDOW,        // window style
                                      CW_USEDEFAULT,              // initial x position
                                      CW_USEDEFAULT,              // initial y position
                                      CW_USEDEFAULT,              // initial x size
                                      CW_USEDEFAULT,              // initial y size
                                      NULL,                       // parent window handle
                                      NULL,                       // window menu handle
                                      hInstance,                  // program instance handle
                                      NULL) ;                     // creation parameters
                 
                 ShowWindow (hwnd, iCmdShow) ;
                 UpdateWindow (hwnd) ;
                 
                 
            while (GetMessage (&msg, NULL, 00))
                 {
                      TranslateMessage (
            &msg) ;
                      DispatchMessage (
            &msg) ;
                 }
                 
            return msg.wParam ;
            }

            LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
            {
                 HDC         hdc ;
                 PAINTSTRUCT ps ;
                 RECT        rect ;
                 
                 
            switch (message)
                 {
                 
            case WM_CREATE:
                      PlaySound (TEXT (
            "hellowin.wav"), NULL, SND_FILENAME | SND_ASYNC) ;
                      
            return 0 ;
                      
                 
            case WM_PAINT:
                      hdc 
            = BeginPaint (hwnd, &ps) ;
                      
                      GetClientRect (hwnd, 
            &rect) ;
                      
                      DrawText (hdc, TEXT (
            "Hello, Windows 98! By ZhangSK"), -1&rect,
                                DT_SINGLELINE 
            | DT_CENTER | DT_VCENTER) ;
                      
                      EndPaint (hwnd, 
            &ps) ;
                      
            return 0 ;
                      
                 
            case WM_DESTROY:
                      PostQuitMessage (
            0) ;
                      
            return 0 ;
                 }
                 
            return DefWindowProc (hwnd, message, wParam, lParam) ;
            }

            Delphi版本
            program HelloWin;

            uses
              Windows,
              Messages,
              MMSystem,
              SysUtils;

            Const
              AppName:String 
            = 'HelloWin';
              Null:Integer 
            = 0;

            function WndProc(WindowHwnd:HWND;TheMessage:UINT;WPARAMS:wParam;LPARAMS:lParam):Integer;stdcall;
            var
              ClientDC:HDC;
              ps:TPaintStruct;
              ClientRect:TRect;
              sUser, sPower: string;
            begin
              
            case TheMessage of
              WM_CREATE: begin
                 PlaySound(
            'hellowin.wav',null,SND_FILENAME or SND_ASYNC);
                 Result:
            =0;
              end;
              WM_PAINT: begin
                 ClientDc:
            =BeginPaint(WindowHwnd,ps);
                 GetClientRect(WindowHwnd,ClientRect);
                 DrawText(ClientDc,PChar(
            'Hello,Window98!'),-1,ClientRect,DT_SINGLELINE or
                          DT_CENTER OR DT_VCENTER);
                 sUser :
            = 'ZhangSK''Testing';
                 sPower :
            = 'POWERD BY DELPHI';
                 TextOut(ClientDC, 
            55, PChar(sUser), Length(sUser));
                 TextOut(ClientDC, ClientRect.Right
            -200, ClientRect.Bottom-30, PChar(sPower), Length(sPower));
                 Endpaint(Windowhwnd,ps);
                 Result:
            =0;
              end;
              WM_DESTROY: begin
                 PostQuitMessage(
            0);
                 Result:
            =0;
              end;
              
            else
                Result:
            =DefWindowProc(WindowHwnd,TheMessage,WPARAMS,LPARAMS);
              end;
            end;


              
            var
              WinHwnd:HWND;
              WinMsg:MSG;
              WinClass:WNDCLASS;
              ECode:DWORD;
              EString:PChar;
            begin
              WinClass.style:
            =CS_HREDRAW OR CS_VREDRAW;
              WinClass.lpfnWndProc:
            =@WndProc;
              WinClass.cbClsExtra:
            =0;
              WinClass.cbWndExtra:
            =0;
              WinClass.hInstance:
            =hInstance;
              WinClass.hIcon:
            =LoadIcon(NULL,IDI_APPLICATION);
              WinClass.hCursor:
            =LoadCursor(Null,IDC_ARROW);
              WinClass.hbrBackground:
            =HBRUSH(GetStockObject(WHITE_BRUSH));
              WinClass.lpszMenuName:
            =nil;
              WinClass.lpszClassName:
            =PChar(AppName);

              
            if (RegisterClass(WinClass)=0) then
              begin
                MessageBox(
            null,'This application need WINDOWS platform','message',MB_ICONERROR);
                exit;
              end;

              WinHwnd:
            =CreateWindow(PChar(AppName),'First SDK Application',WS_OVERLAPPEDWINDOW,
                                    CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
                                    
            0,0,hInstance,nil);
              
            if Iswindow(WinHwnd)then
              begin
                ShowWindow(WinHwnd,SW_SHOWNORMAL);
                updateWindow(WinHwnd);
              end
              
            else begin
                ECode:
            =GetLastError;
                EString:
            =PChar(Inttostr(LoWord(ECode)));
                Messagebox(
            null,EString,'Error',MB_ICONERROR);
                exit;
              end;

              
            while(Getmessage(WinMsg,null,0,0))do
              begin
                TranslateMessage(WinMsg);
                DispatchMessage(WinMsg);
              end;

              UnregisterClass(PChar(AppName),hInstance);
            end.



            posted on 2007-09-13 17:15 張樹坤 閱讀(343) 評論(0)  編輯 收藏 引用
            色综合色天天久久婷婷基地| 久久男人中文字幕资源站| 久久妇女高潮几次MBA| 精品熟女少妇AV免费久久| 国产成人精品三上悠亚久久| 久久99精品久久久久子伦| 精品午夜久久福利大片| 精品久久久久中文字幕一区| 欧美精品九九99久久在观看| 精品久久久久久无码中文字幕一区| 色综合久久中文色婷婷| 亚洲伊人久久成综合人影院| 精品国产VA久久久久久久冰| 久久综合狠狠综合久久97色| 久久Av无码精品人妻系列| 国产精品热久久毛片| 亚洲乱码精品久久久久.. | 久久有码中文字幕| 久久久一本精品99久久精品66| 中文字幕成人精品久久不卡| 亚洲国产欧洲综合997久久| 久久99精品免费一区二区| 国内精品伊人久久久久AV影院| 欧美久久久久久| 精品无码久久久久久久动漫| 久久国产精品久久久| 亚洲精品蜜桃久久久久久| 四虎国产精品成人免费久久| 国产69精品久久久久99| a高清免费毛片久久| 韩国免费A级毛片久久| 久久九九兔免费精品6| 久久中文字幕视频、最近更新| 日韩亚洲欧美久久久www综合网 | 亚洲日本久久久午夜精品| 丰满少妇人妻久久久久久4| 国产99久久精品一区二区| 久久久久亚洲AV无码麻豆| 97精品国产97久久久久久免费| 一本一道久久a久久精品综合| 午夜精品久久久久久影视777|