flat assembler
Message board for the users of flat assembler.

Index > Windows > if more than one menu resource enquiry

Author
Thread Post new topic Reply to topic
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner 29 Oct 2004, 23:03
hi,
i am doing the iczelion tutorial 32 about MDI (Multiple Document Interface) yesterday and face some issue that bugs me a bit time Sad got to use rc in the end Sad

the problem should be the double menu resource generated by fasm, i don't know if i had code it wrong, if yes, please discard this message and show me the right way Smile

below is the fasm code to have a resource of 2 menus

Code:
format PE GUI 4.0
entry start

include '%fasminc%\win32a.inc'

section '.data' data readable writeable
       wndH            dd ?
        insH            dd ?
        wndClsName      db 'GENERIC',0
    wndTitle        db 'GENERIC WINDOW',0

 wndCls  WNDCLASS
    wndMsg  MSG
 
section '.code' code readable executable
start:
        invoke  GetModuleHandle,0
           mov  [insH],eax
             mov  [wndCls.hInstance],eax
         mov  [wndCls.style],CS_HREDRAW or CS_VREDRAW
                mov  [wndCls.lpfnWndProc],window_procedure
          mov  [wndCls.lpszClassName],wndClsName
              mov  [wndCls.lpszMenuName],31
               mov  [wndCls.hbrBackground],COLOR_BTNFACE+1
 invoke  LoadIcon,NULL,IDI_APPLICATION
               mov  [wndCls.hIcon],eax
     invoke  LoadCursor,NULL,IDC_ARROW
           mov  [wndCls.hCursor],eax
   invoke  RegisterClass,wndCls

    invoke  CreateWindowEx,WS_EX_CLIENTEDGE,\
          wndClsName,wndTitle,\
              WS_OVERLAPPEDWINDOW + WS_VISIBLE,\
         CW_USEDEFAULT,CW_USEDEFAULT,\
              400,240,\
          NULL,NULL,[insH],NULL
               mov  [wndH],eax

   ;+---------------------------+
   ;| entering the message loop |
   ;+---------------------------+
   window_message_loop_start:
     invoke  GetMessage,wndMsg,NULL,0,0
          or    eax,eax
               je    window_message_loop_end
       invoke  TranslateMessage,wndMsg
     invoke  DispatchMessage,wndMsg
              jmp     window_message_loop_start

   window_message_loop_end:
    invoke  ExitProcess,0

   ;+----------------------+
   ;| the window procedure |
   ;+----------------------+
   proc window_procedure,hWnd,uMsg,wParam,lParam
               push ebX Esi edi
            cmp  [uMsg],WM_DESTROY
              je   wmDESTROY
      

        wmDEFAULT:
              invoke  DefWindowProc,[hWnd],[uMsg],[wParam],[lParam]
                       jmp  wmBYE

      wmDESTROY:
              invoke  PostQuitMessage,0

       wmBYE:
          pop edi esi ebx
             return
   endp

section '.idata' import data readable
    library KERNEL32, 'KERNEL32.DLL',\
               USER32,   'USER32.DLL'
    
    import  KERNEL32,\
         GetModuleHandle,        'GetModuleHandleA',\
             ExitProcess,            'ExitProcess'
    import   USER32,\
           RegisterClass,          'RegisterClassA',\
               CreateWindowEx,         'CreateWindowExA',\
              DefWindowProc,          'DefWindowProcA',\
               LoadCursor,             'LoadCursorA',\
          LoadIcon,               'LoadIconA',\
            SendMessage,            'SendMessageA',\
         GetMessage,             'GetMessageA',\
          MessageBox,             'MessageBoxA',\
          DestroyWindow,          'DestroyWindow',\
                TranslateMessage,       'TranslateMessage',\
             DispatchMessage,        'DispatchMessageA',\
             PostQuitMessage,        'PostQuitMessage'

section '.rsrc' resource data readable
 directory RT_MENU,appMenuA,\
                 RT_MENU,appMenuB

      resource  appMenuA,30,LANG_ENGLISH,menuMainA
        resource  appMenuB,31,LANG_ENGLISH,menuMainB

    menu menuMainA
              menuitem '&File',0,MFR_POPUP
          menuitem        '&New',1000,0
                         menuseparator
               menuitem        '&Exit',1001,MFR_END
          menuitem '&Window',0,MFR_POPUP + MFR_END
              menuitem        'Tile Horizontal',1002,0
          menuitem        'Tile Vertical',1003,0
            menuitem        'Cascade',1004,MFR_END


    menu menuMainB
              menuitem '&File - Child',0,MFR_POPUP
          menuitem        '&New',1000,0
         menuitem        '&Close',1005,0
                               menuseparator
               menuitem        '&Exit',1001,MFR_END
          menuitem '&Window - Child',0,MFR_POPUP + MFR_END
              menuitem        'Tile Horizontal',1002,0
          menuitem        'Tile Vertical',1003,0
            menuitem        'Cascade',1004,MFR_END
    



if we assemble the above code, no errors would be found, and if we use the RES HACKER to view the resulted executable, we would be able to see two menus, but the problem is, the menu 31 is unusable (like the above example)!


ps: i got a feeling that i have code it wrong, so, anyone willing to show me the correct way Smile
Post 29 Oct 2004, 23:03
View user's profile Send private message Visit poster's website Reply with quote
Nikolay Petrov



Joined: 22 Apr 2004
Posts: 101
Location: Bulgaria
Nikolay Petrov 30 Oct 2004, 22:04
The demo is fast assemble - small part my program and iczelion MDI demo
I am tested one time - work perfect.


Description:
Download
Filename: MDI.rar
Filesize: 4.59 KB
Downloaded: 340 Time(s)

Post 30 Oct 2004, 22:04
View user's profile Send private message Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner 31 Oct 2004, 05:14
yup, thanks nickolay, and sorry for the little trouble

Code:
        directory RT_MENU,appMenuA 

        resource  appMenuA,\
             30,LANG_ENGLISH,menuMainA,\
                31,LANG_ENGLISH,menuMainB 
    


is the correct way to declare multiple same resource
i guess i face it last time and somebody point me, but forgot already after some time :p
Post 31 Oct 2004, 05:14
View user's profile Send private message Visit poster's website 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.