Solved

Minimize Event

Posted on 1998-07-15
8
914 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
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 pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

896 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

18 Experts available now in Live!

Get 1:1 Help Now