News:

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

Bitmap on Static Control (Confused)

Started by Ksbunker, February 26, 2006, 01:04:51 AM

Previous topic - Next topic

Ksbunker

Okay, i've added a bitmap to my resource, and its called

IDB_BITMAP

I've included it in the source as IDB_BITMAP equ 500... everything is sweet

I try the following to place the bitmap onto a static control, but it just doesn't work!!

Invoke LoadBitmap, hInstance, 500
Invoke SendMessage, IDC_LOGO, BM_SETIMAGE, IMAGE_BITMAP, eax

Where IDC_LOGO is a static control, not a button, but I made IDC_LOGO a button as well and it did nothing. I first placing this in WM_INITDIALOG, nothing happened, then tried WM_CREATE, same thing.

Any help would be appreciated. I know this should work, im just puzzled as to why it is not!

Mincho Georgiev

Hi There!
The SendMessage Function sends a message to the destination window by a window handle (the 1st paramater),not to the control ID,so you need to do the following:


invoke GetModuleHandle,NULL
invoke LoadBitmap,eax,500 ;//the bitmap's ID in your resource script
mov hBitmap,eax ;// Bitmap's handle
invoke GetDlgItem,hDlg,ID_STATIC ;//where hDlg is the handle of the Dialog and ID_STATIC is the control ID in your resource script.
;//now in eax you have a valid window handle of the static control,so...
invoke SendMessage,eax,STM_SETIMAGE,IMAGE_BITMAP,hBitmap


I had posted this example before ,it was related to someting else,but it will help you alot:

http://www.freewebs.com/shaka_zulu/trackedmusic_demo.zip

donkey

Be sure that you have the proper style bits set for your static control, it must have the SS_BITMAP style, ie

invoke CreateWindowEx,WS_EX_STATICEDGE,"STATIC","PICBOX",WS_CHILD + WS_VISIBLE + SS_BITMAP, \
[left],[top],[right],[bottom],[hparent],1001,[hInstance],NULL
"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

sheep

You could also use SendDlgItemMessage instead of GetDlgItem+SendMessage

Mincho Georgiev

Correct. GetDlgItem is in case that you will use the returned handle more than once.

Ksbunker

Got it working thanks guys.

Now, my problem is that when the button is smaller than the bitmap or exactly the same size as the bitmap, it always shows a one pixel white border aroundthe button! Which of course, I do not want.

I tried WM_CTLCOLORBTN and change the colour to Black (the bitmap is mostly black) and it did nothing. Any Ideas?