Link to home
Start Free TrialLog in
Avatar of sks
sks

asked on

Minimize Event

This is for MFC - Visual c++ 5.0!   Whenever the user clicks on the minimize button on my dialog box,
I do not want it to minimize, however, I would like for it to do something else.  I have overwritten a member
function of CWnd called "OnSize", however, that doesn't stop the program from minimizing when the
user clicks on the minimize button.
ASKER CERTIFIED SOLUTION
Avatar of nietod
nietod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nietod
nietod

Well, some more details anyways.  The problem was that OnSize is called AFTER the window has been sized.  To late.  You could have handled it at OnWindowPosChanging, but I think you will find OnSysCommand() easier.  it will not trap a minimize caused by an API command, like SetWindowPos() however,  But I suspect that is not a problem.  If it is a problem, let me know.
Avatar of sks

ASKER

Well, I am going to try the OnSysCommand() in a minute.  
I have two questions relating to your answer.
1.  First of all, my class which is called "Cinput" is derived from CDialog .  The
    OnSysCommand() is a member function of CWnd.  Whenever I try to add
    OnSysCommand() as a Windows Msg Handler in the ClassWizard, it's not
    there.  How can I accomplish this?
2.  What do you mean by saying that it won't trap a minimize caused by an API
    command?
1.  I'm not sure.  I don't use the class wizard.   CDialig is derived from CWnd so OnSysCommand() is available.   You must be doing something wrong, but I don't know what.
2.   If you wrote code that minimized the window using SetWindowPos() or a similar window movement function, the code you place in OnSysCommand() will not be called and will not "trap" the minimize.  The code will only "trap" minimize requests caused by pressing the minimize button or menu option.  That probably is not a problem for you, but I wanted to warn you.  For example if some hacker writes a utuility program that can be used to minimize other windows. it might minimize the window directly and your code would not be called.

In the future you should not accept an answer to a question until you are sure it really works for you.  Hopefully you can get your problem with the wizard resolved without help from me.  (I'm willing to try, but there's not much I can do.)  If you hadn't accepted the answer you could have rejected it to ask someone else how to do this.  
Avatar of sks

ASKER

I don't understand completely how I can make it NOT minimize when the user clicks
on MINIMIZE?

Avatar of sks

ASKER

I don't understand completely how I can make it NOT minimize when the user clicks
on MINIMIZE?

Avatar of sks

ASKER

I got it working..........thanks a lot

God Bless You

Sorry, I didn't get back my mail server was down most of the day and now I've got a 15 messages along the lines of "I've got problems...where are you?"  Its good to see this one got solved!