使用 Win32 和视觉样式的按钮背景透明度

发布于 2024-07-20 16:45:53 字数 992 浏览 3 评论 0原文

编辑:如果有人以前在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

番薯 2024-07-27 16:45:53

您尝试过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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文