Discussion:
Bitmap on a dialog - dump question
(too old to reply)
Markus Zingg
2005-12-21 14:53:09 UTC
Permalink
Hi Group

I have a dialog with a control having the ss_bitmap style. I know that
I can use the WM_PAINT message in dialog procedure to paint the
bitmap.

However, if I have a text control, SetWindowText() in WM_INITDIALOG is
sufficient for the dialog to know and update the text as long as the
dialog is alive.

Now one would expect a similar functionality for bitmaps - no? Is
there a much simpler way than using WM_PAINT with all it's DC loading
yadda yadda which I simply missed so far?

TIA

Markus
David Lowndes
2005-12-21 20:51:59 UTC
Permalink
Post by Markus Zingg
I have a dialog with a control having the ss_bitmap style. I know that
I can use the WM_PAINT message in dialog procedure to paint the
bitmap.
However, if I have a text control, SetWindowText() in WM_INITDIALOG is
sufficient for the dialog to know and update the text as long as the
dialog is alive.
Now one would expect a similar functionality for bitmaps - no? Is
there a much simpler way than using WM_PAINT with all it's DC loading
yadda yadda which I simply missed so far?
Markus,

You already have the answer: SS_BITMAP. A control with that style with
an image assigned to it using STM_SETIMAGE draws the image itself.

Dave
Norman Bullen
2005-12-22 04:39:25 UTC
Permalink
Post by Markus Zingg
Hi Group
I have a dialog with a control having the ss_bitmap style. I know that
I can use the WM_PAINT message in dialog procedure to paint the
bitmap.
However, if I have a text control, SetWindowText() in WM_INITDIALOG is
sufficient for the dialog to know and update the text as long as the
dialog is alive.
Now one would expect a similar functionality for bitmaps - no? Is
there a much simpler way than using WM_PAINT with all it's DC loading
yadda yadda which I simply missed so far?
TIA
Markus
Actually, you should _never_ try to get a window (and a STATIC control
is a window) by sending it a WM_PAINT message.

David has given you the correct answer; the control will repaint itself
whenever it knows that it's necessary, such as when you assign a bitmap
to it with STM_SETIMAGE.

If you have reason to believe that something related to a control or
other window has changed, and the window needs to be repainted, use
InvalidateRect() rather than sending a WM_PAINT message.

Norm
--
--
To reply, change domain to an adult feline.
Markus Zingg
2005-12-22 09:24:23 UTC
Permalink
Post by Norman Bullen
Actually, you should _never_ try to get a window (and a STATIC control
is a window) by sending it a WM_PAINT message.
David has given you the correct answer; the control will repaint itself
whenever it knows that it's necessary, such as when you assign a bitmap
to it with STM_SETIMAGE.
If you have reason to believe that something related to a control or
other window has changed, and the window needs to be repainted, use
InvalidateRect() rather than sending a WM_PAINT message.
Norm
Thank you Norm and David

Actually I was after hearing about the STM_SETIMAGE message. Searching
google and msdn with those keywords I thought would relate to the
topic were not helpfull.

Am I right with my asumption that I must call DeleteObject on the
bitmap handle passed to the control with this message before I call
EndDialog() ?

Markus
David Lowndes
2005-12-22 18:45:23 UTC
Permalink
Post by Markus Zingg
Am I right with my asumption that I must call DeleteObject on the
bitmap handle passed to the control with this message before I call
EndDialog() ?
Markus,

Generally, you need to delete anything you've created. If you've not
created a GDI object (used a stock one perhaps), you don't need to
call DeleteObject, otherwise you do :)

Dave

Continue reading on narkive:
Loading...