Click here to Skip to main content
13,002,275 members (65,544 online)
Rate this:
Please Sign up or sign in to vote.
See more:
In my MFC CFormView based application, i want to handle
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
. To maximise the dialog there is style called
. 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
OnSysCommand( UINT nID_i, LPARAM lParam )
. ie iam send
::PostMessage( m_hWnd, WM_SYSCOMMAND, SC_RESTORE, 0 )
from double OnNcLButtonDblClk function. but Restore is not working.

handling of Restore.
void CTitleDoubleClickDlg::OnSysCommand(UINT nID, LPARAM lParam)
    if( SC_RESTORE == nID )
        CDialog::OnSysCommand(nID, lParam);
        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 20-Dec-12 19:34pm
Mohibur Rashid 21-Dec-12 2:01am
It was suppose to do by itself............
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

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

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

Advertise | Privacy | Mobile
Web02 | 2.8.170624.1 | Last Updated 21 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100