[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Asking for PWD at maximize?

Posted on 2000-05-05
7
Medium Priority
?
288 Views
Last Modified: 2013-11-20
Hello,
I want to develop an app. that should ask for a password when it is being maximized (like CCMail), I would really appreciate if I can put password while getting focus too i.e, while repainting.
Thanx in advance.
0
Comment
Question by:Moin
  • 3
  • 2
  • 2
7 Comments
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 2779887
do you mean maximized (full screen) or restored ?

either way you may want to look at overriding OnActivate(...) or OnActivateApp(...) (WM_ACTVATE or WM_ACTIVATEAPP respectively)
0
 
LVL 1

Expert Comment

by:tomkeane
ID: 2782201
Add a handler for WM_WINDOWPOSCHANGING - before the window is resized you'll get this message with a WINDOWPOS structure as an argument.

You can check the flags in the WINDOWPOS argument to see if the window is about to be maximized (or restored) and prompt the user for the password.

If the password is not entered correctly, you can modify the flags in the WINDOWPOS structure to prevent the window from being maximized/restored.

Hope this helps-

Tom
0
 

Author Comment

by:Moin
ID: 2791526
How will I add a handler to "WM_WINDOWPOSCHANGING", because I couldn';t find it anywhere in the MFC  classwizard dialog?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 9

Expert Comment

by:ShaunWilde
ID: 2791662
you will need to change your filter in the class info tab to 'window' for the class that you wish to add this handler to
0
 
LVL 1

Expert Comment

by:tomkeane
ID: 2791700
You could also add it manually (which  is not a bad thing to learn to do anyway...)

Add the following to your header file:
afx_msg void OnWindowPosChanging( WINDOWPOS* lpwndpos );

Add:
  ON_WM_WINDOWPOSCHANGING()
to your message map

and add the function to your class:

void YourClass::OnWindowPosChanging( WINDOWPOS* lpwndpos )
{

}

Tom
0
 

Author Comment

by:Moin
ID: 2795631
How is the WINDOWPOS struct showing the state of Window, i.e., maximized or minimized
0
 
LVL 1

Accepted Solution

by:
tomkeane earned 300 total points
ID: 2795800
I read your question again and had another idea.  Handle WM_SYSCOMMAND - the following code will fire whenver the window is minimized before it gets restored.  In place the MessageBox, you would place your password dialog.

void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
  if (IsIconic() && 
    (nID == SC_RESTORE ||
     nID == SC_ZOOM ||
     nID == SC_MAXIMIZE))
  {
    if (MessageBox( "Allow to restore?", "MyApp", MB_OKCANCEL ) != IDOK)
    {
      return;
    }
  }
      
CFrameWnd::OnSysCommand(nID, lParam);
}
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

831 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