黑龙江省建设厅网站站长,wordpress免费域名,历史看过的网站,十八款免费的软件下载在编写对话框程序时#xff0c;希望能在按钮控件里显示一个小插图,如图所示 最初使用的方法是使用 BM_SETIMAGE 消息#xff0c;但却不能达到满意的效果#xff0c;在网上查了一通资料#xff0c;最后终于实现了#xff0c;现在把实现的方法记下来。
首先来到MSDN上…在编写对话框程序时希望能在按钮控件里显示一个小插图,如图所示 最初使用的方法是使用 BM_SETIMAGE 消息但却不能达到满意的效果在网上查了一通资料最后终于实现了现在把实现的方法记下来。
首先来到MSDN上查得如下资料 BM_SETIMAGE message
Associates a new image (icon or bitmap) with the button.
Parameters
wParam
The type of image to associate with the button. This parameter can be one of the following values:
IMAGE_BITMAPIMAGE_ICON
lParam
A handle (HICON or HBITMAP) to the image to associate with the button.
Return value
不重要略
Remarks
The appearance of text, an icon, or both on a button control depends on the BS_ICON and BS_BITMAP styles, and whether the BM_SETIMAGE message is called. The possible results are as follows: BS_ICON or BS_BITMAP Set?BM_SETIMAGE Called?ResultYesYesShow icon only.NoYesShow icon and text.YesNoShow text only.NoNoShow text only既然希望同时显示图片和文字那么就应该采取上表中的第二行设置蓝色。
故控件属性设置为 然后在 OnInitDialog() 函数中添加如下语句 SendDlgItemMessage(hwnd,IDC_BUTTON1,BM_SETIMAGE,IMAGE_BITMAP,(LPARAM)LoadBitmap(hIn,MAKEINTRESOURCE(IDB_BITMAP1)));但是效果却是这样的 如果把控件属性中的Bitmap项改为 True 效果又成了这个样子 真的很让人抓狂。在一通搜索后发现解决方案就在MSDN中。在BM_SETIMAGE词条的下面有一条老外的评论是这样的 Community Additions
Icon with text solution
I had the same problem for the icon text in the button and I solved using the version 6 of the common controls. You can make this by adding the library (if I understand it, Im not sure). However Ive added it with the preprocessor directive:
#pragma comment(linker,\/manifestdependency:typewin32 nameMicrosoft.Windows.Common-Controls version6.0.0.0 processorArchitectureX86 publicKeyToken6595b64144ccf1df language*\) EDIT: This preprocessor directive go on a single line, I dont know why It force me to put a line break after #pragma Linkinf94 1/14/2013
也就是说使用6.0.0.0版本的 Common-Controls 就好了所以在程序里加上这么一句话 #pragma comment(linker,\/manifestdependency:typewin32 nameMicrosoft.Windows.Common-Controls version6.0.0.0 processorArchitectureX86 publicKeyToken6595b64144ccf1df language*\)就万事OK了64位平台改为AMD64) 关于 Common-Controls 还可以参考 http://blog.csdn.net/thirdprince/article/details/6336010