NativeWindow_01_CreateWindow(Ex)_VC6

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了NativeWindow_01_CreateWindow(Ex)_VC6相关的知识,希望对你有一定的参考价值。

1、

 1 #include <windows.h>
 2 
 3 
 4 LRESULT CALLBACK ProcWindow(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
 5 void QuitWindow();
 6 
 7 HINSTANCE    g_hInstance = 0;
 8 HWND        g_hWnd = 0;
 9 
10 ////////////   ////////////   ////////////   ////////////   ////////////   ////////////
11 
12 int WINAPI WinMain(
13     HINSTANCE _hInstance,        // 当前 hInstance句柄
14     HINSTANCE _hPrevInstance,    // 之前的 hInstance句柄
15     LPSTR _lpCmdLine,            // 命令行
16     int _nCmdShow                // 显示状态
17 )
18 {
19     g_hInstance = _hInstance;
20 
21 // 程序(.exe)的图标貌似默认是 资源文件中 的第一个图标??
22     WNDCLASS wndcls = {0};
23     wndcls.style        = CS_HREDRAW | CS_VREDRAW;
24     wndcls.lpfnWndProc    = ProcWindow;
25     wndcls.cbClsExtra    = 0;
26     wndcls.cbWndExtra    = 0;
27     wndcls.hInstance    = _hInstance;
28     wndcls.hIcon        = LoadIcon(NULL, IDI_ERROR);    // 窗口图标
29     wndcls.hCursor        = LoadCursor(NULL, IDC_CROSS);
30     wndcls.hbrBackground= (HBRUSH)GetStockObject(WHITE_BRUSH);    // 背景画刷
31     wndcls.lpszMenuName = NULL;
32     wndcls.lpszClassName= "zc20110929";
33 // 注册窗口类
34     RegisterClass(&wndcls);
35 
36     g_hWnd = CreateWindowEx(
37         NULL, //WS_EX_CLIENTEDGE,
38         wndcls.lpszClassName,
39         "ZC Window",
40         WS_OVERLAPPEDWINDOW,
41         100, 100,
42         400, 300,
43         NULL,
44         NULL, //g_hMenu,
45         _hInstance,
46         NULL);
47 
48     ShowWindow(g_hWnd, SW_SHOWNORMAL);
49     UpdateWindow(g_hWnd);
50 
51     MSG msg;
52     while(GetMessage(&msg, 0, 0, 0))
53     {
54         TranslateMessage(&msg);
55         DispatchMessage(&msg);
56     }
57 
58     return msg.wParam;
59 }
60 
61 LRESULT CALLBACK ProcWindow(
62     HWND _hWnd, // 窗口句柄
63     UINT _uMsg, // 消息ID(identifier)
64     WPARAM _wParam,
65     LPARAM _lParam)
66 {
67     switch (_uMsg)
68     {
69     case WM_PAINT:
70         {
71             HDC hDc;
72             PAINTSTRUCT ps;
73             hDc = BeginPaint(_hWnd, &ps);
74             TextOut(hDc, 0, 0, "ASDFG zxcvb", strlen("ASDFG zxcvb"));
75             EndPaint(_hWnd, &ps);
76             return 0;
77 //            break;
78         }
79     case WM_DESTROY:
80         {
81             PostQuitMessage(0);
82             return 0;    
83         }
84     }
85     return DefWindowProc(_hWnd, _uMsg, _wParam, _lParam);
86 }
87 
88 void QuitWindow()
89 {
90     DestroyWindow(g_hWnd);
91     PostQuitMessage(0);
92 }

 

2、

 

以上是关于NativeWindow_01_CreateWindow(Ex)_VC6的主要内容,如果未能解决你的问题,请参考以下文章

NativeWindow_01_CreateWindow(Ex)_VC6

NativeWindow_02_DialogBoxParam_VC6

NativeWindow_02_DialogBoxParam_VC6

你能得到 NativeWindow 最小化的事件吗?

AIR - 设置 NativeWindow 的大小以包括系统镶边

利用NativeWindow监视WndProc消息(好像是一个字典,没搞明白)