flat assembler
Message board for the users of flat assembler.

Index > Main > A problem with menu =(

Author
Thread Post new topic Reply to topic
Necromancer13



Joined: 18 Oct 2007
Posts: 32
Location: Ukraine
Necromancer13
I'd like to make menu without LoadMenu function, but with
mov wc.lpszMenuName.......

I've removed LoadMenu froam a source and added mov [wCls.lpszMenuName],30 there...

But it doesn't work...Sad


Code:
format PE GUI 4.0
entry start

include '%fasminc%\win32a.inc'

section '.data' data readable writeable
     wHMain         dd   ?
     wHInstance     dd   ?

     wTitle         db   'Tutorial 8',0
     wClsName       db   'TUT08',0

     wMsg      MSG
     wCls      WNDCLASS

     expBoxTitle    db   'Menu Action Description',0
     expBoxDesc11   db   'MenuBar A -> MenuItem A',0
     expBoxDesc12   db   'MenuBar A -> MenuItem B',0
     expBoxDesc13   db   'MenuBar A -> MenuItem C',0
     expBoxDesc21   db   'MenuBar B -> MenuItem A',0
     expBoxDesc30   db   'MenuBar C (Without Item)',0

section '.code' code readable executable
     start:
          ; +------------------------------+
          ; | registering the window class |
          ; +------------------------------+
          invoke    GetModuleHandle,NULL
                    mov  [wHInstance],eax
                    mov  [wCls.hInstance],eax
                    mov  [wCls.style],CS_HREDRAW or CS_VREDRAW
                    mov  [wCls.lpfnWndProc],window_procedure
                    mov  [wCls.lpszClassName],wClsName
                    mov  [wCls.hbrBackground],COLOR_WINDOW+1
                    mov  [wCls.lpszMenuName],30
          invoke    LoadIcon,NULL,IDI_APPLICATION
                    mov  [wCls.hIcon],eax
          invoke    LoadCursor,NULL,IDC_ARROW
                    mov  [wCls.hCursor],eax
          invoke    RegisterClass,wCls
          ; +--------------------------+
          ; | creating the main window |
          ; +--------------------------+
          invoke    CreateWindowEx,\
                         0,\
                         wClsName,\
                         wTitle,\
                         WS_OVERLAPPEDWINDOW,\
                         CW_USEDEFAULT,\
                         CW_USEDEFAULT,\
                         CW_USEDEFAULT,\
                         CW_USEDEFAULT,\
                         NULL,\
                         eax,\
                         [wHInstance],\
                         NULL
                    mov  [wHMain],eax
          invoke    ShowWindow,[wHMain],SW_SHOW
          ; +---------------------------+
          ; | entering the message loop |
          ; +---------------------------+
          window_message_loop_start:
               invoke    GetMessage,wMsg,NULL,0,0
                         or   eax,eax
                         je   window_message_loop_end
               invoke    TranslateMessage,wMsg
               invoke    DispatchMessage,wMsg
                         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    ;eventhough the API would preserved, but play safe :p
               cmp  [uMsg],WM_COMMAND
               je   wmCOMMAND
               cmp  [uMsg],WM_DESTROY
               je   wmDESTROY

               wmDEFAULT:
                    invoke    DefWindowProc,[hWnd],[uMsg],[wParam],[lParam]
                              jmp  wmBYE
               wmCOMMAND:
                              mov  eax,[wParam]
                              cmp  ax,11
                              je   wmCOMMAND_11
                              cmp  ax,12
                              je   wmCOMMAND_12
                              cmp  ax,13
                              je   wmCOMMAND_13
                              cmp  ax,21
                              je   wmCOMMAND_21
                              cmp  ax,30
                              je   wmCOMMAND_30
                              jmp  wmDEFAULT

                    wmCOMMAND_11:
                              invoke    MessageBox,[hWnd],expBoxDesc11,expBoxTitle,MB_OK
                              jmp  wmBYE
                    wmCOMMAND_12:
                              invoke    MessageBox,[hWnd],expBoxDesc12,expBoxTitle,MB_OK
                              jmp  wmBYE
                    wmCOMMAND_13:
                              invoke    MessageBox,[hWnd],expBoxDesc13,expBoxTitle,MB_OK
                              jmp  wmBYE
                    wmCOMMAND_21:
                              invoke    MessageBox,[hWnd],expBoxDesc21,expBoxTitle,MB_OK
                              jmp  wmBYE
                    wmCOMMAND_30:
                              invoke    MessageBox,[hWnd],expBoxDesc30,expBoxTitle,MB_OK
                              jmp  wmBYE
               wmDESTROY:
                    invoke    PostQuitMessage,0

               wmBYE:
                    pop  edi esi ebx
                    ret
          endp

section '.idata' import data readable writeable
     library   KERNEL32, 'KERNEL32.DLL',\
               USER32,   'USER32.DLL'

     import    KERNEL32,\
               GetModuleHandle,    'GetModuleHandleA',\
               ExitProcess,        'ExitProcess'

     import    USER32,\
               RegisterClass,      'RegisterClassA',\
               CreateWindowEx,     'CreateWindowExA',\
               DefWindowProc,      'DefWindowProcA',\
               ShowWindow,         'ShowWindow',\
               LoadCursor,         'LoadCursorA',\
               LoadIcon,           'LoadIconA',\
               LoadMenu,           'LoadMenuA',\
               GetMessage,         'GetMessageA',\
               MessageBox,         'MessageBoxA',\
               TranslateMessage,   'TranslateMessage',\
               DispatchMessage,    'DispatchMessageA',\
               PostQuitMessage,    'PostQuitMessage'

section '.rsrc' resource data readable
     directory RT_MENU,appMenu

     resource  appMenu,\
               30,LANG_ENGLISH,menuMain

     menu menuMain
          menuitem  'MenuBar A',10,MFR_POPUP
          menuitem       'MenuBar A -> MenuItem A',11,MFT_STRING
          menuitem       'MenuBar A -> MenuItem B',12,MFT_STRING
                         menuseparator
          menuitem       'MenuBar A -> MenuItem C',13,MFR_END
          menuitem  'MenuBar B',20,MFR_POPUP
          menuitem       'MenuBar B -> MenuItem A',21,MFR_END
          menuitem  'MenuBar C (Without Item)',30,MFR_END

    


Please, help... How can I do it? Sad

_________________
FASM Rulezzzzzz!
Post 19 Oct 2007, 02:45
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 713
Location: Adelaide
sinsi
Code:
          invoke    CreateWindowEx,\ 
                         0,\ 
                         wClsName,\ 
                         wTitle,\ 
                         WS_OVERLAPPEDWINDOW,\ 
                         CW_USEDEFAULT,\ 
                         CW_USEDEFAULT,\ 
                         CW_USEDEFAULT,\ 
                         CW_USEDEFAULT,\ 
                         NULL,\ 
                         eax,\                            <<<<<<<<<!!!!!!!!!!!
                         [wHInstance],\ 
                         NULL 
                    mov  [wHMain],eax 
          invoke    ShowWindow,[wHMain],SW_SHOW 
    

Instead of EAX, use NULL (to use the class menu)
Post 19 Oct 2007, 03:55
View user's profile Send private message Reply with quote
Necromancer13



Joined: 18 Oct 2007
Posts: 32
Location: Ukraine
Necromancer13
Thank you! yes, it works now:)
Post 19 Oct 2007, 04:00
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
Chapman7



Joined: 27 Oct 2007
Posts: 1
Chapman7
With using this menu code, how do I get it so instead of the color being white, its the normal window color?
Post 27 Oct 2007, 18:36
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.