更改按钮PNG图像 [英] Change Button PNG Image
本文介绍了更改按钮PNG图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在此学习体验上进展缓慢!
$
点击时,我现在无法更改按钮PNG图像。
我在inputButton类中有这个函数:
Progressing slowly on this learning experience!
I'm now stuck at changing the buttons PNG image when it's clicked.
I have this function in the inputButton class:
void toggleButton(HWND buttonHandle, int buttonId, int buttonState) {
switch (buttonState) {
case 0: {
this->setButtonState(1);
buttonState = 1;
Gdiplus::Bitmap* m_pBitmap;
HICON hicon;
m_pBitmap = Gdiplus::Bitmap::FromFile(L"greenSwitch.png");
m_pBitmap->GetHICON(&hicon);
LRESULT lr = SendMessage(buttonHandle, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hicon);
ShowWindow(buttonHandle, 1);
UpdateWindow(buttonHandle);
}
break;
}
};
但图片不会改变...
我有一种感觉我不能在这里改变它,它必须在WM_DRAWITEM或WM_PAINT回调中完成。这是正确的吗?
But the image doesn't change...
I have a feeling I can't change it here and it has to be done in the WM_DRAWITEM or WM_PAINT callbacks. Is that correct?
推荐答案
您的按钮是否设置了BS_ICON或BS_BITMAP样式?
Does your button have the BS_ICON or BS_BITMAP style set?
您是否检查了代码以确保hicon包含HICON?
Did you check the code to make sure the hicon contains an HICON?
这篇关于更改按钮PNG图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文