[futurebasic] Re : [FB] Crashing Popups Revisited

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 1999 : Group Archive : Group : All Groups

From: "jonathan" <jonathan@...>
Date: Tue, 26 Jan 1999 20:16:57 +0100
here is the code that I use
(hacked out of a non-crashing app)
locking the menu handle is probably overkill
but... as it works i'm not inclined to change

HTH
jonathan

'/--------------------------------------------------------------------------
CLEAR LOCAL MODE
'   this takes the menuRef, the Pt& where it is to be displayed, and the
'   default item to de chosed at pop up. MenuRef% is used for those 
'   that must be created on the fly
'   It returns the ID of the item chosen.
LOCAL FN doPopUp( rectPtr&, defaultChoice%, menuRef%)
 DIM menuRectPt&; 0, rectTop%, rectLeft%          '  rect of popup menu
 DIM menuResult&; 0, menuID%, itemID%             '   results go to menuID
and itemID
 DIM oldPort&, mHndl&
 DIM err
 '
 '   grab the point info
 menuRectPt&;4 = @rectPtr&.top%
 '   prepare the pop up menu
 CALL INSERTMENU( FN GETMENU( menuRef%), -1)
 '  convert rect to global (screen)
 CALL LOCALTOGLOBAL( menuRectPt&)
 CALL GETPORT( oldPort&)
 mHndl&  = FN GETMHANDLE( menuRef%)
 err = FN HLOCK( mHndl&)
 '  do we need to build the menu?
 SELECT menuRef%
  CASE _mConstPopUp : FN doBuildConstPopUp( mHndl&)
 END SELECT
 '   show the menu
 menuResult& = FN POPUPMENUSELECT( mHndl&, rectTop%, rectLeft%,
defaultChoice%)
 err = FN HUNLOCK( mHndl&)
 CALL DELETEMENU( menuRef%)
 CALL RELEASERESOURCE( mHndl&)
 CALL SETPORT( oldPort&)
 '
 IF( menuResult& <> 0) THEN itemID% = itemID% ELSE itemID% = 0
 '
END FN = itemID%