#include
#include "tchar.h"
#include
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
return DefWindowProc(hwnd, message, wParam, lParam);
/*switch (message)
{
case WM_DESTROY
PostQuitMessage(0);
default:
break;
}*/
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
TCHAR *szClassName = _T("winclass");
WNDCLASS wndc;
wndc.cbClsExtra = 0;
wndc.cbWndExtra = 0;
wndc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
wndc.hCursor = LoadCursor(NULL,IDC_ARROW);
wndc.hIcon =LoadIcon(NULL, IDI_APPLICATION);
wndc.hInstance = hInstance;
wndc.lpfnWndProc = WndProc;
wndc.lpszClassName = szClassName;
wndc.lpszMenuName = NULL;
BOOL ret1 =RegisterClass(&wndc);
if (!ret1)
{
MessageBox(NULL, _T("注冊窗口類失敗"), _T(" "), MB_ERR_INVALID_CHARS);
}
HWND hwnd = CreateWindow(szClassName,
_T("WIN"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
if (NULL==hwnd)
{
MessageBox(NULL, _T("創建窗口失敗"), _T(" "), MB_ICONERROR);
return false;
}
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
MSG msg;//LPMSG類型的實參竟然與LPMSG類型的形參不兼容
while (GetMessage(&msg,NULL,NULL,NULL))//GetMessage函數的第一個參數就是LPMSG形參
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
你還有幾個參數沒有設置,還有可以的話位置大小不要用默認大小