[Pythonmac-SIG] Re: [wxPython-mac] wxPython for OS X - now with menus!
Jack Jansen
jack@oratrix.nl
Wed, 16 Jan 2002 11:36:21 +0100
> So how did I do it? Actually, all I did was remove a few lines from the
> wxWindows/wxMac source code which read in the menubar resource. Here's the
> code I removed:
>
> File: src/mac/menu.cpp
> in Function wxMenuBar::MacInstallMenuBar
>
> Handle menubar = ::GetNewMBar( kwxMacMenuBarResource ) ;
> wxString message ;
> wxCHECK_RET( menubar != NULL, wxT("can't read MBAR resource"));
> ::SetMenuBar( menubar ) ;
> ::DisposeHandle( menubar ) ;
There's a couple of issues with this code. First of all, the Carbon docs warn
that you should *not* call DisposeHandle() on a MenuBar anymore, use
DisposeMenuBar(). Second, you're missing a DrawMenuBar() call after the
SetMenuBar(). Third, I'm not sure that you actually want to dispose the
menubar: the docs do say that SetMenuBar copies the menus, but all code I've
ever seen keeps a reference to the menubar handle nonetheless.
--
- Jack Jansen <Jack.Jansen@oratrix.com> http://www.cwi.nl/~jack -
- If I can't dance I don't want to be part of your revolution -- Emma Goldman -