How to Prevent the Minimized Icon From Being Overwritten

If your dialog window contains or consists of a canvas, then when you minimize the window, the icon which is being used (IFrameWindow::setIcon()) will be drawn correctly on the screen. However, if you have some controls which are not on a canvas, then you will run into a problem where the minimized icon is being overwritten by some of your controls.

This is a common problem -- I believe with native PM applications as well -- that can very easily be fixed.

In your application, you will need to create a command handler for your window to capture all of the system commands. This can be done by inheriting from ICommandHandler, and declaring the function Boolean systemCommand( ICommandEvent &event );. Then when you detect the ISystemMenu::idMinimize event, you need to hide() the offending controls. Likewise, when you detect the ISystemMenu::idRestore event, you need to show() the controls that have previously been hidden.

For example:

/* this is part pseudo-code and will not compile without modifications */ class myClass : public IFrameWindow, public ICommandHandler { myClass() : // constructor for class... IFrameWindow(...), // ...inherit from IFrameWindow... ICommandHandler() {;}; // ...and from ICommandHandler Boolean systemCommand( ICommandEvent &event ); // inherited from ICommandHandler }; int main() { myClass *frame = new myClass(); // create class frame->setIcon( MY_ICON_RCID ); // set default icon frame->(ICommandHandler)handleEventsFor( frame ); // setup handler ...do some more stuff here... frame->(ICommandHandler)stopHandlingEventsFor( frame ); // stop handler return 0; } myClass::systemCommand( ICommandEvent &event ) { if( event.commandId() == ISystemMenu::idMinimize ) { ...hide controls overwriting the icon by calling their hide() method... } if( event.commandId() == ISystemMenu::idRestore ) { ...show controls overwriting the icon by calling their show() method... } return false; // return as if the event hasn't been handled }
Note:
See also How to Assign an Icon to a Window and Index of Samples on Hobbes

[Home] [Index]
Page generated by Stéphane Charette on 1997 November 02
Open Class Library (OCL) FAQ © Stéphane Charette, 1997