[英]Checkbox control in Win32 API is rounded in a deformed manner in Windows 11
如下圖所示:
單擊復選框時有未填充的區域(主要在角落)。 我已經通過啟用視覺 styles
#pragma comment(linker,"\"/manifestdependency:type='win32' \
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
而且我還調用了InitCommonControlsEx
INITCOMMONCONTROLSEX controls = { sizeof(INITCOMMONCONTROLSEX), ICC_STANDARD_CLASSES };
if (!InitCommonControlsEx(&controls)) { MessageBoxA(NULL, "Loading controls failed\n", NULL, 0); }
這是我在 WM_CREATE 中創建按鈕的代碼:
int cx_check_box = GetSystemMetrics(SM_CXMENUCHECK) - GetSystemMetrics(SM_CXEDGE);
int cy_check_box = GetSystemMetrics(SM_CYMENUCHECK) - GetSystemMetrics(SM_CYEDGE);
HWND check_box = CreateWindowW(L"BUTTON", L"", WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX, 100, 100,
cx_check_box, cy_check_box, hWnd, NULL, (HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE), NULL);
if (!check_box)
MessageBoxA(NULL, "check box creation failed :(", NULL, MB_RETRYCANCEL);
go 如何讓復選框占據整個空間? 或者讓額外的空間 go 遠離/透明? 先謝謝您的幫助。
Windows SDK 版本 - 10.0.22621.0(即 windows 11 afaik)
您可以處理WM_CTLCOLORBTN消息並將背景設置為紅色。
case WM_CTLCOLORSTATIC:
{
static HBRUSH hBrushColor;
if (!hBrushColor)
{
hBrushColor = CreateSolidBrush(RGB(255, 0, 0));
SetBkColor((HDC)wParam,RGB(255, 0, 0));
}
return (LRESULT)hBrushColor;
}
break;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.