能力值:
( LV4,RANK:50 )
|
-
-
2 楼
在LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
中处理WM_CREATE消息时,调用CreateWindow去创建,记得加上WS_CHILD属性
|
能力值:
(RANK:410 )
|
-
-
3 楼
#include <windows.h>
HINSTANCE g_hInstance;
HWND hEdit, hButton;
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
g_hInstance = hInstance;
WNDCLASS ws;
ws.cbClsExtra=0;
ws.cbWndExtra=0;
ws.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
ws.hCursor=LoadCursor(NULL,IDC_ARROW);
ws.hIcon=LoadIcon(NULL,IDI_APPLICATION);
ws.hInstance=hInstance;
ws.lpszClassName="学习";
ws.lpszMenuName=NULL;
ws.style=CS_HREDRAW|CS_VREDRAW;
ws.lpfnWndProc=WindowProc;
RegisterClass(&ws);
HWND hwnd;
int x,y;
x=(GetSystemMetrics(SM_CXFULLSCREEN))/2-100;
y=(GetSystemMetrics(SM_CYFULLSCREEN))/2-50;
hwnd=CreateWindow("学习","hello word!",WS_OVERLAPPEDWINDOW&~WS_MAXIMIZEBOX,x,y,200,100,0,0,hInstance,0);
ShowWindow(hwnd,SW_NORMAL);
UpdateWindow(hwnd);
MSG msg;
while (GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
switch (uMsg)
{
case WM_CREATE:
hEdit = CreateWindowEx(0,"Edit","Edit",WS_VISIBLE | WS_CHILD,10,10,50,20,hwnd,(HMENU)1000,g_hInstance,NULL);
hButton = CreateWindowEx(0,"Button","Button",WS_VISIBLE | WS_CHILD,15,30,35,20,hwnd,(HMENU)1001,g_hInstance,NULL);
break;
case WM_CLOSE:
if (IDYES==MessageBox(0,"是否关闭?","提示",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}
|
能力值:
( LV2,RANK:10 )
|
-
-
4 楼
先谢谢一楼的朋友...
小虾班班~~~承蒙您多次的帮忙,让我有了很大的进步~~~ 你实在太伟大了~~~
|