OK, I finally got MASM32 downloaded so I can ditch the TASM5 I've been using. I must admit, things DO seem to be progressing a bit more quickly now. Here's where I'm stumped: Is it possible to use "SendMessage" (or SendDlgItemMessage)with BM_SETIMAGE to load a bitmap onto a button when the button was created in the template? From the msdn lookups I've done, it seems as though it SHOULD work...

invoke LoadBitmap, hDlg, 100
mov bmpHandle,eax
invoke GetDlgItem,hDlg,IDC_TEST_BUTTON
mov hBtn,eax
invoke SendMessage,hBtn,BM_SETIMAGE,IMAGE_BITMAP,bmpHandle
Am I completely off-base on this, or what? Would the button have to be created in the dialog template differently? Can "BS_BITMAP" be used in a template with PUSHBUTTON or DEFPUSHBUTTON controls? Or did I just make a REALLY retarted oversight somewhere? Once again, any and all help would be appreciated.
Posted on 2001-02-13 04:25:00 by Q
Make sure LoadBitmap returns a valid bitmap handle
Posted on 2001-02-13 05:40:00 by Iczelion
Q, This is the code I use in the MASM32 library module butv you MUST make sure you set the static control to SS_BITMAP or else it will not work. invoke LoadBitmap,hModule,bmpID mov hBmp, eax invoke SendMessage,hStatic,STM_SETIMAGE,IMAGE_BITMAP,hBmp Your code looks like it should work OK, it differes only in that you gwet the handle with GetDlgItem() which should work OK. Good luck with it, hutch@pbq.com.au
Posted on 2001-02-13 05:44:00 by hutch--
Iczelion's got it right. LoadBitmap is failing. Not sure just why it's failing, but it is. I'll keep messing with it, if you've got any ideas, please let me know.
Posted on 2001-02-13 14:38:00 by Q
What you posted was

   invoke LoadBitmap, hDlg, 100
where hutch has

   invoke LoadBitmap, hModule, bmpID
A dialog handle is a window handle, but the API needs a module/instance handle (for the loaded EXE or DLL file). The needed handle references the file that contains the bit map. To get the handle of the EXE file, you can use (if you haven't already),

    invoke GetModuleHandle,NULL
Posted on 2001-02-13 21:33:00 by tank
In the immortal words of Homer Simpson: "DOH!" Yep, I was using the dialog handle alright... Unfortunately, the EXE handle doesn't seem to work either. LoadBitmap fails either way. I guess I'll have to go over Icz's bitmap tutorial again, I _know_ I must be missing something really simple.
Posted on 2001-02-14 03:05:00 by Q
DOH! Finally got it...
100 BITMAP "bitmap.bmp"
and in the dialog template:
PUSHBUTTON      "", 4321, 15,40,20,20, BS_BITMAP
and of course, in the code:

invoke GetModuleHandle, NULL
invoke LoadBitmap, eax, 100
mov hBmp,eax
.
.
.
invoke GetDlgItem,hDlg,4321
invoke SendMessage,eax,BM_SETIMAGE,IMAGE_BITMAP,hBmp
Thanks for the help... Will probably be back with another "newbie" question in a few minutes... Hard to believe I was once pretty handy with ASM, eh? Back in the days when DOS ruled the PC universe... I'll get this win32 stuff down eventually.
Posted on 2001-02-14 10:29:00 by Q