Home All Groups Group Topic Archive Search About

Aligning a picture in the button control.

Author
13 May 2005 6:47 AM
Frank Rizzo
Hello,

I am trying to add a picture to my button, but the picture always places
itself right smack in the middle, while I want to place it to the left
of the text.

Is is possible to pull this off with the standard button control?
If not, what are some of the alternatives (both commercial and free)
that I can use.  Preferably, these alternatives would be able to accept
high-color images (ico, gif, png, etc...).

Thanks

Author
13 May 2005 11:35 AM
Mike D Sutton
> I am trying to add a picture to my button, but the picture always places
> itself right smack in the middle, while I want to place it to the left
> of the text.
>
> Is is possible to pull this off with the standard button control?
> If not, what are some of the alternatives (both commercial and free)
> that I can use.  Preferably, these alternatives would be able to accept
> high-color images (ico, gif, png, etc...).

Here's a solution I came up with a couple of years ago for this, it's a bit messy and can be cleaned up but the principle works:
http://groups.google.co.uk/group/microsoft.public.vb.winapi/browse_thread/thread/d83ebbe861138f44/85a9b70479f6a4be
Hope this helps,

    Mike


- Microsoft Visual Basic MVP -
E-Mail: ED***@mvps.org
WWW: Http://EDais.mvps.org/
Author
13 May 2005 2:18 PM
Ken Halter
"Frank Rizzo" <fri***@notn.com> wrote in message
news:%23NH$re4VFHA.3044@TK2MSFTNGP10.phx.gbl...
> Hello,
>
> I am trying to add a picture to my button, but the picture always places
> itself right smack in the middle, while I want to place it to the left of
> the text.

This may help... but requires subclassing... Mike's code'll probably be more
straight forward.

Drawing Buttons, Option Boxes and Check Boxes In Your Own Style
http://www.vbaccelerator.com/home/VB/Code/Libraries/Subclassing/Owner_Draw_Buttons/article.asp

Make sure you get the subclasser shown in the 'Related' section. It's great
to have anyway.

--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Sign up now to help keep VB support alive - http://classicvb.org/petition
Please keep all discussions in the groups..
Author
16 May 2005 8:56 AM
Dave
Frank

The simplest way to do what you want would be to make a bitmap or icon that
has both your icon and the required text, you would of course need a second
disabled bitmap if the button was ever to be disabled.

Dave

Show quote
"Frank Rizzo" <fri***@notn.com> wrote in message
news:%23NH$re4VFHA.3044@TK2MSFTNGP10.phx.gbl...
> Hello,
>
> I am trying to add a picture to my button, but the picture always places
> itself right smack in the middle, while I want to place it to the left of
> the text.
>
> Is is possible to pull this off with the standard button control?
> If not, what are some of the alternatives (both commercial and free) that
> I can use.  Preferably, these alternatives would be able to accept
> high-color images (ico, gif, png, etc...).
>
> Thanks

AddThis Social Bookmark Button