何问起C++教程 - Windows编程 - Win32编程
Win32创建复选框代码
Win32创建复选框c++代码如下:
HWND h_hovertreeWND=NULL, h_hwnCheckBox1=NULL;
const UINT h_checkBox1=3961;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInstance, LPSTR lpCmdLine, int nCmdShow)
{
const wchar_t CLASS_NAME[] = L"Hovertree Window Class";

WNDCLASS wc = { };

wc.lpfnWndProc = WindowProcHovertree;
wc.hInstance = hInstance;
wc.lpszClassName = CLASS_NAME;

RegisterClass(&wc);

// Create the window.

h_hovertreeWND = CreateWindowEx(
0, // Optional window styles.
CLASS_NAME, // Window class
L"Hovertree 何问起 ", // Window text
WS_OVERLAPPEDWINDOW, // Window style

// Size and position x,y,width,height
CW_USEDEFAULT, CW_USEDEFAULT, 620, 260,

NULL, // Parent window
NULL, // Menu
hInstance, // Instance handle
NULL // Additional application data
);

ShowWindow(h_hovertreeWND, nCmdShow);

h_hwnCheckBox1 = CreateWindow(L"BUTTON", L"结果大写", WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX, 120, 160, 120, 30, h_hovertreeWND, (HMENU)h_checkBox1, hInstance, NULL);//创建复选框

MSG msg = { };
while (GetMessage(&msg, NULL, 0, 0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

return 0;
}

收藏 列表

评论: