主题:【求助】窗口不显示
HWND hwnd;
void InitWindows(WNDCLASS &wnd, HINSTANCE hInstance = NULL);
LRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
MSG msg;
WNDCLASS wnd;
InitWindows(wnd, hInstance);
hwnd = CreateWindow( TEXT("FirstProgaramn"),
__T("First"),
WS_OVERLAPPEDWINDOW,
0,
0,
800,
600,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
LRESULT CALLBACK WinProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
{
int mbCode = 0;
switch (message)
{
case WM_DESTROY:
mbCode = MessageBox(hwnd, __T("Are you sure quit?"), __T("Exit"), MB_OKCANCEL);
if (mbCode == IDOK)
{
PostQuitMessage(0);
}
return 0;
case WM_LBUTTONDOWN:
MessageBox(hwnd, __T("Mouse Clicked"), __T("Clicked"), MB_OK);
return 0;
case WM_CREATE:
MessageBox(hwnd, __T("window has created"), __T("Created"), MB_OK);
return 0;
default:
DefWindowProc(hwnd, message, wParam, lParam);
return 0;
}
}
void InitWindows( WNDCLASS &wnd, HINSTANCE hInstance /*= NULL*/ )
{
wnd.style = CS_HREDRAW| CS_VREDRAW;
wnd.lpfnWndProc = WinProc;
wnd.cbClsExtra = 0;
wnd.cbWndExtra = 0;
wnd.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wnd.hInstance = hInstance;
wnd.lpszClassName = TEXT("FirstProgaramn");
wnd.lpszMenuName = __T("First");
wnd.hCursor = LoadCursor(NULL,IDC_ARROW);
wnd.hIcon = LoadIcon(NULL, IDI_WINLOGO);
RegisterClass(&wnd);
hwnd = CreateWindow( TEXT("FirstProgaramn"),
__T("First"),
WS_OVERLAPPED,
0,
0,
800,
600,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
}
为什么我创建的窗口就是不显示出来呢
void InitWindows(WNDCLASS &wnd, HINSTANCE hInstance = NULL);
LRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
MSG msg;
WNDCLASS wnd;
InitWindows(wnd, hInstance);
hwnd = CreateWindow( TEXT("FirstProgaramn"),
__T("First"),
WS_OVERLAPPEDWINDOW,
0,
0,
800,
600,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
LRESULT CALLBACK WinProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
{
int mbCode = 0;
switch (message)
{
case WM_DESTROY:
mbCode = MessageBox(hwnd, __T("Are you sure quit?"), __T("Exit"), MB_OKCANCEL);
if (mbCode == IDOK)
{
PostQuitMessage(0);
}
return 0;
case WM_LBUTTONDOWN:
MessageBox(hwnd, __T("Mouse Clicked"), __T("Clicked"), MB_OK);
return 0;
case WM_CREATE:
MessageBox(hwnd, __T("window has created"), __T("Created"), MB_OK);
return 0;
default:
DefWindowProc(hwnd, message, wParam, lParam);
return 0;
}
}
void InitWindows( WNDCLASS &wnd, HINSTANCE hInstance /*= NULL*/ )
{
wnd.style = CS_HREDRAW| CS_VREDRAW;
wnd.lpfnWndProc = WinProc;
wnd.cbClsExtra = 0;
wnd.cbWndExtra = 0;
wnd.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wnd.hInstance = hInstance;
wnd.lpszClassName = TEXT("FirstProgaramn");
wnd.lpszMenuName = __T("First");
wnd.hCursor = LoadCursor(NULL,IDC_ARROW);
wnd.hIcon = LoadIcon(NULL, IDI_WINLOGO);
RegisterClass(&wnd);
hwnd = CreateWindow( TEXT("FirstProgaramn"),
__T("First"),
WS_OVERLAPPED,
0,
0,
800,
600,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
}
为什么我创建的窗口就是不显示出来呢