• <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 張樹坤 閱讀(340) 評論(0)  編輯 收藏 引用

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


            无码AV波多野结衣久久| 嫩草伊人久久精品少妇AV| 潮喷大喷水系列无码久久精品| 色狠狠久久综合网| 色妞色综合久久夜夜| 国产精品嫩草影院久久| 色综合久久中文字幕综合网| 久久亚洲中文字幕精品一区| 国产精品禁18久久久夂久| 久久久久99精品成人片| 色播久久人人爽人人爽人人片AV| 色狠狠久久AV五月综合| 久久久久国产亚洲AV麻豆| 久久久久亚洲精品无码蜜桃| 99久久精品免费看国产一区二区三区| 久久久这里有精品中文字幕| 久久久亚洲欧洲日产国码aⅴ| 国产精品亚洲综合专区片高清久久久| 精品国产青草久久久久福利| MM131亚洲国产美女久久| 久久亚洲精品国产精品婷婷| 99久久99久久精品国产| 久久综合精品国产二区无码| 亚洲国产成人精品女人久久久 | 热久久这里只有精品| 色综合久久夜色精品国产| 国产一区二区三精品久久久无广告| 免费久久人人爽人人爽av| 久久香蕉国产线看观看猫咪?v| 国内精品伊人久久久久| 久久中文骚妇内射| 亚洲AV日韩精品久久久久久久| 亚洲欧美日韩精品久久亚洲区| 免费国产99久久久香蕉| 99国产欧美久久久精品蜜芽| 久久精品一区二区三区AV| 亚洲人成无码www久久久| 日本亚洲色大成网站WWW久久| 99久久免费国产精品| 日本精品久久久中文字幕| 久久久久国产精品|