首先感谢 Darren Sessions、Christian Graus、Joe Woodbury
本人在项目中需要实现button加载PNG图片,且在鼠标在button区域时相应一个事件,比如再加载一张图,或者把一加载上去的图加亮什么的。
PS:翻看国内现存的资料终于找到了解答,那就是连接到了国外网站,终于不像国内下载个代码不仅仅要你注册,你说回复你的主题还是能理解的,还要我付费,这你MTD何必呢,穷疯了,你多挂些广告,加代码让我们点了广告才能下载也得嘛,是不?不是商业机密的东西至于那么要紧?两千年继承下来就是“闭门造车”
参照下面3篇文章就能完成想要的功能。
1,Starting with GDI+
http://www.codeproject.com/KB/GDI-plus/startinggdiplus.aspx
2,Loading JPG & PNG resources using GDI+
http://www.codeproject.com/KB/GDI-plus/cgdiplusbitmap.aspx
3,A user draw button that supports PNG files with transparency, for Visual C++ 6.0 and VS2005
http://www.codeproject.com/KB/buttons/GdipButton.aspx
前两篇主要是添加对应代码来启动GDI+,因为我想要的功能是第三个中才有的,但是他使用了前两篇中的.CPP和.H,所以必须遵循前两篇的规则来加代码。
其实上述文章并不难看懂(连我这个四级都没过的人都能看懂),耐心点看就好了。
其实第一篇和第二篇要加的地方是一样的,但是要完成的demo有区别罢了。
就按第二篇来配置
对于第二篇中说要添加的地方:
GDI+ needs to be initialized before any GDI+ calls are made. I suggest adding the following data member to the class derived from CWinApp
:
而不是CTest00Dlg中
而是在Test00.h中
class CTest00App : public CWinApp
...............
}
Test00.cpp中
BOOL CTest00App::InitInstance()
................
}
重载这个的时候,因为看到头晕了,所以用向导找到对应添加的地方,就手动添加的 - =;
int CTest00App::ExitInstance()