MENUS
Use the Help menu
No way I know of to get rid of it; it's not "added to compiled FB apps", but added to _everything_; but you can prevent having _two_ "Help" menus (assuming your program has it's own) by adding on to Apple's if it exists;
LONG IF SYSTEM(_sysVers) > 799
REM Put Help in the Help menu
osErr% = FN HMGETHELPMENUHANDLE(mhdl&)
LONG IF osErr% = _noErr
CALL DELETEMENU(5) 'the menu we'd use if this wasn't OS8
FOR ItemID% = 1 TO 5
MenuText$ = STR#(_menuStr,ItemID%)
IF mhdl& <> 0 THEN CALL APPENDMENU(mhdl&,MenuText$)
NEXT ItemID%
SearchHelp$ = STR#(_menuStr,1)
FOR ItemID% = 1 TO 8
CALL GETITEM(mhdl&,ItemID%,MenuText$)
LONG IF MenuText$ = SearchHelp$
iIntro% = ItemID%
ItemID% = 9
END IF
NEXT ItemID%
END IF
helpMenu% = _KHMHelpMenuID
iBasics% = iIntro% + 1
iSetPrefs% = iBasics% + 1
iAboutGames% = iSetPrefs% + 1
iPerfInterp% = iAboutGames% + 1
XELSE
REM Put Help in it's own menu
helpMenu% = 5
iIntro% = 1
iBasics% = 2
iSetPrefs% = 3
iAboutGames% = 4
iPerfInterp% = 5
MENU helpMenu%,_resMenu,_enable
END IF
Bill
No need to check for System 8; just use the OS's help menu, and it will appear in the right place under System 7 or 8.
LOCAL FN insertHelpItem
DIM helpItem$, myErr, mHndl&
helpItem$ = "My application help"
LONG IF SYSTEM(_sysVers) > 699 'System 7 or later? - Put it in the Help menu.
myErr = FN HMGETHELPMENUHANDLE(mHndl&)
LONG IF myErr = _noErr
LONG IF mHndl&
CALL APPENDMENU(mHndl&,helpItem$)
END IF
END IF
XELSE 'System 6 or earlier, put it in the Apple menu
mHndl& = FN GETMHANDLE(_appleResMenu)
LONG IF mHndl&
CALL INSMENUITEM(mHndl&,helpItem$,1)
END IF
END IF
END FN
Greg
Thanks. This shows me how to insert the menu item. Great!
Now, what numbers (menu number and item number) do I look for in the menu events?
Pierre A. Zippi
Don't look for menu number and item number, since you don't know them. (The item could be in the Apple menu or Help menu, and is in a undetermined position on either menu.)
I look for the menu item name. In PG, it's as simple as :
' ============================
"Action : Menu"
' -
LONG IF gItemName$ = "My application help"
FN openHelp
END IF
If you aren't using PG :
itemName$ = FN pGgetItemName$(MENU(_menuID),MENU(_itemID))
LONG IF itemName$ = "My application help"
FN openHelp
END IF
Greg
When you define your menu, add this (where tmp$ is your help statement):
'======================
'------------- attach Balloon Help ---------------
'======================
LOCAL FN attachBalloonHelp(tmp$)
DIM helpMHndl&
DIM osErr
DIM mHndl&
LONG IF SYSTEM (_sysVers) > 699
osErr = FN HMGETHELPMENUHANDLE (helpMHndl&)
LONG IF osErr = _noErr
IF helpMHndl& <> 0 THEN CALL APPENDMENU (helpMHndl&, tmp$)
END IF
XELSE
mHndl& = FN GETMHANDLE (_appleResMenu)
IF mHndl& <> 0 THEN CALL INSMENUITEM (mHndl&, "Help/H", 1)
END IF
CALL DRAWMENUBAR
END FN
---
Then you can get the user's action by using (the constant is important!):
SELECT gWhichMenu
CASE _kHMHelpMenuId 'system 7.0 Balloon Help menu
FN yourHelpWnd 'your help routine
tedd
Excellent Ted but I have a few more questions
My other menus are in resedit so I set up the extra help menus by adding these couple of lines in a setup function, which adds the menu items as you suggested.
tmp$ = "Computer Manager Help"
FN attachBalloonHelp(tmp$)
tmp$ = "About Computer Manager"
FN attachBalloonHelp(tmp$)
Now, how do I make those menus work with my menu handler?
LOCAL FN doMenus
menuID = MENU(_menuID)
itemID = MENU(_itemID)
SELECT menuID
CASE _kHMHelpMenuId 'system 7.0 Balloon Help menu
LONG IF SYSTEM (_sysVers) > 699
'FN yourHelpWnd 'your help routine
BEEP
END IF
CASE 127 'apple menu
LONG IF SYSTEM (_sysVers) < 700
SELECT itemID
CASE 1
'help
FN cmhelp
CASE 2
'about Rush
FN Rush
END SELECT
END IF
tedd
Try this:
LOCAL FN doMenus
menuID = MENU(_menuID)
itemID = MENU(_itemID)
SELECT menuID
CASE _kHMHelpMenuId 'system 7.0 Balloon Help
LONG IF SYSTEM (_sysVers) > 699
' --- insert this code here
osErr%=FN HMGETHELPMENUHANDLE(HelpMHndl&)
LONG IF osErr% = _noErr
CALL GETITEM(HelpMHndl&,itemID,tmp$)
LONG IF tmp$ = "Computer Manager Help"
FN cmhelp
XELSE
IF tmp$ = "About Computer Manager" THEN FN Rush
END IF
END IF
' --- end of inserted code
END IF
CASE 127 'apple menu
LONG IF SYSTEM (_sysVers) < 700
SELECT itemID
CASE 1
'help
FN cmhelp
CASE 2
'about Rush
FN Rush
END SELECT
END IF
Al Staffieri Jr.
You can get the item number using the normal MENU(_itemID) function. The catch is, since you have added items to the _bottom_ of the Help menu, you have to know how many items were above yours before you added your items. Usually (on my machine, anyway) there are 4 items above my app's items (they are "About balloon help...", "Show balloons", plus 2 dividing lines), so the first item I add is usually item #5. To take the guesswork out of this, you should get a count of the existing items _before_ you add any:
OSErr = FN HMGETHELPMENUHANDLE(hmHandle&)
hmItemCount = FN COUNTMITEMS(hmHandle&) 'items above mine
The first item you add will have an item number equal to hmItemCount+1; the next will be hmItemCount+2, and so on.
Rick
|