FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

MENUS

Bypass the 25 popup menus limitation


All you need is one popup menu.

For each menu, store the menu items in a separate STR# resource and build the popup menu on the fly before you display it.

I suppose somebody on the FB list or Chris Stazny knows how to detect a click on a popup menu be fore it's displayed.... I don't know how to do this part....

The following is from a PG project of mine and has been altered but not tested. It should give you the idea.

CLEAR LOCAL
LOCAL FN StringListToMenu(myMenu%, myStringList%)
  DIM menuHandle&, menuItemCount%, theItem%, theText$
  DIM myCursor%, itemCount%
  DIM ResErr%, osErr%

  menuHandle& = FN installPop(myMenu%)

  LONG IF menuHandle&
    menuItemCount% = FN COUNTMITEMS(menuHandle&)
    LONG IF menuItemCount%
      FOR theItem% = 1 TO menuItemCount%
        CALL DELMENUITEM(menuHandle&, 1)
      NEXT theItem%
    END IF

    itemCount% = FN countStr(myStringList%)
    LONG IF itemCount%
      FOR theItem% = 1 TO itemCount%
        theText$ = STR#(myStringList%, theItem%)
        CALL INSMENUITEM(menuHandle&, theText$, theItem%)
      NEXT theItem%
    END IF

'if you want to save the menu, otherwise the menu
'reverts to it's previous state before start up
'*********************
    CALL CHANGEDRESOURCE(menuHandle&)
    CALL UPDATERESFILE(gResRef)
'*********************

    FN deletePop(menuHandle&)

  END IF

END FN

Michael Evans