[futurebasic] Re: Pop Up Resource

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 1998 : Group Archive : Group : All Groups

From: MAWRPh <MAWRPh@...>
Date: Wed, 27 May 1998 02:14:21 EDT
In a message dated 5/26/98 7:17:43 AM, rush@... wrote:

>Is there any way to create the popup list for a popup menu dynamically
>from an array?

It depends on how you want to create it. Will it be different each time? Will
you just be adding items to the end or inserting new items? Here is how I have
done it with STR# resources, clearing out the old menu and creating a new one
from scratch. It should get you started.

Need to have an empty popup menu in your resource file
'=========================================
LOCAL FN popUpDelete
'------------------------------
'clear the pop-up menu and the string resource
'-------------------------------
  DIM menuH&, elcount%, count%, resHndl&

  menuH& = FN installPop(_popMenu)      'from PG POP!.FLTR
  elcount%  = FN COUNTMITEMS (menuH&)
  count% = elcount%
  DO
    LONG IF elcount%<> 0
      CALL DELMENUITEM ( menuH&, count%)
    END IF
    DEC (count%)
  UNTIL count% = 0
  FN deletePop (menuH&)             'from PG POP!.FLTR
  
  resHndl& = FN NEWHANDLE _clear(2)
  FN pGreplaceRes(resHndl&, _"STR#", _popMenuSTR, "") 'From PG
END FN

'=========================================

LOCAL FN popUpBuild
'------------------------------
'build the pop-up menu from the string resource
'-------------------------------
  DIM menuH&, elcount%, count%, mTitle$
  
  menuH& = FN installPop(_popMenu)      'from PG POP!.FLTR
  elcount% = FN countStr(_popMenuSTR)    'from PG
  LONG IF elcount%<> 0
    FOR count% = 1 TO  elcount%
      mTitle$ = STR#(_popMenuSTR, count%)
      LONG IF mTitle$ <>""                'check for empty STR# item
        CALL APPENDMENU ( menuH&, mTitle$)
      END IF
    NEXT
  END IF
  FN deletePop (menuH&)             'from PG POP!.FLTR
END FN

'=========================================

Not sure if this will work for you, I use it at shutdown (to clear the menu
and STR#) and at start-up to build a pop-up that doesn't change (usually)
while the app is running.

HTH

Mark