The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Ksbunker on February 26, 2006, 01:04:51 AM

Title: Bitmap on Static Control (Confused)
Post by: Ksbunker on February 26, 2006, 01:04:51 AM
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!
Title: Re: Bitmap on Static Control (Confused)
Post by: Mincho Georgiev on February 26, 2006, 01:17:19 AM
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
Title: Re: Bitmap on Static Control (Confused)
Post by: donkey on February 26, 2006, 07:19:41 AM
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
Title: Re: Bitmap on Static Control (Confused)
Post by: sheep on February 26, 2006, 02:26:00 PM
You could also use SendDlgItemMessage instead of GetDlgItem+SendMessage
Title: Re: Bitmap on Static Control (Confused)
Post by: Mincho Georgiev on February 26, 2006, 03:56:49 PM
Correct. GetDlgItem is in case that you will use the returned handle more than once.
Title: Re: Bitmap on Static Control (Confused)
Post by: Ksbunker on February 27, 2006, 05:59:12 AM
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?