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

            天下

            記錄修行的印記

            經典win32 SDK 程序

            #include <windows.h>
            #include <stdlib.h>
            #include <malloc.h>
            #include <memory.h>
            #include <tchar.h>

            #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS      // some CString constructors will be explicit

            #include <atlbase.h>
            #include <atlstr.h>

            #define MAX_LOADSTRING 100

            HINSTANCE hInst;                                // current instance
            TCHAR szTitle[MAX_LOADSTRING] = "Test Windows Message";                    // The title bar text
            TCHAR szWindowClass[MAX_LOADSTRING] = "MyTestWindows";            // the main window class name

            HWND main_hWnd;
            HWND btn_hwnd;
            DWORD btn_style = WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|WS_CHILD;
            int times = 0;
            // Forward declarations of functions included in this code module:
            ATOM                MyRegisterClass(HINSTANCE hInstance);
            BOOL                InitInstance(HINSTANCE, int);
            LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);

            #define MY_BUTTON_ID (1001)


            int APIENTRY WinMain(HINSTANCE hInstance,
                                 HINSTANCE hPrevInstance,
                                 LPTSTR    lpCmdLine,
                                 int       nCmdShow)
            {
                UNREFERENCED_PARAMETER(hPrevInstance);
                UNREFERENCED_PARAMETER(lpCmdLine);

                
                MSG msg;

                MyRegisterClass(hInstance);

                if (!InitInstance (hInstance, nCmdShow))
                {
                    return FALSE;
                }

                while (GetMessage(&msg, NULL, 0, 0))
                {
                    if (msg.hwnd == main_hWnd)
                    {
                        ATLTRACE("%04u,[Loop Main]MSG:0x%04X,HWND:0x%06x \r\n",times++,msg.message,msg.hwnd);
                    }
                    if (msg.hwnd==btn_hwnd)
                    {
                        ATLTRACE("%04u,[Loop Button]MSG:0x%04X,HWND:0x%06x \r\n",times++,msg.message,msg.hwnd);
                    }
                    TranslateMessage(&msg);
                    DispatchMessage(&msg);
                }

                return (int) msg.wParam;
            }



            ATOM MyRegisterClass(HINSTANCE hInstance)
            {
                WNDCLASSEX wcex;

                wcex.cbSize = sizeof(WNDCLASSEX);

                wcex.style            = CS_HREDRAW | CS_VREDRAW;
                wcex.lpfnWndProc    = WndProc;
                wcex.cbClsExtra        = 0;
                wcex.cbWndExtra        = 0;
                wcex.hInstance        = hInstance;
                //wcex.hIcon            = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_WIN05));
                wcex.hIcon            = NULL;
                wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
                wcex.hbrBackground    = (HBRUSH)(COLOR_WINDOW+1);
                //wcex.lpszMenuName    = MAKEINTRESOURCE(IDC_WIN05);
                wcex.lpszMenuName    = NULL;
                wcex.lpszClassName    = szWindowClass;
                //wcex.hIconSm        = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
                wcex.hIconSm        = NULL;

                return RegisterClassEx(&wcex);
            }

            BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
            {


               hInst = hInstance; 

               main_hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
                  CW_USEDEFAULT, 0, 300, 200, NULL, NULL, hInstance, NULL);

               if (!main_hWnd)
               {
                  return FALSE;
               }

               ShowWindow(main_hWnd, nCmdShow);
               UpdateWindow(main_hWnd);

               return TRUE;
            }


            LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
            {
                int wmId, wmEvent;
                PAINTSTRUCT ps;
                HDC hdc;

                ATLTRACE("%04u,[Main WndProc]MSG:0x%04X,HWND:0x%06x \r\n",times++,message,hWnd);
                switch (message)
                {
                case WM_CREATE:
                    {
                        //ATLTRACE("Main HWND:0x%06x \r\n",main_hWnd);
                        
            //ATLTRACE("WndProc HWND:0x%06x \r\n",hWnd);
                        btn_hwnd = CreateWindowEx(0,"BUTTON","My button",btn_style,10,10,100,50,hWnd,(HMENU)(UINT_PTR)MY_BUTTON_ID,hInst,NULL);
                        //ATLTRACE("Button HWND:0x%06x \r\n",btn_hwnd);
                    }

                    break;
                case WM_COMMAND:
                    wmId    = LOWORD(wParam);
                    wmEvent = HIWORD(wParam);
                    // Parse the menu selections:
                    switch (wmId)
                    {
                    case 1001:
                        
                        //MessageBox(hWnd,"abc","bcd",MB_OK);
                        break;
                    default:
                        return DefWindowProc(hWnd, message, wParam, lParam);
                    }
                    break;
                case WM_PAINT:
                    hdc = BeginPaint(hWnd, &ps);
                    EndPaint(hWnd, &ps);
                    break;
                case WM_DESTROY:
                    PostQuitMessage(0);
                    break;
                default:
                    return DefWindowProc(hWnd, message, wParam, lParam);
                }
                return 0;
            }

            posted on 2012-08-30 08:54 天下 閱讀(452) 評論(0)  編輯 收藏 引用 所屬分類: Win32

            <2012年8月>
            2930311234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            導航

            統計

            常用鏈接

            留言簿(4)

            隨筆分類(378)

            隨筆檔案(329)

            鏈接

            最新隨筆

            搜索

            最新評論

            久久成人影院精品777| 久久只这里是精品66| 伊人久久大香线蕉av一区| 色欲久久久天天天综合网| 精品乱码久久久久久夜夜嗨| 精品久久综合1区2区3区激情 | 久久国产AVJUST麻豆| 伊人久久大香线蕉亚洲| 久久亚洲精品无码AV红樱桃| 国产精品久久久久久久久鸭 | 欧美一区二区久久精品| 99精品国产99久久久久久97| 久久se精品一区二区| 久久精品国产清自在天天线| 亚洲国产成人久久精品99| 国产亚洲美女精品久久久| 亚洲色欲久久久综合网东京热| 欧美一区二区精品久久| MM131亚洲国产美女久久| 亚洲狠狠婷婷综合久久久久| 久久久黄片| 久久久人妻精品无码一区| 国产精品美女久久久免费| 国产L精品国产亚洲区久久| 少妇久久久久久被弄高潮| 久久久久亚洲AV成人网人人网站| 九九精品99久久久香蕉| 久久精品国产免费观看三人同眠| 亚洲国产成人久久一区WWW| 国产真实乱对白精彩久久| 91精品国产高清久久久久久91| 国产日韩久久久精品影院首页| …久久精品99久久香蕉国产| 久久天堂AV综合合色蜜桃网 | 看全色黄大色大片免费久久久| 久久亚洲国产午夜精品理论片| 久久精品国产亚洲av麻豆色欲 | 热久久国产欧美一区二区精品| 无码乱码观看精品久久| 久久99精品国产麻豆不卡| 久久国产成人精品国产成人亚洲|