Page 1 of 1

(Howto) Add a bitmap to a menu

Posted: 9 Jun 2006 9:01
by Chan Bok
Here are the code snippets to add a bitmap into the main menu item.
Call this in the taskWindow:

Code: Select all

onInitMenu() = handled(0):-                                             MenuH = gui_native::getMenu(vpi::getTaskWindow()),         Hinst = vpi::getAttrVal(attr_win_instance),             CyCx = gui_native::getMenuCheckMarkDimensions(),                Cx = bit::getLow16of32(CyCx),         Cy = bit::getHigh16of32(CyCx),           LR_COPYFROMRESOURCE=0x4000,         MenuID = (your menu Id),         ResID = (your res Id),         HBmp = gui_native::loadImage(Hinst,uncheckedConvert(string,ResId),              0,Cx,Cy,LR_COPYFROMRESOURCE),         _ = setMenuItemBitmaps(MenuH,MenuID,0,HBmp,HBmp).
You can get very nice looking menus as illustrated below.
You can see more by downloading the Axon Idea Processor from:
http://web.singnet.com.sg/~axon2000/download.htm

Chan Bok
Axon Research

Posted: 28 Nov 2007 11:09
by Steve Lympany
I don't know if this is the proper way, but here is a way to do it for Vip7

Code: Select all

clauses     add_bitmap_to_menu_item(MenuID,ResID):-         MenuH = gui_native::getMenu(vpi::getTaskWindow()),         Picture = vpi::pictLoad(resid(ResId), 15, 15, gui_Native::lr_loadmap3dcolors),         HBMP=vpi::pictToBitmap(Picture),         _ = gui_native::setMenuItemBitmaps(MenuH,MenuID,0,HBmp,HBmp).  

Posted: 29 Nov 2007 0:17
by Chan Bok
Dear Steve,

It is good to know that gui_Native::loadImage can be replaced by
pure prolog predicates (pictLoad and pictToBitmap).

The menu bitmap size is 13x13 using
Control Panel|Display|Appearance|Font Size|Default.
Hence it is better not to hard code it.

Chan Bok
Axon Research