Q: According to Inside Macintosh,
LMGetTheMenu should return the menu ID of the currently
highlighted menu, but the return value is always zero when I call
LMGetTheMenu during the routine whose address I've passed
to LMSetMenuHook . What am I missing?
A: Documentation on LMGetTheMenu is unclear. It is
supposed to return the ID of the menu whose title is currently
highlighted after a call to MenuSelect . However, Menu
Manager does not update this variable while the user is selecting from
a menu; it is updated only after a selection has been made. The bottom
line is that LMGetTheMenu does not work at MenuHook time.
If you need to know when a specific menu is pulled down, you might be
able to use a custom menu definition ('MDEF' ) -- see the
latest Tool Chest Edition of the Developer CD Series for
sample code. Or, you could use LMSetMBarHook , whose
parameter is called only when a menu is about to be drawn. You might
then be able to use the passed rectangle to help you discover which
menu is pulled down. However, neither of these methods is particularly
recommended; it would be better to redesign your program so that it
doesn't need to know these things.
Further Reference:
Inside Macintosh: Menu Manager
[Dec 22 1998]
|