LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MSG msg;
WNDCLASS winclass;
winclass.style = CS_HREDRAW|CS_VREDRAW;
winclass.cbClsExtra = 0;
winclass.cbWndExtra = 0;
winclass.hbrBackground = (HBRUSH) GetStockObject(DKGRAY_BRUSH);
winclass.hIcon = LoadIcon(hInstance,IDI_QUESTION);
winclass.hCursor = LoadCursor(hInstance,IDC_CROSS);
winclass.hInstance = hInstance;
winclass.lpfnWndProc = (WNDPROC)WndProc;
winclass.lpszMenuName = NULL;
winclass.lpszClassName = "name";
RegisterClass(&winclass);
HWND hWnd;
hWnd=CreateWindow("name","Test",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);
ShowWindow(hWnd,SW_MAXIMIZE);
UpdateWindow(hWnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
參考答案:winclass.lpszMenuName = NULL;
winclass.lpszClassName = TEXT("name");
如果不行把第一行的NULL也改成TEXT("")这个样子的.
随便起个名字就行了
CreateWindow中前两个参数也这样改:
TEXT("name"),TEXT("Text")