Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
In my MFC CFormView based application, i want to handle
C++
ON_WM_NCLBUTTONDBLCLK()
windows message. ie, when a user double click on
Tittle bar of the dialog, window needs to be maximise. So i handled the above window message. To check whether clickked area is tittle bar or not iam used
C++
HTCAPTION
. To maximise the dialog there is style called
C++
SC_MAXIMIZE
. i know this. but iam not need this. so that iam used CWnd::MoveWindow function for resize the window.
But again double click is happend, then window needs to be restored.
For that iam handled
C++
OnSysCommand( UINT nID_i, LPARAM lParam )
. ie iam send
C++
::PostMessage( m_hWnd, WM_SYSCOMMAND, SC_RESTORE, 0 )
from double OnNcLButtonDblClk function. but Restore is not working.

handling of Restore.
C++
void CTitleDoubleClickDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
    if( SC_RESTORE == nID )
    {
        CDialog::OnSysCommand(nID, lParam);
    }
    else
    {
        CDialog::OnSysCommand(nID, lParam);
    }
}


My question is
1. How to restore a window to its previous size by using SC_RESTORE( Note: iam using MoveWindow insted of SC_MAXIMISE for maximise the window)
Posted
Comments
Mohibur Rashid 21-Dec-12 2:01am    
It was suppose to do by itself............
[no name] 21-Dec-12 2:15am    
means?
Jochen Arndt 21-Dec-12 3:26am    
Use the reply button at the right of a comment (like I have done now). So the poster of the comment will get a mail notification and may answer you.

I think Mohibur means that you must track the window state yourself when not using the Windows functions: Upon maximize and minimize, save the window size and position in member vars and use these for restoring. Optionally, saving must be also done upon moving and resizing (SC_MOVE and SC_SIZE).

1 solution

I believe your problem may be that you are using MoveWindow() so the new size of the window will be set after the move. When you pass the SC_RESTORE command to the default procedure, it has no previous information to restore it. You should be able to check this by stepping into the windows code if you have the source loaded on your system.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900