Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Cannot handle 'Maximize' event for a MFC MDI application using OnS

40 views
Skip to first unread message

suchi.de

unread,
Jan 4, 2010, 8:14:01 AM1/4/10
to
We have a MFC application based on MFC Multi Docuemnt Architecture.

We have a menu item 'Lock' , on clicking which we set the lock flag to true
and send the following message to minimize the application, frm the App class.
CMainFrame *)m_pMainWnd->SendMessage(WM_SYSCOMMAND, SC_MINIMIZE);

Once the application is locked, on trying to maximize the application , the
user is prompted back with a login dialog.
To trap the maximize\restore operation we have the following code in the
Frame class.

void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
if ( theApp.m_isApplocked)
{
if (nID == SC_MAXIMIZE || nID == SC_RESTORE || nID == SC_CLOSE)
{
CDGPassword passdlg;
if ( passdlg.DoModal() == IDOK)
{
theApp.m_isApplocked = false;
}
else
{
return;
}
}
}
CMDIFrameWnd::OnSysCommand(nID,lParam);
}
This works perfectly when we lock the application and immediately try to
maximize it. The user is prompted with the login dialog as expected.
However, if we lock the application , then hover the mouse pointer to some
other applications in the taskbar ( without actualy clicking on any of them),
and then click on our minimized application , the application gets maximized
without prompting for any login dialog.
On debugging the code, we found out that in the second case, on hovering the
mouse pointer to other apps and then clicking our app, the control never goes
to the OnSysCommand handler at all.

We tried with a sample application using the MDI architecture and faced the
same issue.

I want to know if anybody has come across a similar issue, or if there is
any other message apart from WM_COMMAND that I need to handle for trapping
the maximize event.

Any help in this regard will be appreciated.


David Lowndes

unread,
Jan 4, 2010, 8:58:36 AM1/4/10
to
>On debugging the code, we found out that in the second case, on hovering the
>mouse pointer to other apps and then clicking our app, the control never goes
>to the OnSysCommand handler at all.

I'd recommend that you use Spy++ to record which messages you get in
all circumstances so that you can come up with a solution that'll work
consistently.

Dave

0 new messages