🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.mac.oop.powerplant
2 messages
2 total messages Started by jgagnon Fri, 01 Mar 2002 15:48
KHICommandZoomWindow and PowerPlant
#26
Author: jgagnon
Date: Fri, 01 Mar 2002 15:48
11 lines
1648 bytes
Hi,

I have an Lapplication and I added the standard OS X Window Menu.

The problem is that PowerPlant don't handle correctly the Zoom command in
the window menu.  I think I must handle the command kHICommandZoomWindow,
but i don't know how?  Do you have hints about this problem?

Thanks!

J. Gagnon :-) 
Re: KHICommandZoomWindow and PowerPlant
#27
Author: David Dunham
Date: Fri, 01 Mar 2002 23:47
68 lines
3384 bytes
In article <B8A50CE7.CA6%jgagnon@nospam.com>, jgagnon
<jgagnon@nospam.com> wrote:

> I have an Lapplication and I added the standard OS X Window Menu.
> 
> The problem is that PowerPlant don't handle correctly the Zoom command in
> the window menu.  I think I must handle the command kHICommandZoomWindow,
> but i don't know how?  Do you have hints about this problem?

You can register for the Carbon Event without switching the entire
application to Carbon Events:

    // Since we're using a Carbon style command for Help, install a
Carbon Event handler for it
    EventHandlerUPP upp = ::NewEventHandlerUPP(EventProc);
    EventTypeSpec   events[] = { kEventClassCommand,
kEventCommandProcess,
                                 kEventClassCommand,
kEventCommandUpdateStatus };
    ThrowIfOSStatus_(InstallApplicationEventHandler(upp, 2, events,
this, nil));

...

OSStatus    ClayApp::HandleCarbonEvent(
    EventHandlerCallRef inHandlerCallRef,
    EventRef            inEvent)
{
    UInt32              eClass = ::GetEventClass(inEvent);
    UInt32              kind = ::GetEventKind(inEvent);

    OSStatus            s;

    HICommand           hiCmd;
    UInt32              actualSize;
    s = ::GetEventParameter(inEvent, kEventParamDirectObject,
typeHICommand, nil,
        sizeof(hiCmd), &actualSize, &hiCmd);
    if (hiCmd.commandID == cmd_Help) {
        if (kind == kEventCommandProcess) {
            this->DoHelp();
        } else {            // kEventCommandUpdateStatus
            if (UDesktop::FrontWindowIsModal()) {
                // A modal window is in front, so don't allow the Help
window
                ::DisableMenuCommand(nil, cmd_Help);
            } else {
                ::EnableMenuCommand(nil, cmd_Help);
            }
        }
        return noErr;
    }

    s = ::CallNextEventHandler(inHandlerCallRef, inEvent);

    return s;
} // HandleCarbonEvent

(though I think the zooming would be a window handler)

BTW, my app zooms just fine when I use that menu item. Or do you mean
that you don't get the chance to intercept it?

-- 
David Dunham    A Sharp    david@SPAM_B_GONE.a-sharp.com
http://www.pensee.com/dunham/
    "I say we should listen to the customers and give them what they want."
    "What they want is better products for free." --Scott Adams
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads