Solved

Minimize Event

Posted on 1998-07-15
8
913 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
  • 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
 
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
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.

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now