Click here to Skip to main content
11,502,383 members (35,098 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VC6 C++
In my MFC CFormView based application, i want to handle
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
HTCAPTION
. To maximise the dialog there is style called
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
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);
    }
    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 20-Dec-12 19:34pm
Comments
Mohibur Rashid at 21-Dec-12 2:01am
   
It was suppose to do by itself............
Jochen Arndt at 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
good
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.
  Permalink  

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



Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 21 Dec 2012
Copyright © CodeProject, 1999-2015
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