Solved

Asking for PWD at maximize?

Posted on 2000-05-05
7
252 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ORA-01403: no data found 43 101
bigDiff challenge 17 106
changeXy challenge 13 82
Problem to open Excel file 15 133
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

778 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