如何在MFC中的按钮中添加图像和文本? [英] How to add an image along with Text in a button in MFC?

查看:81
本文介绍了如何在MFC中的按钮中添加图像和文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我很难在按钮中添加图像和文本..我知道可以通过启用具有bitmapbutton类的所有者绘制功能来完成此操作.还有其他方法可以在不绘制文本的情况下与文本一起添加图像吗?

hello all,Am having a hard time in adding image along with a text in a Button..I know that it can be done by enabling the owner draw function with bitmapbutton class..But I dont want to that..so is ther anyother way that i can add an image along with text without drawing the text?

推荐答案

写道:

但我不想这样.



如果您知道该怎么做,但又不想这样做,那么我建议您求助于祈祷.



If you know how to do it, but you don''t want to, then I suggest you resort to prayer as an alternative.


因此,我的问题再也没有得到任何答复.一个聪明的人误解了我的问题,并回答了一个不适用于我的问题的答案.最后,我浏览了很多有关将图像添加到按钮的文章,而我想做的就是将图像和文本都添加到按钮上...这可以使用ownerdraw ..我不想实现ownerdram的原因是因为它使您的工作更加复杂..因为您必须绘制文本(已连接4个程序员)以禁用,单击并正常显示状态..现在回到我的观点..u可以使用下面的代码在按钮中添加图像和文本...

So,again I got no replies for my Question except a brilliant guy mis-understood my question and replied an answer which is not applicable for my Question.And atlast I went through lot of articles about adding Images to a Button.What Exactly I wanted was to add an image and text both to a button...It can be done using ownerdraw..the reason why I dont want to implement the ownerdram is because it makes your work more complicated..because u gotta draw the text(which is wired 4 programmer) for disable,click and normal states..Now coming back to my point..u can use the below code to add an image and text in a button...

HICON addIcon = (HICON)LoadImage(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_MYICON),
						IMAGE_ICON,0,0,LR_DEFAULTCOLOR);		 	
	
	SendMessageA(::GetDlgItem(m_hWnd,IDC_MYBUTTON),BM_SETIMAGE,IMAGE_ICON,(LPARAM)(DWORD)addIcon

);

BM_SETIMAGE在这里是一条重要消息.因为它负责在按钮中设置文本和图像

);

BM_SETIMAGE is an important message here..because it is responsible for setting Text and an image in a button


这篇关于如何在MFC中的按钮中添加图像和文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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