1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#include <windows.h>
HWND hStatic;
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {
case WM_CREATE:
SystemParametersInfo(SPI_SETDROPSHADOW, 0, NULL, SPIF_SENDCHANGE);
hStatic = CreateWindow("CustomChildWindow", "Hello",
WS_CHILD | WS_VISIBLE | WS_BORDER,
10, 10, 100, 50,
hwnd, NULL, NULL, NULL);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
}
LRESULT CALLBACK CustomProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
return DefWindowProc(hwnd, msg, wParam, lParam);
}
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, int nCmdShow) {
WNDCLASS wc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = (HBRUSH)COLOR_BACKGROUND+1;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hInstance = hInst;
wc.lpfnWndProc = WndProc;
wc.lpszClassName = "TestWindow";
wc.lpszMenuName = NULL;
wc.style = 0;
RegisterClass(&wc);
wc.lpszClassName = "CustomChildWindow";
wc.style = CS_DROPSHADOW;
wc.lpfnWndProc = CustomProc;
RegisterClass(&wc);
HWND hwnd = CreateWindow("TestWindow", "This is a test window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
0, 0, hInst, 0);
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
|