News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

How to create a button with icon & text?

Started by rogerio, April 11, 2009, 10:48:24 PM

Previous topic - Next topic

rogerio

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


donkey

Use a bitmap, draw the text on the bitmap and apply it to the button.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

rogerio

Thanks donkey and I will use your suggestion. Is M$ misleading or is something missing in the masm32 compiler?

donkey

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
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

rogerio

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.

donkey

Hi rogerio,

Someone mentioned a problem with the addin a few months ago, I will take a look at it on the weekend.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Vortex

Hi rogerio,

Here are some Masm32 examples :

\masm32\examples\exampl02\bmbutton

\masm32\examples\exampl04\bmpbutn

\masm32\examples\exampl05\nova