|
|
|
date: Mon, 2 Jun 2008 22:44:27 +0400,
group: microsoft.public.win32.programmer.ui
back
Image + text on a button
Hello, hope this is the right group. 8=]
This is from the MSDN Library page on BM_SETIMAGE:
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? Result
Yes Yes Show icon only.
No Yes Show icon and text.
I wanted to get both icon and text, so I didn't set BM_ICON on my button. In
WM_INITDIALOG (yes, the button is in a dialog) I say:
~
SendDlgItemMessage(hwndDlg, IDC_CREATE, BM_SETIMAGE, IMAGE_ICON,
reinterpret_cast<LPARAM>(create_image));
~
It doesn't work. The button shows text only. Now, if I do set the BS_ICON
style, it works, but there's no text, as documented.
Just in case, create_image is instantiated as follows:
~
create_image = LoadImage(g_current_instance,
MAKEINTRESOURCE(IDI_ICONCREATE), IMAGE_ICON, 32, 32, LR_SHARED);
~
So how do I make it work?
Also, I heard that the text & image configuration only works on Vista. Is
that true? And if it is, is that documented? Because I can't find it.
Thanks.
date: Mon, 2 Jun 2008 22:44:27 +0400
author: Roman ru
Re: Image + text on a button
On Jun 2, 11:44 am, "Roman" <DXDragonDEL...@yandex.THISru> wrote:
> Hello, hope this is the right group. 8=]
>
> This is from the MSDN Library page on BM_SETIMAGE:
>
> 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? Result
> Yes Yes Show icon only.
> No Yes Show icon and text.
>
> I wanted to get both icon and text, so I didn't set BM_ICON on my button. In
> WM_INITDIALOG (yes, the button is in a dialog) I say:
>
> ~
> SendDlgItemMessage(hwndDlg, IDC_CREATE, BM_SETIMAGE, IMAGE_ICON,
> reinterpret_cast<LPARAM>(create_image));
> ~
>
> It doesn't work. The button shows text only. Now, if I do set the BS_ICON
> style, it works, but there's no text, as documented.
> Just in case, create_image is instantiated as follows:
>
> ~
> create_image = LoadImage(g_current_instance,
> MAKEINTRESOURCE(IDI_ICONCREATE), IMAGE_ICON, 32, 32, LR_SHARED);
> ~
>
> So how do I make it work?
>
> Also, I heard that the text & image configuration only works on Vista. Is
> that true? And if it is, is that documented? Because I can't find it.
>
> Thanks.
Hi,
You need to make the button an owner-drawn button and handle
the text drawn using the style BS_OWNERDRAW, and handle
the following Windows message:
WM_DRAWITEM
Or,
You can fabricate an image that contains both the image and the
text, and use the following API to set the image on the button:
SendMessage() BM_SETIMAGE
http://msdn.microsoft.com/en-us/library/bb775923(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms644950(VS.85).aspx
http://msdn.microsoft.com/en-us/library/bb761822(VS.85).aspx
Kellie.
date: Mon, 2 Jun 2008 12:46:02 -0700 (PDT)
author: Kellie Fitton
|
|