SetBitmap Problem
-
Hi All, I use a CStatic to show a bitmap in a dialog. The bitmap is a thumbnail of a file. Everytime when a file is chosen, the code call CStattic::SetBitmap to associates a new bitmap with the static control and the bitmap will be shown out immediately. But I minimize the dialog and maximize the dialog again, the bitmap in the CStatic control can't be shown out. Do you know how to show the picture out again when the dialog is maximized? thanks, Eric
-
Hi All, I use a CStatic to show a bitmap in a dialog. The bitmap is a thumbnail of a file. Everytime when a file is chosen, the code call CStattic::SetBitmap to associates a new bitmap with the static control and the bitmap will be shown out immediately. But I minimize the dialog and maximize the dialog again, the bitmap in the CStatic control can't be shown out. Do you know how to show the picture out again when the dialog is maximized? thanks, Eric
Sounds like you've got a problem with the control not repainting itself. What if you call Invalidate() on the CStatic when your form is shown ? ( NOte : this should have happened by itself )
Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
-
Hi All, I use a CStatic to show a bitmap in a dialog. The bitmap is a thumbnail of a file. Everytime when a file is chosen, the code call CStattic::SetBitmap to associates a new bitmap with the static control and the bitmap will be shown out immediately. But I minimize the dialog and maximize the dialog again, the bitmap in the CStatic control can't be shown out. Do you know how to show the picture out again when the dialog is maximized? thanks, Eric
Is the bitmap getting deleted after you set it? If you're using CBitmap, and it goes out of scope, it will delete the gdi object.
- S 50 cups of coffee and you know it's on!
-
Is the bitmap getting deleted after you set it? If you're using CBitmap, and it goes out of scope, it will delete the gdi object.
- S 50 cups of coffee and you know it's on!
The code is like this:
{
CBitmap tempBitmap;
...
HBITMAP hBitmap = HBITMAP(tempBitmap);
m_picHolder.SetBitmap(hBitmap);
...
}When call SetBitmap again, the bitmap can be shown out. But it will disappear after minimize and maximize the dialog. Thanks, Eric
-
The code is like this:
{
CBitmap tempBitmap;
...
HBITMAP hBitmap = HBITMAP(tempBitmap);
m_picHolder.SetBitmap(hBitmap);
...
}When call SetBitmap again, the bitmap can be shown out. But it will disappear after minimize and maximize the dialog. Thanks, Eric
Eric Vonjacson wrote:
CBitmap tempBitmap;
You need to create on heap , using new. Or , make CBitmap object, as member variable along with m_picHolder.
Prasad Notifier using ATL | Operator new[],delete[][^]
-
The code is like this:
{
CBitmap tempBitmap;
...
HBITMAP hBitmap = HBITMAP(tempBitmap);
m_picHolder.SetBitmap(hBitmap);
...
}When call SetBitmap again, the bitmap can be shown out. But it will disappear after minimize and maximize the dialog. Thanks, Eric
I think tempBitmap is deleted when it goes out of scope, which also deletes the gdi resource it's wrapping. Try adding a CBitmap member variable to your class like: CBitmap m_bitmap; then in your function: { m_bitmap.LoadBitmap(); // or however you're getting it m_picHolder.SetBitmap(m_bitmap); }
- S 50 cups of coffee and you know it's on!