// This is part of the Professional User Interface Suite library.
// Copyright (C) 2001-2002 FOSS Software, Inc.
// All rights reserved.
//
// http://www.fossware.com
// mailto:foss@fossware.com
//
// This source code can be used, modified and redistributed
// under the terms of the license agreement that is included
// in the Professional User Interface Suite package.
//
// Warranties and Disclaimers:
// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND
// INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
// IN NO EVENT WILL FOSS SOFTWARE INC. BE LIABLE FOR ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES,
// INCLUDING DAMAGES FOR LOSS OF PROFITS, LOSS OR INACCURACY OF DATA,
// INCURRED BY ANY PERSON FROM SUCH PERSON'S USAGE OF THIS SOFTWARE
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
#include "stdafx.h"
#if (!defined __EXT_RESIZABLE_DIALOG_H)
#include <ExtResizableDialog.h>
#endif
#if (!defined __EXT_CONTROLBAR_H)
#include <ExtControlBar.h>
#endif
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CExtResizableDialog
IMPLEMENT_DYNAMIC( CExtResizableDialog, CDialog )
CExtResizableDialog::CExtResizableDialog()
: m_bEnabledControlBarUpdate( false )
, m_bInConrolBarUpdate( false )
{
m_bShowResizingGripper = true;
}
CExtResizableDialog::CExtResizableDialog(
UINT nIDTemplate,
CWnd * pParentWnd
)
: CExtWA < CExtWS < __BASEOF_CExtResizableDialog__ > >( nIDTemplate, pParentWnd )
, m_bEnabledControlBarUpdate( false )
, m_bInConrolBarUpdate( false )
{
m_bShowResizingGripper = true;
}
CExtResizableDialog::CExtResizableDialog(
LPCTSTR lpszTemplateName,
CWnd * pParentWnd
)
: CExtWA < CExtWS < __BASEOF_CExtResizableDialog__ > >( lpszTemplateName, pParentWnd )
, m_bEnabledControlBarUpdate( false )
, m_bInConrolBarUpdate( false )
{
m_bShowResizingGripper = true;
}
BEGIN_MESSAGE_MAP(CExtResizableDialog, CDialog)
//{{AFX_MSG_MAP(CExtResizableDialog)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CExtResizableDialog message handlers
void CExtResizableDialog::OnOK()
{
DWORD dwStyle = GetStyle();
if( (dwStyle & WS_CHILD) == 0 )
CExtWA < CExtWS < __BASEOF_CExtResizableDialog__ > >::OnOK();
}
void CExtResizableDialog::OnCancel()
{
DWORD dwStyle = GetStyle();
if( (dwStyle & WS_CHILD) == 0 )
CExtWA < CExtWS < __BASEOF_CExtResizableDialog__ > >::OnCancel();
}
LRESULT CExtResizableDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if( message == WM_DESTROY )
m_bEnabledControlBarUpdate = false;
bool bUpdateBarsOnThisMsg = false;
if( m_bEnabledControlBarUpdate )
{
CWinApp * pApp = AfxGetApp();
ASSERT( pApp != NULL );
BOOL bIdleMsg = pApp->IsIdleMessage(
#if _MFC_VER < 0x700
&pApp->m_msgCur
#else
&(::AfxGetThreadState()->m_msgCur)
#endif
);
if( bIdleMsg )
bUpdateBarsOnThisMsg = true;
}
LRESULT lResult =
CExtWA < CExtWS < __BASEOF_CExtResizableDialog__ > >::WindowProc(message, wParam, lParam);
if( bUpdateBarsOnThisMsg && (!m_bInConrolBarUpdate) )
{
m_bInConrolBarUpdate = true;
CExtControlBar::DoCustomModeUpdateControlBars( this );
m_bInConrolBarUpdate = false;
}
return lResult;
}
void CExtResizableDialog::PreSubclassWindow()
{
CDialog::PreSubclassWindow();
m_bEnabledControlBarUpdate = true;
EnableToolTips();
}
BOOL CExtResizableDialog::PreTranslateMessage(MSG* pMsg)
{
if(
CExtControlBar::DoCustomModePreTranslateMessage(
this,
pMsg
)
)
return TRUE;
return CDialog::PreTranslateMessage(pMsg);
}
//////////////////////////////////////////////////////////////////////////
// CExtResizablePropertyPage
IMPLEMENT_DYNAMIC( CExtResizablePropertyPage, CPropertyPage )
CExtResizablePropertyPage::CExtResizablePropertyPage()
: m_bEnabledControlBarUpdate( false )
, m_bInConrolBarUpdate( false )
{
m_bShowResizingGripper = false;
}
CExtResizablePropertyPage::CExtResizablePropertyPage(
UINT nIDTemplate,
UINT nIDCaption // = 0
)
: CExtWA < CExtWS < __BASEOF_CExtResizablePropertyPage__ > >( nIDTemplate, nIDCaption )
, m_bEnabledControlBarUpdate( false )
, m_bInConrolBarUpdate( false )
{
m_bShowResizingGripper = false;
}
CExtResizablePropertyPage::CExtResizablePropertyPage(
LPCTSTR lpszTemplateName,
UINT nIDCaption // = 0
)
: CExtWA < CExtWS < __BASEOF_CExtResizablePropertyPage__ > >( lpszTemplateName, nIDCaption )
, m_bEnabledControlBarUpdate( false )
, m_bInConrolBarUpdate( false )
{
m_bShowResizingGripper = false;
}
BEGIN_MESSAGE_MAP(CExtResizablePropertyPage, CPropertyPage)
//{{AFX_MSG_MAP(CExtResizablePropertyPage)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CExtResizablePropertyPage message handlers
void CExtResizablePropertyPage::OnOK()
{
DWORD dwStyle = GetStyle();
if( (dwStyle & WS_CHILD) == 0 )
CExtWA < CExtWS < __BASEOF_CExtResizablePropertyPage__ > >::OnOK();
}
void CExtResizablePropertyPage::OnCancel()
{
DWORD dwStyle = GetStyle();
if( (dwStyle & WS_CHILD) == 0 )
CExtWA < CExtWS < __BASEOF_CExtResizablePropertyPage__ > >::OnCancel();
}
LRESULT CExtResizablePropertyPage::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if( message == WM_DESTROY )
m_bEnabledControlBarUpdate = false;
bool bUpdateBarsOnThisMsg = false;
if( m_bEnabledControlBarUpdate )
{
CWinApp * pApp = AfxGetApp();
ASSERT( pApp != NULL );
BOOL bIdleMsg = pApp->IsIdleMessage(
#if _MFC_VER < 0x700
&pApp->m_msgCur
#else
&(::AfxGetThreadState()->m_msgCur)
#endif
);
if( bIdleMsg )
bUpdateBarsOnThisMsg = true;
}
LRESULT lResult =
CExtWA < CExtWS < __BASEOF_CExtResizablePropertyPage__ > >::WindowProc(message, wParam, lParam);
switch( message )
{
case WM_SHOWWINDOW:
case WM_WINDOWPOSCHANGED:
if( GetStyle() & WS_VISIBLE )
ArrangeLayout();
break;
} // switch( message )
if( bUpdateBarsOnThisMsg && (!m_bInConrolBarUpdate) )
{
m_bInConrolBarUpdate = true;
CExtControlBar::DoCustomModeUpdateControlBars( this );
m_bInConrolBarUpdate = false;
}
return lResult;
}
void CExtResizablePropertyPage::PreSubclassWindow()
{
CPropertyPage::PreSubclassWindow();
m_bEnabledControlBarUpdate = true;
EnableToolTips();
}
BOOL CExtResizablePropertyPage::PreTranslateMessage(MSG* pMsg)
{
if(
CExtControlBar::DoCustomModePreTranslateMessage(
this,
pMsg
)
)
return TRUE;
return CPropertyPage::PreTranslateMessage(pMsg);
}
/////////////////////////////////////////////////////////////////////////////
// CExtResizablePropertySheet
IMPLEMENT_DYNAMIC( CExtResizablePropertySheet, CPropertySheet )
CExtResizablePropertySheet::CExtResizablePropertySheet()
: m_bSheetInitialized( false )
{
m_bShowResizingGripper = true;
}
CExtResizablePropertySheet::CExtResizablePropertySheet(
UINT nIDCaption,
CWnd *pParentWnd, // = NULL
UINT iSelectPage // = 0
)
: CExtWA < CExtWS < __BASEOF_CExtResizablePropertySheet__ > >( nIDCaption, pParentWnd, iSelectPage )
, m_bSheetInitialized( false )
{
m_bShowResizingGripper = true;
}
CExtResizablePropertySheet::CExtResizablePropertySheet(
LPCTSTR pszCaption,
CWnd *pParentWnd, // = NULL
UINT iSelectPage // = 0
)
: CExtWA < CExtWS < __BASEOF_CExtResizablePropertySheet__ > >( pszCaption, pParentWnd, iSelectPage )
, m_bSheetInitialized( false )
{
m_bShowResizingGripper = true;
}
BEGIN_MESSAGE_MAP(CExtResizablePropertySheet, CPropertySheet)
//{{AFX_MSG_MAP(CExtResizablePropertySheet)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CExtResizablePropertySheet message handlers
void CExtResizablePropertySheet::PreSubclassWindow()
{
CPropertySheet::PreSubclassWindow();
EnableToolTips();
}
void CExtResizablePropertySheet::_SyncActivePage()
{
CPropertyPage * pWnd = CPropertySheet::GetActivePage();
if( pWnd != NULL
&& pWnd->GetSafeHwnd() != NULL
&& ::IsWindow( pWnd->GetSafeHwnd() )
)
{
RDI_t _val;
if( !m_mapRDI.Lookup(
pWnd->GetSafeHwnd(),
_val
)
)
AddAnchor(
pWnd->GetSafeHwnd(),
__RDA_LT,
__RDA_RB
);
}
}
LRESULT CExtResizablePropertySheet::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
CPropertyPage * pWndPrevActivePage = NULL;
switch( message )
{
case WM_CLOSE:
if( m_bEnableSaveRestore )
SaveWindowRect();
break;
case WM_SYSCOMMAND:
if( wParam == SC_CLOSE )
{
if( m_bEnableSaveRestore )
SaveWindowRect();
}
break;
case WM_COMMAND:
if( wParam == IDOK || wParam == IDCANCEL )
{
if( m_bEnableSaveRestore )
SaveWindowRect();
}
else if( wParam == ID_WIZBACK || wParam == ID_WIZNEXT )
{
pWndPrevActivePage = CPropertySheet::GetActivePage();
}
break;
case WM_DESTROY:
case WM_NCDESTROY:
m_bSheetInitialized = false;
break;
case WM_SIZE:
_SyncActivePage();
break;
} // switch( message )
LRESULT lResult =
m_bSheetInitialized
? CExtWA < CExtWS < __BASEOF_CExtResizablePropertySheet__ > > :: WindowProc(message,wParam,lParam)
: CPropertySheet :: WindowProc(message,wParam,lParam)
;
switch( message )
{
case WM_CREATE:
{
// window should be resizable
ModifyStyle(
0,
WS_THICKFRAME | WS_CLIPCHILDREN
);
::PostMessage( m_hWnd, (WM_USER+10), 0, 0 );
}
break;
case (WM_USER+10):
{
if( m_bSheetInitialized )
break;
m_bSheetInitialized = true;
CRect rcWnd;
GetWindowRect( &rcWnd );
CSize sizeWnd = rcWnd.Size();
SetMinTrackSize( sizeWnd );
::SetWindowPos(
m_hWnd, NULL, 0,0,0,0,
SWP_NOSIZE|SWP_NOMOVE
|SWP_NOZORDER|SWP_NOOWNERZORDER
|SWP_NOREPOSITION
|SWP_FRAMECHANGED
);
CTabCtrl * pTabCtrl = CPropertySheet::GetTabControl();
CWnd * pWnd = GetWindow( GW_CHILD );
for( ; pWnd != NULL; pWnd = pWnd->GetWindow(GW_HWNDNEXT) )
{
if( pTabCtrl == pWnd )
{
pTabCtrl->ModifyStyle( 0, WS_CLIPSIBLINGS );
AddAnchor( pTabCtrl->GetSafeHwnd(), __RDA_LT, __RDA_RB );
continue;
}
CString sClassName;
::GetClassName(
pWnd->GetSafeHwnd(),
sClassName.GetBuffer( _MAX_PATH+1 ),
_MAX_PATH
);
sClassName.ReleaseBuffer();
sClassName.MakeLower();
if( sClassName == _T("static") )
{
pWnd->ModifyStyle( 0, WS_CLIPSIBLINGS );
AddAnchor( pWnd->GetSafeHwnd(), __RDA_LB, __RDA_RB );
continue;
}
if( sClassName == _T("button") )
{
CRect rcWndButton;
pWnd->GetWindowRect( &rcWndButton );
ScreenToClient( &rcWndButton );
rcWndButton.OffsetRect( -10, 0 );
pWnd->MoveWindow( &rcWndButton );
pWnd->ModifyStyle( 0, WS_CLIPSIBLINGS );
AddAnchor( pWnd->GetSafeHwnd(), __RDA_RB );
CButtonInSheetHook * pBtn = new CButtonInSheetHook;
VERIFY(
pBtn->SubclassWindow(
pWnd->GetSafeHwnd()
)
);
continue;
}
//AddAnchor( pWnd->GetSafeHwnd(), __RDA_LT, __RDA_RB );
} // for( ; pWnd != NULL; pWnd = pWnd->GetWindow(GW_HWNDNEXT) )
_SyncActivePage();
CRect rcDesktop( 0, 0, 0, 0 );
::SystemParametersInfo( SPI_GETWORKAREA, 0, &rcDesktop, 0 );
SetMaximizedRect( &rcDesktop );
CSize sizeDesktop = rcDesktop.Size();
SetMaxTrackSize( sizeDesktop );
CRect _rcWnd;
GetWindowRect( &_rcWnd );;
CSize _size = _rcWnd.Size();
::SendMessage(
m_hWnd, WM_SIZE,
WPARAM(SIZE_RESTORED),
MAKELPARAM( _size.cx, _size.cy )
);
if( GetStyle() & WS_VISIBLE )
RedrawWindow();
OnResizablePropertySheetInitialized();
}
break;
case WM_COMMAND:
if( wParam == ID_WIZBACK || wParam == ID_WIZNEXT )
{
if( !m_bSheetInitialized )
break;
if( pWndPrevActivePage != NULL )
{
CPropertyPage * pWndNewActivePage = CPropertySheet::GetActivePage();
if( pWndPrevActivePage != pWndNewActivePage )
{
CRect rcWndPage;
pWndPrevActivePage->GetWindowRect( &rcWndPage );
ScreenToClient( &rcWndPage );
pWndNewActivePage->MoveWindow( &rcWndPage );
}
}
_SyncActivePage();
ArrangeLayout();
}
break;
} // switch( message )
return lResult;
}
BOOL CExtResizablePropertySheet::PreCreateWindow(CREATESTRUCT& cs)
{
if( ! ( CExtWA < CExtWS < __BASEOF_CExtResizablePropertySheet__ > > :: PreCreateWindow(cs) ) )
{
ASSERT( FALSE );
return FALSE;
}
return TRUE;
}
void CExtResizablePropertySheet::OnResizablePropertySheetInitialized()
{
if( m_bEnableSaveRestore )
LoadWindowRect();
}