[futurebasic] Re: [FB] Standard Font menu and Carbon

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 2002 : Group Archive : Group : All Groups

From: Robert Purves <robert.purves@...>
Date: Sat, 2 Nov 2002 23:41:26 +1300
On Saturday, November 2, 2002, at 10:54  PM, Alain Pastor wrote:

> Has anyone succeeded in using the Carbon Toolbox function 
> CreateStandardFontMenu with _kHierarchicalFontMenuOption?
>
> This should give a Font menu with items sorted by name with a 
> hierarchical menu attached if necessary. Or so I believe.
>
> In addition, I would like to attach this ordered Font menu as a 
> hierarchical item of another menu (I don't know yet if it's doable).
>
> The code below crashes when _kHierarchicalFontMenuOption is set, 
> otherwise it seems to work:


This slightly simplified version of your code works in both Classic and 
OS X 10.2.1.  No crash.


_kHierarchicalFontMenuOption = 1

toolbox fn CreateStandardFontMenu( MenuRef menu,¬
   MenuItemIndex afterItem, Sint16 firstHierMenuID,¬
   UInt32 options, UInt32 * outHierMenuCount) = OSStatus

dim   menuFont  as MenuRef
dim @ itemcount as UInt32

menuFont = fn NewMenu( 2, "Police" )
long if menuFont
long if fn CreateStandardFontMenu( menuFont, 0, 200,¬
  _kHierarchicalFontMenuOption, itemcount ) == _noErr
InsertMenu( menuFont, 0 )
end if
end if

window 1
do
handleevents
until _nil
// kill resources "plst", 0



Robert P.