flat assembler
Message board for the users of flat assembler.

Index > Windows > Bitmap-button

Author
Thread Post new topic Reply to topic
arnix



Joined: 04 Mar 2005
Posts: 4
arnix 04 Mar 2005, 19:53
Hi, I am trying to create a bitmap-button, here is what I'm doing:

Code:
...
...
...
section '.rsrc' resource data readable

   directory RT_DIALOG,         dialogs,\
             RT_ICON,           icons,\
             RT_GROUP_ICON,     group_icons,\
             RT_BITMAP,         bitmaps

             IDR_LOGO         = 7
             IDR_DOIT         = 10

   resource dialogs,     301, LANG_ENGLISH or SUBLANG_DEFAULT, main
   resource group_icons, 401, LANG_NEUTRAL, main_icon
   resource icons,       1, LANG_NEUTRAL, icon_data
   resource bitmaps,     IDR_DLG_BITMAP, LANG_NEUTRAL, dlgbitmap,\
                         IDR_DOIT, LANG_NEUTRAL, doitbitmap


   ID_DO_B = 907h


   dialog main,'Demo Patcher Program',10,10,168,98,\
                WS_POPUP or WS_SYSMENU or DS_CENTER,,\
             WS_EX_TOOLWINDOW or WS_EX_APPWINDOW,\
              'Courier New',8

         dialogitem 'STATIC', IDR_DLG_BITMAP,-1,0,0,168,98,\
            WS_VISIBLE or SS_BITMAP or SS_CENTERIMAGE or SS_REALSIZEIMAGE
         dialogitem 'BUTTON', IDR_DOIT, ID_DO_B, 4, 69, 78, 11,\
                SS_CENTERIMAGE or SS_REALSIZEIMAGE or WS_VISIBLE or BS_BITMAP
   enddialog

   icon   main_icon,icon_data,'icon.ico'
   bitmap dlgbitmap,'dlg.bmp'
   bitmap doitbitmap,'doit.bmp'


section '.c' code readable executable

start:
   invoke GetModuleHandle, 0

   invoke DialogBoxParam,eax,301,HWND_DESKTOP,WindowProc,0
   invoke ExitProcess,eax

proc WindowProc, hwnd,msg,wparam,lparam
   push    ebx esi edi

   cmp     [msg],WM_INITDIALOG
   jz      wminit
   cmp     [msg],WM_COMMAND
   jz      wmcommand
   cmp     [msg],WM_CLOSE
   jz      wmclose
   xor     eax, eax
   jmp     finish

wminit:
invoke LoadBitmap, [hwnd], IDR_DOIT
invoke SendDlgItemMessage, [hwnd], ID_DO_B, BM_SETIMAGE, IMAGE_BITMAP, eax
jmp processed

...
...
...
    

Lasterror shows ERROR_RESOURCE_DATA_NOT_FOUND (00000714)
But where is my fault? The resource exists! Isn't it?
Post 04 Mar 2005, 19:53
View user's profile Send private message Reply with quote
drs



Joined: 20 Jan 2005
Posts: 17
Location: Southern California, USA
drs 05 Mar 2005, 15:59
Hi,

I'm not an expert in assembly or anything but I think your problem might be that you are not passing the correct argument into LoadBitmap. It should be the instance to the application not a window.

Save EAX from GetModuleHandle and pass it into LoadBitmap. This way you are passing a handle to an instance and not a handle to a window.

Let me know if that works.

Thanks.

EDIT:

Actually I just reread your source code, it looks like [hwnd] might be eax. Check this in a debugger anyway.
Post 05 Mar 2005, 15:59
View user's profile Send private message ICQ Number Reply with quote
arnix



Joined: 04 Mar 2005
Posts: 4
arnix 05 Mar 2005, 20:07
Yes, I already solved the problem, you are right about instance Smile Here is the right code:

...
...
start:
invoke GetModuleHandle, 0
mov [hInstance],eax
...
...
invoke LoadBitmap, [hInstance], IDR_DOIT
invoke SendDlgItemMessage, [hwnd], ID_DO_B, BM_SETIMAGE, IMAGE_BITMAP, eax

;================

Thank you Smile
Post 05 Mar 2005, 20:07
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.