如何在不使用其他任何头文件(如CbuttonStyle)的情况下创建透明按钮 [英] how to create transparent button without using any other header files like CbuttonStyle

查看:77
本文介绍了如何在不使用其他任何头文件(如CbuttonStyle)的情况下创建透明按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建一个透明按钮,以便我可以查看按钮后面的图片而无需使用任何头文件?

How to Create a transparent button so that i can view a picture behind the button.with out using any header files?

推荐答案

看看 WM_CTLCOLORBTN [创建空心笔刷 [
have a look at WM_CTLCOLORBTN[^] - then create a hollow brush[^]

maybe :)


HBRUSH CInstructions::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
 
if(WM_CTLCOLORBTN)
{
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0,0,0));
hbr = (HBRUSH)GetStockObject( HOLLOW_BRUSH);
}
return hbr;
}



在按钮的属性中使按钮OwnerDraw = true.
如果为按钮创建了变量,则其类型应为CButtonStyle

可以在其中下载ButtonStyle.h,ButtonStyle.cpp,Buttons.h和Buttons.cpp文件并将其复制到 ^ ]


在项目和源文件中包含CButtonStyle.h,CButtonStyle.cpp.
然后在您的项目标头中声明
CButtonStyle myButton;

我在vc ++ 2008版本中尝试过此操作.



make button OwnerDraw=true in properties of button.
If the variable is created for the button then its type should be CButtonStyle

Where the ButtonStyle.h ,ButtonStyle.cpp,Buttons.h and Buttons.cpp file can be downloaded and copied in to the project folder in the An easy way to create transparent button[^]


include CButtonStyle.h,CButtonStyle.cpp in the project and in source file.
then declare in ur project header
CButtonStyle myButton;

I tried this in vc++2008 version.


这篇关于如何在不使用其他任何头文件(如CbuttonStyle)的情况下创建透明按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆