Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Who releases a MenuRef of a popup menu control?



On 8 May 2006, at 15:49, Norio Ota wrote:

I am about to attach a menu reference created programmatically to a popup control.
Is the menu reference freed when the control is disposed?

yes

Or do I have to release it by myself?

and yes.


MenuRef rMenu = NewMenu(...) // retain count = 1;

SetControlPopupMenuHandle( hControl, rMenu );  // retain count = 2
		
// don't forget these
// SetControlMinimum( hControl, 0 );
// SetControlMaximum( hControl, CountMenuItems( rMenu ) );

ReleaseMenu( rMenu ) // retain count = 1


... ... ... ... // later when window / dialog disposed of

// Either
DisposeWindow( win ); // tears down controls in window
// or
DisposeControl( hControl ) // => Control releases menu, retain count = 0, menu dies.



Hope that helps,

Douglas
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden
References: 
 >Who releases a MenuRef of a popup menu control? (From: Norio Ota <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.