win32 c++所有者绘制带有透明图像的按钮
我已经在我的 win32 应用程序中实现了一个所有者绘制按钮(没有 MFC)。该按钮是普通的 20x20 位图(具有透明度的圆形图标)。问题是按钮位于纯色背景上,我可以看到按钮灰色背景(因为位图是圆形的)。我尝试用 NULL_BRUSH 响应 WM_CTLCOLORBTN 但没有运气。我尝试使用位图和 ico 文件显示按钮,但不会让步。有谁知道如何解决这个问题?
这是我的问题,设置图标的边缘应该是透明的(不是白色/灰色)
i've implemented a owner draw button into my win32 app (no MFC). The button is a normal 20x20 bitmap (round icon with transparency). The problem is that the button is positioned on a solid background and i can see the buttons gray background (since the bitmap is round). I've tried responding to WM_CTLCOLORBTN with NULL_BRUSH but no luck.. I've tried displaying the button using a bitmap and a ico file but wont budge.. Does anyone know how to solve this problem?
This is my problem, the settings icon should be transparent at the edges (not white/gray)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
除了@joel的答案之外,如果您想让某些区域透明,请使用一些图像编辑器(RGB(0xFF,0x00,0xFF))在您想要具有透明度的区域中放置独特的颜色,然后使用 TransperantBlt
In addition to what @joel's answer, if you want to make some area transperant put a unique color in the area where you want to have transperancy using some image editors (RGB(0xFF,0x00,0xFF)) is mostly used Then use TransperantBlt
您说它是纯色背景,但您的图像显示某种橙黄色渐变作为背景。如果它确实是标准的 Windows 按钮纯色,您可以使用 LR_LOADMAP3DCOLORS 或 LR_LOADTRANSPARENT 通过 LoadImage 加载位图。由于您有渐变,因此您必须使用更复杂的技术来遮盖位图。
http://www.winprog.org/tutorial/transparency.html
You say it's a solid background but your image shows some kind of orange-yellow gradient as a background. If it really was a standard windows button solid color you can load the bitmap with LoadImage using the LR_LOADMAP3DCOLORS or LR_LOADTRANSPARENT. Since you have a gradient you'll have to use a more complicated technique to mask out the bitmap.
http://www.winprog.org/tutorial/transparency.html
听起来您正在尝试制作一个非矩形控件。
您可以调用
SetWindowRgn
告诉 Windows 您的控件是非矩形的。It sounds like you're trying to make a non-rectangular control.
You could call
SetWindowRgn
to tell Windows that your control is non-rectangular.