I'm having a problem getting the 'delete' glyph to show in a menu (it's to
be activated with Command-Delete, obviously). I'm using this code:
Dim iMenu, oserr As Integer
#if targetcarbon then
Declare Function SetMenuItemKeyGlyph Lib "CarbonLib" (inMenu as Integer,
inItem as Integer, inGlyph as Integer) as Integer
Declare Function GetMenuHandle Lib "CarbonLib" ( menuID as Integer ) as
Integer
#else
Declare Function SetMenuItemKeyGlyph Lib "AppearanceLib" (inMenu as
Integer, inItem as Integer, inGlyph as Integer) as Integer
Declare Function GetMenuHandle Lib "InterfaceLib" ( menuID as Integer ) as
Integer
#endif
iMenu = GetMenuHandle(2)
If iMenu <> 0 then
oserr = SetMenuItemKeyGlyph (iMenu,3,23)
end if
The menu in question is the File menu, and the menuitem is the third in that
menu. The above code works in OS X, but not when I try running it in the IDE
in RB Classic. Sometimes (and I can't figure out the circumstances at all),
it *will* work in RB Classic.
Something else odd is that, in OS X, if the main window for my project is
open when I run it in the IDE, this code does not work, but changing the
menu id to 3 *does* work. It doesn't matter if that window is frontmost in
RB; it just needs to be open. Why would that affect it? (It works in the
built app, in OS X at any rate.)
Maybe I'm using the wrong numbers? The Declares themselves don't seem to be
generating errors that I can tell; I've tried including a Beep if oserr is >
zero, and I never hear any beeps, but I still don't get the glyph in
Classic.
George
--
George Clark - gaclark at sprynet dot com
|