Solved

Minimize Event

Posted on 1998-07-15
8
922 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

751 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