MFC按钮图像/图标疯狂 [英] MFC Button image/icon madness

查看:72
本文介绍了MFC按钮图像/图标疯狂的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,



虽然在代码项目中MFC按钮似乎有几个很好的改进,但我想检查一下我不是遗漏了一些明显我无法使用Visual Studio的对话框编辑器直接使用图像/图标MFC按钮来实现我想要的功能。



我想要的是一个按钮,边框很好,但没有冷却,有一个包含透明度的图像。也就是说,当前Windows主题的对话框背景颜色被假定为图像的背景颜色。



我最接近的是将源PNG文件加载到GIMP2中。 6并将其保存为Windows ICO格式。它在GIMP中看起来很好。导入时在VS2010的编辑器中看起来很好;即它与GIMP保存的大小相同。



OK



但是当我设置一个MFC按钮时在一个对话框中,在属性窗格中有一个图像类型的图标,并选择我可爱的大型PNG-now-ICO的ID,它突然非常小。



我想也许有一个奇怪的默认值为32x32或48x48等?但是,如果我将autosize属性设置为true,则按钮会折叠为更小。我可以调整按钮的大小,但图标不会变大。



如果没有办法将大图标放到按钮上,我将非常感谢任何代码建议项目按钮增强提交,知道使用对话框编辑器作为自定义控件。



我花了几个小时搜索但没有找到答案 - 如果我遗漏了某些东西,道歉很简单。



我从快速播放中注意到C#对话框编辑器和按钮控件直接从PNG工作。



祝你好运,



Neil。

解决方案

这是一篇可以满足您需求的文章:支持Visual C ++ 6.0的PNG文件的用户绘图按钮和VS2005 [ ^ ]

Dear all,

While there are what appear to be several excellent improvements to the MFC button here at code project, I would like to check that I am not missing something obvious. I cant get image/icon MFC buttons to do what I want straight out of the box with Visual Studio's dialog editor.

What I want is to have a button, with a border is fine, but cooler without, that has an image which includes transparency. That is, where the current Windows theme's dialog background colour is assumed as the image's background colour.

The closest I have got is to load the source PNG file into GIMP2.6 and save it out as a Windows ICO format. It looks fine in GIMP. It looks fine in VS2010's editor when imported; i.e. its the same size as saved from GIMP.

OK

But when I set a MFC Button on a dialog to have an "image type" of "icon" in the properties pane and select the ID of my lovely large PNG-now-ICO its suddenly very small.

I thought maybe there is an odd default of 32x32 or 48x48 etc.? But if I set the "autosize" property to true the button just collapses to be even smaller. I can resize the button but the icon will get no larger.

If there is no way of getting large icons onto buttons I would be very grateful for any recommendations of code project button enhancement submissions that are know to work with the dialog editor as custom controls.

I have spent hours searching but have found no answers - apologies if I have missed something simple.

I noticed from a quick play around that the C# dialog editor and button control works straight off from a PNG.

Best regards,

Neil.

解决方案

Here's an article that will do what you want: A user draw button that supports PNG files with transparency, for Visual C++ 6.0 and VS2005[^]


这篇关于MFC按钮图像/图标疯狂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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