void RheiaEnvironementManager::OnCloseFrame(RheiaFrameEvent& event) { ReleaseMenu( event.GetFrame() , event.GetFrame()->GetMenuBar() ); event.Skip(); }
Boolean MCScreenDC::close(Boolean force) { if (m_dst_profile != nil) { CMCloseProfile(m_dst_profile); m_dst_profile = nil; } if (m_srgb_profile != nil) { CMCloseProfile(m_srgb_profile); m_srgb_profile = nil; } SetApplicationDockTileMenu(NULL); ReleaseMenu(f_icon_menu); DisposeEventHandlerUPP(s_icon_menu_event_handler_upp); f_icon_menu = NULL; s_icon_menu_event_handler_upp = NULL; showmenu(); //if the menu is hidden, show it. finalisebackdrop(); DisposeRgn(mouseMoveRgn); //dispose the region crated in open() uint2 i; if (ncolors != 0) { int2 i; for (i = 0 ; i < ncolors ; i++) { if (colornames[i] != NULL) MCValueRelease(colornames[i]); } delete colors; delete colornames; delete allocs; } DisposeWindow((WindowPtr)invisibleWin); delete vis; delete mousewindow; delete activewindow; delete lastactivewindow; //TSM - closes down TSM for this app and removes appleevents AERemoveEventHandler(kTextServiceClass, kPos2Offset, TSMPositionToOffsetUPP, False); AERemoveEventHandler(kTextServiceClass, kOffset2Pos, TSMOffsetToPositionUPP, False); AERemoveEventHandler(kTextServiceClass, kUpdateActiveInputArea, TSMUpdateHandlerUPP, False); AERemoveEventHandler(kTextServiceClass, kUnicodeNotFromInputMethod, TSMUnicodeNotFromInputUPP, False); DisposeAEEventHandlerUPP(TSMPositionToOffsetUPP); DisposeAEEventHandlerUPP(TSMOffsetToPositionUPP); DisposeAEEventHandlerUPP(TSMUpdateHandlerUPP); DisposeAEEventHandlerUPP(TSMUnicodeNotFromInputUPP); closeIME(); RemoveReceiveHandler(dragdropUPP, NULL); RemoveTrackingHandler(dragmoveUPP, NULL); DisposeDragTrackingHandlerUPP(dragmoveUPP); DisposeDragReceiveHandlerUPP(dragdropUPP); opened = False; return True; }
int main() { IBNibRef nibRef; WindowRef window; OSStatus err; MenuDefSpec defSpec; MenuRef menu; SInt32 gestaltResult; // Create a Nib reference passing the name of the nib file (without the .nib extension) // CreateNibReference only searches into the application bundle. err = CreateNibReference(CFSTR("main"), &nibRef); require_noerr( err, CantGetNibRef ); // Once the nib reference is created, set the menu bar. "MainMenu" is the name of the menu bar // object. This name is set in InterfaceBuilder when the nib is created. err = SetMenuBarFromNib(nibRef, CFSTR("MenuBar")); require_noerr( err, CantSetMenuBar ); // Add a Quit item if we're not running on X Gestalt( gestaltMenuMgrAttr, &gestaltResult ); if ( ( gestaltResult & gestaltMenuMgrAquaLayoutMask ) == 0 ) { MenuRef rootMenu = AcquireRootMenu(); MenuItemIndex item; GetMenuItemHierarchicalMenu( rootMenu, 2, &menu ); AppendMenuItemTextWithCFString( menu, CFSTR("Quit"), 0, kHICommandQuit, &item ); SetMenuItemCommandKey( menu, item, false, 'Q' ); ReleaseMenu( rootMenu ); } defSpec.defType = kMenuDefProcPtr; defSpec.u.defProc = NewMenuDefUPP( SampleMDEF ); // Create a standard menu CreateNewMenu( 200, 0, &menu ); SetMenuTitleWithCFString( menu, CFSTR("Sample") ); InsertMenu( menu, 0 ); AddSampleItems( menu ); // Create a custom menu CreateCustomMenu( &defSpec, 201, 0, &menu ); SetMenuTitleWithCFString( menu, CFSTR("Sample [Custom]") ); InsertMenu( menu, 0 ); AddSampleItems( menu ); // Create a standard menu CreateNewMenu( 202, 0, &menu ); SetMenuTitleWithCFString( menu, CFSTR("Shell") ); InsertMenu( menu, 0 ); AddShellItems( menu ); // Create a custom menu CreateCustomMenu( &defSpec, 203, 0, &menu ); SetMenuTitleWithCFString( menu, CFSTR("Shell [Custom]") ); InsertMenu( menu, 0 ); AddShellItems( menu ); // Create a standard menu CreateNewMenu( 204, 0, &menu ); SetMenuTitleWithCFString( menu, CFSTR("Fonts") ); InsertMenu( menu, 0 ); CreateStandardFontMenu( menu, 0, 0, 0, NULL ); // Create a custom menu CreateCustomMenu( &defSpec, 205, 0, &menu ); SetMenuTitleWithCFString( menu, CFSTR("Fonts [Custom]") ); InsertMenu( menu, 0 ); CreateStandardFontMenu( menu, 0, 0, 0, NULL ); // Then create a window. "MainWindow" is the name of the window object. This name is set in // InterfaceBuilder when the nib is created. err = CreateWindowFromNib(nibRef, CFSTR("MainWindow"), &window); require_noerr( err, CantCreateWindow ); // We don't need the nib reference anymore. DisposeNibReference(nibRef); // The window was created hidden so show it. ShowWindow( window ); // Call the event loop RunApplicationEventLoop(); CantCreateWindow: CantSetMenuBar: CantGetNibRef: return err; }