[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Asking for PWD at maximize?

Posted on 2000-05-05
7
Medium Priority
?
284 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
Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

 
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

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.

Question has a verified solution.

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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

649 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