如何在不同的按钮状态下加载不同的位图? [英] How load different bitmaps on different button states ?

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

问题描述





我想在不同的按钮状态下加载不同的位图。对于单击按钮时的实例,鼠标悬停和正常状态。就像这样我要加载三个状态的三个不同的位图。通常这可以通过CBitmap完成:SetBitmap(),我能够以我想要的所有方式加载。但问题是当我检查在Windows XP机器上运行我的应用程序然后位图是没有加载。



我完全不确定为什么他们没有被加载。任何人请让我知道这是我的位图加载的问题。如果是这样,我能够在其他操作系统上加载它们。



如果这不是获取位图的方法,那么请告诉我如何加载位图等我必须能够在所有操作系统上加载和设置位图。



请找到我为将按钮设置为按钮而实现的代码,类似于鼠标悬停并点击按钮,



 CButton * pMyButton =(CButton *)GetDlgItem(IDC_BTN_STANDARD); 
BitmapStd.LoadBitmap(IDB_STANDARD_IDEAL_BMP);
HBITMAP hBitmap =(HBITMAP)BitmapStd.GetSafeHandle();
pMyButton - > SetBitmap(hBitmap);







先谢谢。

解决方案

我是这样做的:

 HBITMAP hBmp; 

// 从程序资源中加载位图
hBmp = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE( 222 ));

// 将消息发送到按钮,重新绘制自己
SendMessage(GetDlgItem(hDlg,IDC_PWBUTTON),BM_SETIMAGE,(WPARAM)IMAGE_BITMAP,(LPARAM)hBmp);
}



按钮在资源文件中定义:

 PUSHBUTTON  & Password,IDC_PWBUTTON, 13 ,< span class =code-digit> 48 , 40  40 ,BS_BITMAP 


Hi,

I want load different bitmaps on different button states .For Instance when button is clicked ,mouse hovering and normal state.Like this I want to load three different bitmap on three states.Usually this can be done by CBitmap:SetBitmap() ,and I am able to load in all the ways I want.But the problem is when I checked running my application on windows XP machine then the bitmaps are not getting loaded.

I am not at all sure why they are not getting loaded.Can anyone please let me know is this problem with my bitmap loading.If so,I able to load them on other operating systems right.

If this is the not the way to get the bitmaps,then kindly let me know how can I load bitmap such that I must be able to load and setbitmaps on all operating systems.

Please find the code I implemented for setting the bitmap on to the button,similarly done for mouse hovering and button click,

CButton *pMyButton = (CButton*)GetDlgItem(IDC_BTN_STANDARD);
BitmapStd.LoadBitmap(IDB_STANDARD_IDEAL_BMP);
HBITMAP hBitmap = (HBITMAP)BitmapStd.GetSafeHandle();
pMyButton ->SetBitmap(hBitmap);




Thanks in Advance.

解决方案

I do it with something like this:

HBITMAP			hBmp;

// load the bitmap from the program's resources
hBmp = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(222));

// send the message to the button, to repaint itself
SendMessage(GetDlgItem(hDlg,IDC_PWBUTTON), BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBmp);
}


The button is defined in the resource file thus:

PUSHBUTTON "&Password",	IDC_PWBUTTON,	 13, 48, 40,  40, BS_BITMAP


这篇关于如何在不同的按钮状态下加载不同的位图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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