• <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>

            張樹坤的學(xué)習(xí)博客

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

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

            公告

            http://www.zhangsk.cn

            常用鏈接

            留言簿(1)

            我參與的團隊

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            被Delphi慣壞了,發(fā)現(xiàn)寫一個原生的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 張樹坤 閱讀(339) 評論(0)  編輯 收藏 引用

            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            久久久精品一区二区三区| 亚洲国产精品高清久久久| 精品久久久无码人妻中文字幕豆芽| 久久天天躁狠狠躁夜夜avapp| 伊人久久大香线蕉综合热线| 午夜精品久久久内射近拍高清 | 精品少妇人妻av无码久久| 69久久精品无码一区二区| 亚洲午夜精品久久久久久浪潮 | 久久久久99精品成人片| 免费精品久久天干天干| 91性高湖久久久久| 热99RE久久精品这里都是精品免费| 精品久久久久久无码专区| 久久国产午夜精品一区二区三区| 日韩av无码久久精品免费| 久久亚洲高清综合| 久久精品二区| 精品久久久无码人妻中文字幕豆芽| 久久99精品久久久久久不卡| 久久精品无码一区二区无码| 日韩精品无码久久一区二区三| 狠狠色丁香婷综合久久| 久久久久久久久久久精品尤物| 国产精品va久久久久久久| 国产精品久久久亚洲| 欧美熟妇另类久久久久久不卡 | 日韩乱码人妻无码中文字幕久久| 久久人人爽人人爽人人片AV东京热 | 成人久久精品一区二区三区| 中文国产成人精品久久不卡| 三级韩国一区久久二区综合| 久久人人爽人人爽人人片AV麻豆| 久久99精品久久久久婷婷| 久久久精品国产免大香伊 | 欧美久久综合性欧美| 国产精品久久久久久吹潮| 久久综合狠狠综合久久| 久久久亚洲欧洲日产国码二区| 亚洲av伊人久久综合密臀性色| 亚洲国产精品无码久久久不卡|