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

            天下

            記錄修行的印記

            經(jīng)典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 天下 閱讀(463) 評(píng)論(0)  編輯 收藏 引用 所屬分類: Win32

            <2015年12月>
            293012345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            留言簿(4)

            隨筆分類(378)

            隨筆檔案(329)

            鏈接

            最新隨筆

            搜索

            最新評(píng)論

            久久se精品一区精品二区| 7777久久亚洲中文字幕| 一级做a爰片久久毛片看看| 久久亚洲国产成人影院| 99久久久国产精品免费无卡顿| 亚洲色婷婷综合久久| 国产成人精品久久亚洲高清不卡| 99久久99久久| 日本免费久久久久久久网站| 久久人妻少妇嫩草AV无码蜜桃| 婷婷国产天堂久久综合五月| 久久精品aⅴ无码中文字字幕不卡| 精品国产VA久久久久久久冰| 久久99国产精品久久99| 亚洲乱码日产精品a级毛片久久| 久久精品aⅴ无码中文字字幕不卡 久久精品aⅴ无码中文字字幕重口 | 久久亚洲精品中文字幕三区| 久久国产精品免费一区| 亚洲va中文字幕无码久久| 精品久久人人妻人人做精品| 久久国产欧美日韩精品| 一本一道久久综合狠狠老| 久久精品国产一区二区三区不卡 | 91精品观看91久久久久久| 精品久久久久久无码不卡| 中文字幕成人精品久久不卡| 久久综合九色综合网站| 热99RE久久精品这里都是精品免费 | 999久久久国产精品| 性高湖久久久久久久久| 亚洲日本va午夜中文字幕久久| 久久精品国产精品亚洲人人| 久久99亚洲网美利坚合众国| 99久久无色码中文字幕人妻| 国内精品伊人久久久久妇| 色诱久久av| 中文精品99久久国产| 香蕉99久久国产综合精品宅男自| 久久99亚洲综合精品首页| 久久91亚洲人成电影网站| 97久久精品无码一区二区天美|