#include
#include
#include
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
if (msg == WM_COMMAND && LOWORD(wp) == 1 && HIWORD(wp) == BN_CLICKED) {
MessageBox(hwnd, _T("你点了按钮"), _T("哼"), MB_OK);
return 0;
} else
return DefWindowProc(hwnd, msg, wp, lp);
}
int APIENTRY _tWinMain(HINSTANCE hInst, HINSTANCE hPrev, LPTSTR szCmd, INT nShow)
{
WNDCLASS wc;
HWND hwnd;
MSG msg;
BOOL ret;
InitCommonControls();
ZeroMemory(&wc, sizeof wc);
wc.lpfnWndProc = WndProc;
wc.lpszClassName = _T("TestWin");
RegisterClass(&wc);
hwnd = CreateWindow(_T("TestWin"), _T("TestWin"), WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 300, 200,
0, 0, hInst, 0);
CreateWindow(_T("BUTTON"), _T("OK"), WS_VISIBLE|WS_CHILD|BS_DEFPUSHBUTTON,
10, 10, 100, 50,
hwnd, (HMENU) 1, hInst, 0);
ShowWindow(hwnd, SW_SHOWNORMAL);
while ( GetMessage(&msg, hwnd, 0, 0) > 0 ) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
这样可以吗
你是如何写的?
把代码贴出来看看