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

            鏈接

            最新隨筆

            搜索

            最新評論

            丰满少妇人妻久久久久久| 久久最近最新中文字幕大全| 中文字幕日本人妻久久久免费 | 欧美国产成人久久精品| 无码国内精品久久综合88| 久久久噜噜噜久久中文福利| 久久99热精品| 一本色道久久99一综合| 久久久久国产一区二区三区| 奇米影视7777久久精品| 亚洲美日韩Av中文字幕无码久久久妻妇| 欧美熟妇另类久久久久久不卡| 久久综合五月丁香久久激情| 久久夜色精品国产网站| 久久这里有精品| 国产精品九九久久免费视频| 国内精品久久久久久久97牛牛| 99久久无色码中文字幕人妻| 欧美精品福利视频一区二区三区久久久精品 | 一级女性全黄久久生活片免费 | 国产精品免费久久久久电影网| 久久久久久久91精品免费观看| 精品国际久久久久999波多野| 2021最新久久久视精品爱| 久久WWW免费人成—看片| 国产亚洲色婷婷久久99精品| 亚洲中文精品久久久久久不卡| 久久国产欧美日韩精品免费| 亚洲国产成人精品女人久久久 | 99久久精品国产高清一区二区| 91麻豆国产精品91久久久| 欧美性大战久久久久久| 久久996热精品xxxx| 国产精品99久久久久久董美香| 久久国产精品99精品国产987| 久久久久AV综合网成人| 色欲综合久久中文字幕网| 亚洲午夜久久久久久久久电影网| 欧美日韩精品久久久久| 99久久无色码中文字幕人妻| 亚洲女久久久噜噜噜熟女|