CreateWindow返回NULL,GetLastError()返回1407,谁来告诉我怎么办啊。。。在线等
-------------------------------------------
cpp:
#include <windows.h>
long _stdcall WndProc(HWND hWnd,
UINT message,
WPARAM wParam,
LPARAM lParam); //回调函数声明
int _stdcall WinMain(HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // handle to previous instance
int nCmdShow // handle to previous instance
)
{
static TCHAR szAppName[] = "PAINT";
static TCHAR szWinName[] = "cowboy's win";
MSG msg;
static HWND hWnd;
WNDCLASSEX wce;
wce.cbSize = sizeof(WNDCLASSEX);
wce.style = CS_HREDRAW | CS_VREDRAW;
wce.lpfnWndProc = (WNDPROC)WndProc; //The WNDPROC type defines a pointer to this callback function
wce.cbClsExtra = 0; //The system initializes the bytes to zero
wce.cbWndExtra = 0; //The system initializes the bytes to zero
wce.hIcon = ::LoadIcon(NULL,IDI_WINLOGO);
wce.hCursor = ::LoadCursor(NULL,IDC_ARROW);
wce.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wce.lpszMenuName = NULL;
wce.lpszClassName = szAppName;
wce.hIconSm = NULL;
if(!RegisterClassEx(&wce))
{
::MessageBox(NULL,TEXT("注册失败!"),szAppName,MB_ICONERROR);
return 0;
}
hWnd = CreateWindowEx(WS_EX_LEFT,szAppName, szAppName, WS_OVERLAPPEDWINDOW,CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
if(!hWnd)
{
long i = GetLastError(); //1407
//::MessageBox(NULL,TEXT("创建失败!"),szAppName,MB_ICONERROR);
return 0;
}
::ShowWindow(hWnd,nCmdShow);
::UpdateWindow(hWnd);
while(::GetMessage(&msg,NULL,0,0))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
return msg.wParam;
}
long _stdcall WndProc(HWND hWnd,
UINT message,
WPARAM wParam,
LPARAM lParam
)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
switch(message)
{
case WM_PAINT:
hdc = ::BeginPaint(hWnd,&ps);
::GetClientRect(hWnd,&rect);
::DrawText(hdc,TEXT("做个玩玩"),-1,&rect,DT_CENTER | DT_VCENTER);
::EndPaint(hWnd,&ps);
break;
case WM_DESTROY:
::PostQuitMessage(0);
break;
}
return ::DefWindowProc(hWnd,message,wParam,lParam);
}
---------------------------------------