I am trying to get two popup menu's in a window and while the
following program does do that and selects the correct item in
each popup menu, it always comes back in the doDialog function
with the same button ID, i.e., 10, the ID of the _first_ popUp
menu, independent of which popUp was clicked. The resource file
has two menus (ID's 10 and 11) and two CNTL resources (ID's 10 and 11).
Why do I always get 10 for the _btnClick ID? Pop-up menus are new
to me. Any help would be appreciated.
Eric
RESOURCES "popUp.rsrc"
Begin GLOBALS
DIM gProgramEnds% AS INT
END GLOBALS
LOCAL FN newPrefItem$ 'Standard popup function
dim pref&;0,menuID%, itemID%
pref& = fn menuchoice
mHndl&= FN GETMHANDLE(menuID%)
LONG IF mHndl& > 0
CALL GETITEM(mHndl&,itemID%,item$) 'get the name of the current value
END IF
END FN = item$
LOCAL FN popUpMenu(menuResID%) 'Standard popup function
wndH&=WINDOW(_wndPointer)
LONG IF wndH&>0
cntrlH&=FN GETNEWCONTROL(menuResID%,wndH&)
END IF
END FN
LOCAL FN buildWnd
WINDOW #1,"PopUp Menu Demo",(0,0)-(300,100),_docNoGrow
MENU 1,0, _enable, "File"
MENU 1,1, _enable, "/QQuit"
EDIT MENU 2
MENU 10,-2,_enable,"Item List"
FN popUpMenu(10)
menu 11,-2,_enable,"New List"
fn popUpMenu(11)
TEXT _geneva, 11
EDIT FIELD 1,"",(20,70)-(60,84),_statFramed,_centerJust
EDIT FIELD 2,"",(120,70)-(160,84),_statFramed,_centerJust
END FN
local
DIM evnt% as INT
DIM id% as INT
LOCAL FN doDialog
evnt% = DIALOG(0)
id% = DIALOG(evnt)
SELECT evnt%
CASE _btnClick
SELECT id%
CASE 10 'popUp menu 10
item$ = FN newPrefItem$
edit$(1) = item$
CASE 11 'popUp menu 11
edit$(2) = item$
item$ = fn newPrefItem$
END SELECT
CASE _wndClose
gProgramEnds = _true
CASE _wndRefresh
END SELECT
END FN
LOCAL FN doMenu
gProgramEnds = _true
END FN
'------------Main-------------------------
ON DIALOG FN doDialog
on menu fn doMenu
FN buildWnd
DO
HANDLEEVENTS
UNTIL gProgramEnds%