Menu() Array

Purpose

Array containing window events. Implemented for compatibility with GFA-BASIC 16. Should not be used in GFA-BASIC 32 with OCX controls.

Syntax

Menu(index)

index:iexp

Description

The Menu() array contains window messages from the message queue when used with GetEvent, PeekEvent, or DoEvents. (GFA-BASIC 16 compatible). The GFA-BASIC 32 COM/OCX Sleep command doesn't copy the messages to the Menu() array. Sleep dispatches the messages according COM rules.

About the Menu() array.

The menu bar created with the Menu m$() command contains the pop-up menus with the various menu entries. Such pop-up menus can be invoked in GFA-BASIC even outside of the menu bar by using the Popup command. The Menu() function receives the pop-up menus and windows created with GFA-BASIC commands like OpenW. Menu(m) returns a value indicating which event has occurred. The values are assigned as follows:

Menu(1)=1 Keyboard: NOT IMPLEMENTED in GFA-BASIC 32
Menu(5) - Used to get information about the pressed key - use Screen_Preview instead.
Menu(1)=4 The close box of a window was activated
Menu(1)=5 The minimum size field in a window was activated
Menu(7) - New width
Menu(8) - New height
Menu(9) - SIZEICONC
Menu(1)=6 The maximum size field in a window was activated.
Menu(7) - New width
Menu(8) - New height
Menu(9) - SIZEFULLSCREEN
Menu(1)=7 The arrow up box in a window was activated
Menu(1)=8 The arrow down box in a window was activated
Menu(1)=9 The arrow left box in a window was activated
Menu(1)=10 The arrow right box in a window was activated
Menu(1)=11 The area above the vertical scroll bar was activated; Page up
Menu(1)=12 The area below the vertical scroll bar was activated; Page down
Menu(1)=13 The area to the left of the horizontal scroll bar was activated; Page left
Menu(1)=14 The area to the right of the scroll bar was activated; Page right
Menu(1)=15 The vertical scroll bar was moved
Menu(7) - Position in the range from 0 to 1000
Menu(1)=16 The horizontal scroll bar was moved
Menu(7) - Position in the range from 0 to 1000
Menu(1)=17 he title bar in a window was activated. If the window was moved,
Menu(7) - Returns the new x-position.
Menu(8) - Returns the new y-position of the upper left corner of the window.
Menu(1)=18 The size box of a window was activated. If the size of the window was changed,
Menu(7) - Returns the new width.
Menu(8) - Returns the new height of the window.
Menu(9) - TYPEofSIZE
Menu(1)=20 A menu or a pop-up entry was selected.
Menu(0) returns the index of the menu entry in the entry field or the number of the entry in a pop-up menu.
Menu(1)=21 WM_PAINT. A rectangular segment of a window must be redrawn; Redraw Message
Menu(7) - Returns the left x-coordinate of the window rectangle
Menu(8) - Returns the upper y-coordinate of the window rectangle
Menu(9) - Returns the width of the window rectangle
Menu(10) - Returns the height of the window rectangle
Menu(1)=30 Control message. A message from a Control element was sent.
Menu(5) - Number of the Dialog window
Menu(6) - Number of the item (ItemID)
Menu(13) - The high word of lParam of the message, e.g. LB_SELECTSTRING for a Select box, or BN_CLICK for a button.

The following always applies:

Menu(0) The index number of the menu item selected in the current active window.
Menu(2) Mouse x-position (corresponds to the MOUSESX function)
Menu(3) Mouse y-position (corresponds to the MOUSESY function)
Menu(4) The status of the mouse keys:
Menu(4)=0 - No mouse key was pressed
Menu(4)=1 - The left mouse button was pressed
Menu(4)=2 - The right mouse button was pressed
Menu(7) Returns the number of the GFA-BASIC window above which the mouse was located when the mouse button was pressed.
Menu(11) Mess (message number). Same as _Mess.
Menu(12) wParam. Same as _wParam
Menu(13) lParam. Same as _lParam
Menu(14) GFA-BASIC window handle(0-31). Same as _winId.
Menu(15) Windows window handle. Same as _hWnd.
Menu(16) Time in ms since booting

Example

Global a$, ch%, i%

Data Title &1, Entry &1, Entry &2, &End,

Data Title &2, Entry &1, Entry &2, ...,

Data Title &3, Entry &1, Entry &2, ..., , */

Dim m$(20)

i% = -1

Do

i% ++

Read m$(i%)

Until InStr(m$(i%), "*/")

OpenW # 1, , , , , -1

Menu m$()

Do

DoEvents

EvalMenu() /* MENU(1) = 20

EvalKey() /* MENU(1) = 1

EvalMess() /* MENU(1) = Rest

Loop

 

Procedure EvalMenu()

Local e% = MENU(0)

Local t$ = Trim$(m$(e%))

Local p% = InStr(t$, "&")

If e% = 3

CloseW # 1

End

EndIf

t$ = Left$(t$, p% - 1) + Mid$(t$, p% + 1)

Cls

Text 0, _Y / 2, t$ + " was selected"

EndProc

 

Procedure EvalKey

// Does not work in GFABasic32

Local e%, ee%

e% = Byte(MENU(5))

ee% = Byte(Shr(MENU(5), 8))

WindGet 14, ch%

Cls

Text 0, _Y / 2, "Keyboard input"

Text 0, _Y / 2 + ch%, "ASCII-CODE : " + Str$(e%)

Text 0, _Y / 2 + 2 * ch%, "Scan-CODE : " + Str$(ee%)

EndProc 'Return

 

Procedure EvalMess()

Local e%

e% = MENU(1)

If e%

Cls

Switch e%

Case 4 : CloseW # 1 : End

Case 5 /* Minimizer

Case 6 /* Maximizer

Case 7, 8, 11, 12, 15

a$ = "vert. slider "

Case 9, 10, 13, 14, 16

a$ = "horz. slider "

Case 17

a$ = "Title line "

Case 18

a$ = "Sizer "

Case 21

a$ = "WM_PAINT message "

EndSwitch

If !e% = 21

Text 0, _Y / 2, a$ + "activated"

Else

WindGet 14, ch%

Text 0, _Y / 2 + ch%, a$

EndIf

EndIf

Return

See Also

MenuItem, Menu, GetEvent, PeekEvent, DoEvents

{Created by Sjouke Hamstra; Last updated: 17/10/2014 by James Gaite}