hi all,

I having a bit of difficulty to insert a submenu from a rc into the mainmenu. I the menu show, but weird result :mad:

here is my rc file:

#include "Resource.h"

#define IDR_MAINMENU 101
#define IDR_LOGMENU 102
#define IDM_NEW 1001
#define IDM_EXIT 1002
#define IDM_CLEAR 1003

IDR_MAINMENU MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "New", IDM_NEW
MENUITEM "Exit", IDM_EXIT
END
END

IDR_LOGMENU MENU DISCARDABLE
BEGIN
POPUP "&Log"
BEGIN
MENUITEM "&Clear", IDM_CLEAR
END
END


here is my source:

.CONST
IDR_MAINMENU equ 101
IDR_LOGMENU equ 102
.......
.DATA
szLogMenuName db "&Log",0
.......
.DATA?
hMainMenu dd ?
hLogMenu dd ?
mii MENUITEMINFO <?>

.CODE
.......
invoke LoadMenu, hInst, IDR_MAINMENU
mov hMainMenu, eax

invoke CreateWindowEx,NULL,\ ;WS_EX_CLIENTEDGE
ADDR szMainClassName,\
ADDR szAppName,\
WS_OVERLAPPED+WS_CAPTION+WS_SYSMENU+WS_MINIMIZEBOX+WS_VISIBLE,\
100,\ ;x
100,\ ;y
550,\ ;cWidth
600,\ ;cheight
NULL,\
hMainMenu,\ ;hMenu can be place here to create the menu
hInst,\
NULL
mov hwnd,eax
..........

invoke LoadMenu, hInst, IDR_MAINMENU
mov hLogMenu, eax

;invoke GetMenuItemInfo, hLogMenu, 0, TRUE, addr mii
mov mii.cbSize, SIZEOF MENUITEMINFO
mov mii.fMask, MIIM_DATA+MIIM_ID+MIIM_STATE+MIIM_SUBMENU+MIIM_TYPE
mov mii.fType, MFT_STRING
mov mii.fState, MFS_ENABLED
mov mii.wID, IDR_LOGMENU
push hLogMenu
pop mii.hSubMenu
mov eax, offset szLogMenuName
mov mii.dwTypeData, eax
mov mii.cch, SIZEOF szLogMenuName
invoke GetMenuItemCount, hMainMenu
invoke InsertMenuItem, hMainMenu, eax, TRUE, addr mii
invoke DrawMenuBar, hWnd


what is wrong with my code???:confused:


thankx in adv,
Posted on 2003-02-24 02:45:42 by Yanda
possibly your code should look like:



invoke LoadMenu, hInst, IDR_LOGMENU ;load logmenu instead of mainmenu !!!!!
mov hLogMenu, eax

;invoke GetMenuItemInfo, hLogMenu, 0, TRUE, addr mii
mov mii.cbSize, SIZEOF MENUITEMINFO
mov mii.fMask, MIIM_DATA+MIIM_ID+MIIM_STATE+MIIM_SUBMENU+MIIM_TYP
E
mov mii.fType, MFT_STRING
mov mii.fState, MFS_ENABLED
mov mii.wID, IDR_LOGMENU ;<-- do you really want to set submenu ID to resource ID?
push hLogMenu
pop mii.hSubMenu
mov eax, offset szLogMenuName
mov mii.dwTypeData, eax
mov mii.cch, SIZEOF szLogMenuName ;<--- not needed for setmenuxxxx
invoke GetMenuItemCount, hMainMenu
invoke InsertMenuItem, hMainMenu, eax, TRUE, addr mii
invoke DrawMenuBar, hWnd

Posted on 2003-02-24 07:53:46 by japheth
thankx,

yea:stupid:

too much coding last night, brain not work out :grin:


:alright:
Posted on 2003-02-24 14:04:57 by Yanda