vbVeryBeginner
Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
|
hi,
i am doing the iczelion tutorial 32 about MDI (Multiple Document Interface) yesterday and face some issue that bugs me a bit time got to use rc in the end
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
below is the fasm code to have a resource of 2 menus
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
|