BBjMDI::addMenuButton

Description

In BBj 8.00 and higher, this method adds a menu button control to the BBjMDI window.

Syntax

Return Value

Method

BBjMenuButton

addMenuButton(int ID, int x, int y, int width, int height, string title)

BBjMenuButton

addMenuButton(int ID, int x, int y, int width, int height, string title, string flags)

Parameters

Variable

Description

ID

Control ID number. It must be an integer between 1 and 32767 and be unique within a given top-level window.

x

Ignored.

y

Ignored.

width

Width of the control in current units.

height

Height of the control in current units.

title

Tool button title. The title can be ordinary text or "BITMAP=", followed by a path name. (PREFIX is not searched.) If the BITMAP= syntax is used, an attempt is made to locate and load a bitmapped image (see the IMAGE Mnemonic - Draw Bitmapped Image (SYSGUI)) from that file. If it succeeds, the image is drawn in the button. Otherwise the text, complete with "BITMAP=", is displayed. The title or bitmap can be changed at any time with the 'TITLE' mnemonic. Including the '&' before a character in the title causes it to be an accelerator.

flags

Control flags, as follows:

Flag

Description

$0001$

Sets the control to be initially disabled.

$0010$

Sets the control to be initially invisible.

$0800$

Draws a recessed client edge around the control.

$1000$

Draws a raised edge around the control.

$2000$

Paints the button in a style similar to Office 2003.

$4000$

Always paint the border around the control.

Return Value

Returns the created BBjMenuButton object.

Remarks

None.

Example

rem ' addMenuButton

open (unt)"X0"
sysgui! = BBjAPI().getSysGui()
mdi! = BBjAPI().getMDI()
mdi!.createMDIWindow(100,100,250,200,"MDI Window")

rem ' Create Menu Buttons
mb1! = mdi!.addMenuButton(101,0,0,80,30,"Open")
mb2! = mdi!.addMenuButton(102,0,0,80,30,"Save")
mb3! = mdi!.addMenuButton(103,0,0,80,30,"Print")
mb1!.setCallback(mb1!.ON_BUTTON_PUSH,"mb1")
mb2!.setCallback(mb1!.ON_BUTTON_PUSH,"mb2")
mb3!.setCallback(mb1!.ON_BUTTON_PUSH,"mb3")

rem ' Create dropdown menu(s)
dropdownMenu! = sysgui!.addPopupMenu()
dropdownItem1! = dropdownMenu!.addMenuItem(-201,"Dropdown Item 1")
dropdownItem2! = dropdownMenu!.addMenuItem(-202,"Dropdown Item 2")

rem 'Associate dropdown menu(s) with the buttons
mb1!.setDropdownMenu(dropdownMenu!)
mb2!.setDropdownMenu(dropdownMenu!)
mb3!.setDropdownMenu(dropdownMenu!)

rem ' Add Images
ImageManager! = sysgui!.getImageManager()
openImage! = ImageManager!.loadImageFromFile("open.png",err=*next)
mb1!.setImage(openImage!)
saveImage! = ImageManager!.loadImageFromFile("save.png",err=*next)
mb2!.setImage(saveImage!)
printImage! = ImageManager!.loadImageFromFile("print.png",err=*next)
mb3!.setImage(printImage!)
CALLBACK(ON_POPUP_ITEM_SELECT,DropdownItem1,dropdownMenu!.getID(),dropdownItem1!.getID())
CALLBACK(ON_POPUP_ITEM_SELECT,DropdownItem2,dropdownMenu!.getID(),dropdownItem2!.getID())
CALLBACK(ON_CLOSE,APP_CLOSE,mdi!.MDI_CONTEXT)
process_events

APP_CLOSE:
    mdi!.closeAll(0)
release

mb1:
    print "1"
return

mb2:
    print "2"
return

mb3:
    print "3"
return

DropdownItem1:
    i = msgbox("Dropdown Item 1")
return

DropdownItem2:
    i = msgbox("Dropdown Item 2")
return

See Also

BBjAPI

BBjMDI

Object Variables

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.