Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
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

Re: Image + text on a button   
Kellie Fitton wrote:

> 
> 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:

No.
You don't need at all owner-drawing for bitmap + text !
See MSDN and Google Groups
date: Mon, 02 Jun 2008 22:11:42 +0200   author:   Henry

Re: Image + text on a button   
Thanks, but I don't think I'm going through such a hassle just to display 
the text. I guess I'll stick to displaying just the image.

Was I was really looking for is the confirmation that BM_SETIMAGE doesn't 
work when BS_ICON is not set. Now I see there's Community Content on 
http://msdn.microsoft.com/en-us/library/bb761822(VS.85).aspx describing this 
issue, so this is probably a documentation bug.

Oh well. 8=]
date: Tue, 3 Jun 2008 00:15:47 +0400   author:   Roman ru

Re: Image + text on a button   
> Thanks, but I don't think I'm going through such a hassle just to display the 
> text. I guess I'll stick to displaying just the image.
>
>
There are several well-known simple methods to display text and image
They have been posted many times on win32 api newsgroup
(comp.os.ms-windows.programmer.win32) since ~1995...
date: Mon, 02 Jun 2008 22:28:28 +0200   author:   Steven

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us