Solved

Asking for PWD at maximize?

Posted on 2000-05-05
7
238 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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 100 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

9 Experts available now in Live!

Get 1:1 Help Now