Solved

Minimize Event

Posted on 1998-07-15
8
923 Views
Last Modified: 2008-02-01
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.
0
Comment
Question by:sks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 100 total points
ID: 1167892
I think your best bet to trap this is in the OnsysCommand() function.

Let me know if you need more details.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1167893
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.
0
 

Author Comment

by:sks
ID: 1167894
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?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Expert Comment

by:nietod
ID: 1167895
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.  
0
 

Author Comment

by:sks
ID: 1167896
I don't understand completely how I can make it NOT minimize when the user clicks
on MINIMIZE?

0
 

Author Comment

by:sks
ID: 1167897
I don't understand completely how I can make it NOT minimize when the user clicks
on MINIMIZE?

0
 

Author Comment

by:sks
ID: 1167898
I got it working..........thanks a lot

God Bless You

0
 
LVL 22

Expert Comment

by:nietod
ID: 1167899
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!
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question