External Function
===============================================================================
FUNCTION ulong LoadImageA(ulong hintance, string filename,uint utype,int x,int y,uint fload)  LIBRARY "USER32.DLL"
FUNCTION boolean SetMenuItemBitmaps(ulong hmenu,uint upos,uint flags,ulong handle_bm1,ulong handle_bm2)  LIBRARY "USER32.DLL"
FUNCTION int GetSystemMetrics(  int nIndex ) LIBRARY "USER32.DLL"
FUNCTION ulong GetMenuItemID(ulong hMenu,uint uItem) LIBRARY "USER32.DLL"
FUNCTION int GetSubMenu(ulong hMenu,int pos) LIBRARY "USER32.DLL"
FUNCTION ulong GetMenu(ulong hWindow) LIBRARY "USER32.DLL"
FUNCTION boolean ModifyMenu(ulong  hMnu, ulong uPosition, ulong uFlags, ulong uIDNewItem, long lpNewI) alias for ModifyMenuA LIBRARY "USER32.DLL"
function boolean SetMenuDefaultItem(ulong hMenu,ulong uItem, ulong fByPos ) LIBRARY "USER32.DLL"
===============================================================================

Long           ll_MainHandle
long            ll_SubMenuHandle
integer         li_MenuItemID
long            ll_X
long            ll_Y
long            ll_BitmapHandleA
long            ll_BitmapHandleB

// Win32 contants
Integer IMAGE_BITMAP    = 0
Integer LR_LOADFROMFILE = 16
Integer SM_CXMENUCHECK  = 71
Integer SM_CYMENUCHECK  = 72
Integer MF_BITMAP       = 4
Integer MF_BYCOMMAND    = 0
Integer MF_BYPOSITION   = 1024

// Get a handle to the menu
ll_MainHandle = GetMenu(Handle(this))

// Get a handle the the first menu item
ll_SubMenuHandle = GetSubMenu(ll_MainHandle,0)

// Load the images in their original sizes
ll_BitmapHandleA = LoadImageA(0,'ok.bmp',0,0,0,LR_LOADFROMFILE)
ll_BitmapHandleB = LoadImageA(0,'stop.bmp',0,0,0,LR_LOADFROMFILE)

// get the menu id of the first submenu item
li_MenuItemID = GetMenuItemID(ll_SubMenuHandle,0)
ModifyMenu(ll_SubMenuHandle,li_MenuItemID,MF_BITMAP,li_MenuItemId,ll_BitmapHandleA)

// get the menu id of the first submenu item
li_MenuItemID = GetMenuItemID(ll_SubMenuHandle,1)
ModifyMenu(ll_SubMenuHandle,li_MenuItemID,MF_BITMAP,li_MenuItemId,ll_BitmapHandleB)

// Get a handle the third submenu menu item
ll_SubMenuHandle = GetSubMenu(ll_SubMenuHandle,2)

// get the menu id of the first submenu item
li_MenuItemID = GetMenuItemID(ll_SubMenuHandle,0)
ModifyMenu(ll_SubMenuHandle,li_MenuItemID,MF_BITMAP,li_MenuItemId,ll_BitmapHandleA)

li_MenuItemID = GetMenuItemID(ll_SubMenuHandle,1)
ModifyMenu(ll_SubMenuHandle,li_MenuItemID,MF_BITMAP,li_MenuItemId,ll_BitmapHandleB)


// back to the top


//Now get the handle of the second submenu..
ll_SubMenuHandle = GetSubMenu(ll_MainHandle,1)

// Get sizes for the pictures, use winapi for the bitmaps sizes
ll_x = GetSystemMetrics(SM_CXMENUCHECK)
ll_y = GetSystemMetrics(SM_CYMENUCHECK)

// Load the images using the dimensions for the checked state
ll_BitmapHandleA = LoadImageA(0,'ok.bmp',  IMAGE_BITMAP ,ll_x,ll_y,LR_LOADFROMFILE)
ll_BitmapHandleB = LoadImageA(0,'stop.bmp',IMAGE_BITMAP ,ll_x,ll_y,LR_LOADFROMFILE)

SetMenuItemBitmaps(ll_SubMenuHandle,0,MF_BYPOSITION,ll_BitmapHandleA,ll_BitmapHandleB)
SetMenuItemBitmaps(ll_SubMenuHandle,1,MF_BYPOSITION,ll_BitmapHandleB,ll_BitmapHandleA)

// Get a handle the third submenu menu item
ll_SubMenuHandle = GetSubMenu(ll_SubMenuHandle,2)

SetMenuItemBitmaps(ll_SubMenuHandle,0,MF_BYPOSITION,ll_BitmapHandleA,ll_BitmapHandleB)
SetMenuItemBitmaps(ll_SubMenuHandle,1,MF_BYPOSITION,ll_BitmapHandleB,ll_BitmapHandleA)



// set default menu item for second menuitem of the third submenu

// Get a handle the the third menu item
ll_SubMenuHandle = GetSubMenu(ll_MainHandle,2)

// set the default for the second item
SetMenuDefaultItem(ll_SubMenuHandle,1,MF_BYPOSITION)
Posted by 민서정
l