flat assembler
Message board for the users of flat assembler.

Index > Windows > Handcrafted Menu Problem

Author
Thread Post new topic Reply to topic
nerd_boy



Joined: 07 Oct 2007
Posts: 4
nerd_boy
Confused Trying to make a little menu resource and decided to make one menu similar to Notepad's. Between a few tutorials and google, I managed somewhat decently. However, when I try to compile this, line 107 gives me an error. This is based off of the menu code that sulaiman converted from masm to fasm. *HIS* code compiles without any problem, whereas mine doesn't. After going through at least twenty pages back in the Windows forum and Googling like crazy, I've broken down and decided to seek help.

Again, line 107,which I've marked, is what fasm claims to be the culprit. Any and all help is much appreciated.

Code:
; CodeCoder
;
;       - A program to implement, debug, and otherwise create an environment to test
;         the code editor editor.

format PE GUI 4.0
entry start
include "C:\Documents and Settings\nerd_boy\Desktop\FASM\INCLUDE\win32a.inc"

section '.data' data readable writeable
     ;Windows Creation Specific Stuff Here
     szClass       db      "CodeCoderClass",0
     szTitle    db      "Code Coder Thingy(Completely not ripping off of Code Jotter)",0
     hInstance    dd      ?
     hMainWnd      dd      ?
     msg   MSG
     wc          WNDCLASSEX

section '.code' code readable writeable executable
  start:
    ;get the instance of this program
   invoke GetModuleHandle,0
    mov [hInstance],eax

     ;setup the window
   mov [wc.hInstance],eax
      xor eax,eax
 mov [wc.cbSize],sizeof.WNDCLASSEX
   mov [wc.style],eax
  mov [wc.cbClsExtra],eax
     mov [wc.cbWndExtra],eax
     mov [wc.lpszMenuName],eax
   mov [wc.hIconSm],eax
        mov [wc.hbrBackground],COLOR_BTNFACE+1
      mov [wc.lpszClassName],szClass
      mov [wc.lpfnWndProc],MainWindowProc
 invoke LoadIcon,NULL,IDI_APPLICATION
        mov [wc.hIcon],eax
  invoke LoadCursor,NULL,IDC_ARROW
    mov [wc.hCursor],eax
        invoke RegisterClassEx,wc
   or eax,eax
  jz finish
   invoke LoadMenu,[hInstance],1
       invoke CreateWindowEx,0,szClass,szTitle,WS_VISIBLE+WS_OVERLAPPEDWINDOW,220,220,200,200,HWND_DESKTOP,eax,[hInstance],0
       or eax,eax
  jz finish
   mov [hMainWnd],eax
  invoke ShowWindow,eax,SW_SHOW

  message_loop:
    invoke GetMessage,msg,NULL,0,0
      or eax,eax
  jz finish
   invoke TranslateMessage,msg
 invoke DispatchMessage,msg
  jmp message_loop

  finish:
       invoke ExitProcess,0

proc MainWindowProc hWnd,uMsg,wparam,lparam
     push ebx esi edi
    mov eax,[uMsg]
      cmp eax,WM_DESTROY
  je .wmdestroy
    .defwndproc:
       invoke DefWindowProc,[hWnd],[uMsg],[wparam],[lparam]
        jmp .finish
    .wmdestroy:
  invoke PostQuitMessage,0
    xor eax,eax
    .finish:
     pop edi esi ebx
     ret
endp

include "CodeEditor.asm"

section '.idata' import data readable writable
     library kernel32,'KERNEL32.DLL',\
       user32,'USER32.DLL'

     import   kernel32,\
         GetModuleHandle,        'GetModuleHandleA',\
             ExitProcess,            'ExitProcess'

     import      user32,\
           RegisterClassEx,        'RegisterClassExA',\
             CreateWindowEx,         'CreateWindowExA',\
              DefWindowProc,          'DefWindowProcA',\
               ShowWindow,             'ShowWindowA',\
          LoadCursor,             'LoadCursorA',\
          LoadIcon,               'LoadIconA',\
            LoadMenu,               'LoadMenuA',\
            GetMessage,             'GetMessageA',\
          MessageBox,             'MessageBoxA',\
          TranslateMessage,       'TranslateMessage',\
             DispatchMessage,        'DispatchMessageA',\
             PostQuitMessage,        'PostQuitMessageA'

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

     resource menus,1,LANG_ENGLISH,menuMain

     menu menuMain ;<--- THIS IS LINE 107, THE CULPRIT!
     menuitem 'File',10,MFR_POPUP
               menuitem 'New',11,MFT_STRING
              menuitem 'Open',12,MFT_STRING
             menuitem 'Save',13,MFT_STRING
             menuitem 'Save As',14,MFT_STRING
                  menuseparator
               menuitem 'Exit',15,MFR_END
       menuitem 'Edit',20,MFR_POPUP
               menuitem 'Undo',21,MFT_STRING
             menuseparator
               menuitem 'Copy',22,MFT_STRING
             menuitem 'Cut',23,MFT_STRING
              menuitem 'Paste',24,MFT_STRING
            menuitem 'Delete',25,MFT_STRING
                   menuseparator
               menuitem 'Select All',26,MFR_END
         menuitem 'Format',30,MFR_POPUP
             menuitem 'WordWrap',31,MFT_STRING
                 menuitem 'Font',32,MFT_STRING
             menuitem 'Highlighting',33,MFT_STRING
             menuitem 'AutoComplete',34,MFR_END
       menuitem 'Help',40,MFR_POPUP
               menuitem  'About CodeCoder',41,MFR_END    

_________________
--nerd_boy
Post 07 Oct 2007, 22:44
View user's profile Send private message Visit poster's website Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1608
Location: Ukraine
shoorick
try this:
Code:
          menuitem 'Help',40,MFR_POPUP + MFR_END
                   menuitem  'About CodeCoder',41,MFR_END
    
Post 08 Oct 2007, 04:56
View user's profile Send private message Visit poster's website Reply with quote
nerd_boy



Joined: 07 Oct 2007
Posts: 4
nerd_boy
Ha! It works now! Very Happy Thank you so much, shoorick. You have no idea how crazy this has been driving me.
Post 08 Oct 2007, 05:22
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
I just had hard trouble with hand-crafted menus. Just wanted to let you know:
Code:
;NOT WORKING!!!
  menu FirstMenu
       menuitem '&Test Controls',0,MFR_POPUP
                menuitem "Say Hello",IDM_HELLO
                menuitem "Clear Edit Box",IDM_CLEAR
                menuitem "Get Text", IDM_GETTEXT
                menuseparator
                menuitem "E&xit",IDM_EXIT,MFR_END
    

Even the first menuitem should have MFR_END flag because it is the last of the main menu items!

Everytime you see FASM telling you "undefined symbol 'size?05x'" or something and menuname dd RVA data?05w,size?05x,0,0 then you probably should check where you missed MFR_END flag

The correct one is this:
Code:
  menu FirstMenu
       menuitem '&Test Controls',0,MFR_POPUP+MFR_END
                menuitem "Say Hello",IDM_HELLO
                menuitem "Clear Edit Box",IDM_CLEAR
                menuitem "Get Text", IDM_GETTEXT
                menuseparator
                menuitem "E&xit",IDM_EXIT,MFR_END
    
Post 09 May 2009, 15:19
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger 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.