Share Tips, Code Samples, etc. with the Visual Prolog community.
Chan Bok
Active Member
Posts: 26
Joined: 13 Sep 2000 23:01

(Howto) Add a bitmap to a menu

Unread post 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
Attachments
menu-icon.jpg
menu-icon.jpg (44.51 KiB) Viewed 11908 times
Steve Lympany
VIP Member
Posts: 56
Joined: 31 Mar 2001 23:01

Unread post 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).  
Chan Bok
Active Member
Posts: 26
Joined: 13 Sep 2000 23:01

Unread post 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
Post Reply