• <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++博客 :: 首頁 :: 聯(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 張樹坤 閱讀(341) 評論(0)  編輯 收藏 引用
            久久精品国产99久久久香蕉| 亚洲欧美日韩精品久久亚洲区| 久久夜色精品国产噜噜亚洲AV| 久久久噜噜噜久久中文福利| 久久久WWW免费人成精品| 久久综合伊人77777麻豆| 久久线看观看精品香蕉国产| 亚洲国产天堂久久综合| 亚洲AV无码久久精品色欲| 久久久99精品成人片中文字幕 | 亚洲国产日韩综合久久精品| 久久精品亚洲日本波多野结衣 | 精品国产乱码久久久久久人妻| 国产成人99久久亚洲综合精品| 国产色综合久久无码有码| 日韩电影久久久被窝网| 色综合久久久久| 人妻少妇久久中文字幕一区二区| 亚洲国产成人久久综合一 | 亚洲国产精品一区二区久久hs| 久久精品国产亚洲网站| A狠狠久久蜜臀婷色中文网| 久久久久久毛片免费播放| 久久亚洲中文字幕精品一区| 99久久婷婷国产一区二区| 亚洲午夜久久久影院伊人| 久久亚洲精品成人无码网站| 伊人久久大香线蕉综合Av | 亚洲伊人久久成综合人影院| 国内精品久久久久国产盗摄| 亚洲精品97久久中文字幕无码 | 亚洲AV无码久久| 大香伊人久久精品一区二区| 欧美激情精品久久久久久久九九九| AAA级久久久精品无码区| 国产高潮国产高潮久久久91 | 久久无码AV中文出轨人妻 | 成人久久久观看免费毛片| 99久久精品无码一区二区毛片 | 久久这里只有精品首页| 狠狠色丁香久久综合五月|