16,473
社区成员
发帖
与我相关
我的任务
分享
#include "stdafx.h"
#include <Windows.h>
LRESULT CALLBACK myWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
return ::DefWindowProcW(hWnd, uMsg, wParam, lParam);
}
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{
const wchar_t * className = L"myClassName";
//窗口类
WNDCLASSW wc = { 0 };
wc.lpfnWndProc = myWindowProc;
wc.hbrBackground = (HBRUSH)(GetStockObject(BLACK_BRUSH));
wc.lpszClassName = className;
//注册窗口类
if (!RegisterClassW(&wc))
{
}
//创建窗口
HWND hwnd = CreateWindowExW(NULL, className, L"myWindow",
WS_CLIPSIBLINGS | WS_POPUP | WS_VISIBLE | WS_CLIPCHILDREN, 0, 0, 500, 500,
NULL, NULL, NULL, NULL);
RECT rect = { 0 };
::GetWindowRect(hwnd, &rect); //这里获取的结果,显示窗口大小是500 * 500!!!
MSG msg = { 0 };
while (::GetMessageW(&msg, NULL, 0, 0))
{
::TranslateMessage(&msg);
::DispatchMessageW(&msg);
}
return (int)(msg.wParam);
}