使用 Win32 和视觉样式的按钮背景透明度
编辑:如果有人以前在 win32 中尝试过此操作,我使用 DrawThemeBackground() 的方向是否正确?
我最近使用版本 6 的清单启用了视觉样式ComCtl32.dll 的。 Win32 中的视觉样式示例:视觉样式
这些按钮看起来很棒,但我不知道如何使按钮周围的背景透明。 请参阅示例图片: http://www.freeimagehosting.net/image.php?2bdeff33ba .jpg
我的主窗口背景颜色设置为深灰色:
a.hbrBackground = GetStockObject(DKGRAY_BRUSH);
常用控件初始化为:
INITCOMMONCONTROLSEX stylesStruct;
stylesStruct.dwSize = sizeof(stylesStruct);
stylesStruct.dwICC = ICC_STANDARD_CLASSES;
InitCommonControlsEx(&stylesStruct);
我创建按钮窗口:
j = CreateWindow(L"BUTTON", L"hello",
WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, 100, 100,
100, 100, h, 0, hInst, 0);
按钮在白色背景上看起来很好,但边框在其他任何内容上都可见。 是否可以使按钮周围的边框透明?
Edit: If anyone's tried this in win32 before, am I going in the right direction by using DrawThemeBackground()?
I'v recently enabled Visual Styles using a manifest for version 6 of ComCtl32.dll. Example of Visual Styles in Win32: Visual Styles
The buttons look great, but I can't figure out how to make the background around the buttons transparent. Please see example image: http://www.freeimagehosting.net/image.php?2bdeff33ba.jpg
My main window background color is set to dark grey with:
a.hbrBackground = GetStockObject(DKGRAY_BRUSH);
The common controls are initialized with:
INITCOMMONCONTROLSEX stylesStruct;
stylesStruct.dwSize = sizeof(stylesStruct);
stylesStruct.dwICC = ICC_STANDARD_CLASSES;
InitCommonControlsEx(&stylesStruct);
And I create the button windows with:
j = CreateWindow(L"BUTTON", L"hello",
WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, 100, 100,
100, 100, h, 0, hInst, 0);
Buttons look fine over a white background, but the border becomes visible over anything else. Is it possible to make the border around buttons transparent?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您尝试过
WS_EX_TRANSPARENT
吗?我认为您可以在 Visual Studio 的资源编辑器中设置它(如果您正在使用它)。
Have you tried
WS_EX_TRANSPARENT
?I think you can set it in the resource editor in Visual Studio, if you're using that.