//标准Win32应用程序中显示一个窗口的代码:
//////////////////////////////////////////////////////////////////////////
//窗口
BOOL InitWindow(HINSTANCE hInstance, int nCmdShow)
{
int wWidth = GetSystemMetrics(SM_CXSCREEN);
int wHeight = GetSystemMetrics(SM_CYSCREEN);
// 窗口类结构
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style
= CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc
= (WNDPROC)WinProc;
wcex.cbClsExtra
= 0;
wcex.cbWndExtra
= 0;
wcex.hInstance
= hInstance;
wcex.hIcon
= LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MAINICON));
wcex.hCursor
= LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground
= (HBRUSH)(COLOR_WINDOW + 1);
wcex.lpszMenuName
= NULL;
wcex.lpszClassName
= AP_CLASSNAME;
wcex.hIconSm
= LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_MAINICON));
// 注册窗口类
RegisterClassEx(&wcex);
// 创建主窗口
hwnd = CreateWindowEx( 0,
AP_CLASSNAME,
AP_WINDOWNAME,
WS_OVERLAPPED |
WS_CAPTION |
WS_SYSMENU |
WS_MINIMIZEBOX,
wWidth / 2 - AP_SCREENWIDTH / 2,
wHeight / 2 - AP_SCREENHEIGHT / 2 - 30,
AP_SCREENWIDTH,
AP_SCREENHEIGHT,
NULL,
NULL,
hInstance,
NULL);
if (!hwnd)
return FALSE;
//显示并更新窗口
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
return TRUE;
}
[[it] 本帖最后由 flyue 于 2008-5-25 14:38 编辑 [/it]]