The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: rogerio on April 11, 2009, 10:48:24 PM

Title: How to create a button with icon & text?
Post by: rogerio on April 11, 2009, 10:48:24 PM
According to M$, it is possible to create a button with an icon and text. This is a partial quote from their SDK Button Styles. Thanks...

Quote
The appearance of text or 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.
BM_SETIMAGE called? Result Show icon and text.

This is my current code and I can set text or icon, but not both. Thanks...

;---------- [Create the Button Control] ----------
         INVOKE     CreateWindowEx, 0, addr ButtonClass, addr szButText,\
                    WS_CHILD or WS_VISIBLE or BS_PUSHBUTTON or BS_ICON or \
                    BS_LEFT or BS_VCENTER or BS_TEXT,\
                    100, 50, 100, 40, hWnd, 702, hInstance, 0
         mov     hButCtrl, eax

;---------- [Load the Image] ----------
         invoke     LoadIcon, hInstance, 901
         mov        hImage, eax
         invoke     SendMessage, hButCtrl, BM_SETIMAGE, IMAGE_ICON, hImage

Title: Re: How to create a button with icon & text?
Post by: donkey on April 12, 2009, 12:44:26 AM
Use a bitmap, draw the text on the bitmap and apply it to the button.
Title: Re: How to create a button with icon & text?
Post by: rogerio on April 12, 2009, 01:02:34 AM
Thanks donkey and I will use your suggestion. Is M$ misleading or is something missing in the masm32 compiler?
Title: Re: How to create a button with icon & text?
Post by: donkey on April 16, 2009, 05:14:32 AM
Hi rogerio,

I have uploaded an example of displaying text on a bitmap button to my website. The source (GoAsm) is inlcuded, you can find it on the GoAsm Projects page.

http://www.quickersoft.com/donkey/index.html
Title: Re: How to create a button with icon & text?
Post by: rogerio on April 16, 2009, 10:54:00 AM
Thanks donkey. I noticed one thing, you did not use WM_PAINT which is great. On occasions, I have seen problems out of paint and it required a remodel of the code.

I also downloaded your TB Paint addin for RadAsm while I was on your site, but the addin did not show up in the list. I did put the .dll into the addin folder of RadAsm version 2.2.1.6.
Title: Re: How to create a button with icon & text?
Post by: donkey on April 16, 2009, 01:46:19 PM
Hi rogerio,

Someone mentioned a problem with the addin a few months ago, I will take a look at it on the weekend.
Title: Re: How to create a button with icon & text?
Post by: Vortex on April 16, 2009, 05:35:36 PM
Hi rogerio,

Here are some Masm32 examples :

\masm32\examples\exampl02\bmbutton

\masm32\examples\exampl04\bmpbutn

\masm32\examples\exampl05\nova