- It leaks the strings you create with CFStringCreateWithCString. For
simple sample code like this, there's no reason to use C-strings to
create CFStrings when you can just define CFStrings directly with
CFSTR. Keep sample code as simple as possible so people don't get
sidetracked by issues that aren't relevant to what you're trying to
- The following is only likely to confuse people:
int basemenuindex = 201;
CreateNewMenu(++basemenuindex, 0, &specialmenuref);
First, basemenuindex is a MenuID, not an index. Second, it's
pointless to assign it a value and then increment it before using it.
This may have had value in your experimentation or your application,
but it's pointless and possibly confusing in sample code. IMO, the
following would be better:
I used MenuID because the declaration of CreateNewMenu uses MenuID.
Being consistent never hurts when dealing with newbies.
FWIW, the occasional uppercase character tends to make variable and
function names easier for some people to read.
Thanks to Larry and Rosya, who quite patiently told me the same
thing over and over until I finally got it :)
Well, you fancy know-everything-because-you're-so-experienced-on-
other-platforms people sometimes take a while to stop acting like you
know everything and start paying attention to what we low level Mac
programmers who have been doing this for years are trying to tell
you. Welcome to the Mac. :-)
On 29/10/2006, at 3:03 AM, Laurence Harris wrote:
On Oct 28, 2006, at 10:21 AM, David Walters wrote:
On 28/10/2006, at 10:22 PM, Rosyna wrote:
Ack, at 10/28/06, David Walters said:
I'm afraid I'm a little slow on the uptake with your answer,
and I tried passing a 0 to every function that required a
menuID - but I couldn't get it to run.
That's because SetMenuItemHierarchicalMenu() doesn't take a menu
id. It takes a MenuItemIndex, you're passing 0, which isn't a
valid index in this case.
Notice the text you quoted from the Menu Manager Reference and
the sample code you pasted. The sample code correctly passes an
index (4). The index is the menu item you want to attach the
ok, how do we know that 4 is correct?
I don't have that code in front of me, but 4 is just the fourth
I don't see the same mechanics you do because I can't find a
reason why 4 is the correct index to pass in the example from apple.
I noticed Larry was using Appendblahblah instead of Insertblahblah,
for ( int i = 0; i < 5; ++i )
InsertMenuItemTextWithCFString( barMenu, mainItems[ i ], 0, 0, 0 );
CreateNewMenu( 0, 0, &subMenu );
InsertMenuItemTextWithCFString( subMenu, subItems[ i ], 0, 0, 0 );
SetMenuItemHierarchicalMenu( barMenu, 1, subMenu );
and I changed the example and now it works - except for the
submenus on "five"... so I can't get Insertblahblah to work.
I can't tell from this exactly what isn't working.
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden