?
Solved

Asking for PWD at maximize?

Posted on 2000-05-05
7
Medium Priority
?
277 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

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 …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

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