Here is test dialog class (Example 11)
Header file
#pragma once
#include "WndResizer.h"
class CExample11Dlg : public CDialog
{
DECLARE_DYNAMIC(CExample11Dlg)
public:
CExample11Dlg(CWnd* pParent = NULL); virtual ~CExample11Dlg();
enum { IDD = IDD_EX11_DLG };
CWndResizer m_resizer;
protected:
virtual void DoDataExchange(CDataExchange* pDX);
DECLARE_MESSAGE_MAP()
public:
virtual BOOL OnInitDialog();
afx_msg void OnShowOptionsCheck();
afx_msg void OnHideTopPanelCheck();
afx_msg void OnHideBottomPanelCheck();
};
Implementation file (CPP)
#include "stdafx.h"
#include "WndResizerApp.h"
#include "Example11Dlg.h"
IMPLEMENT_DYNAMIC(CExample11Dlg, CDialog)
CExample11Dlg::CExample11Dlg(CWnd* pParent )
: CDialog(CExample11Dlg::IDD, pParent)
{
}
CExample11Dlg::~CExample11Dlg()
{
}
void CExample11Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CExample11Dlg, CDialog)
ON_BN_CLICKED(IDC_OPTIONS_CHECK, OnShowOptionsCheck)
ON_BN_CLICKED(IDC_HIDE_TOP_CHECK, OnHideTopPanelCheck)
ON_BN_CLICKED(IDC_HIDE_BOTTOM_CHECK, OnHideBottomPanelCheck)
END_MESSAGE_MAP()
BOOL CExample11Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_resizer.Hook( this );
m_resizer.SetAnchor( IDC_TOPLABEL, ANCHOR_TOP | ANCHOR_HORIZONTALLY );
#if 1
m_resizer.CreateSplitContainer( _T("InputOutputSplitter"), IDC_INPUT_EDIT, IDC_OUTPUT_EDIT );
m_resizer.SetShowSplitterGrip( _T("InputOutputSplitter"), TRUE );
m_resizer.SetAnchor( _T("InputOutputSplitter"), ANCHOR_ALL );
m_resizer.SetParent( IDC_INPUT_LABEL, IDC_INPUT_EDIT );
m_resizer.SetAnchor( IDC_INPUT_LABEL, ANCHOR_LEFT | ANCHOR_TOP );
m_resizer.SetParent( IDC_INPUT_CLEAR_BUTTON, IDC_INPUT_EDIT );
m_resizer.SetAnchor( IDC_INPUT_CLEAR_BUTTON, ANCHOR_RIGHT | ANCHOR_TOP );
m_resizer.SetMinimumSize( IDC_INPUT_EDIT, CSize(0, 0) );
#else
const UINT inputIds[] = { IDC_INPUT_EDIT, IDC_INPUT_LABEL, IDC_INPUT_CLEAR_BUTTON, 0 };
m_resizer.CreatePanel( _T("InputPanel"), inputIds, TRUE );
m_resizer.SetAnchor( IDC_INPUT_EDIT, ANCHOR_ALL );
m_resizer.SetAnchor( IDC_INPUT_LABEL, ANCHOR_LEFT | ANCHOR_TOP );
m_resizer.SetAnchor( IDC_INPUT_CLEAR_BUTTON, ANCHOR_RIGHT | ANCHOR_TOP );
m_resizer.SetMinimumSize( IDC_INPUT_EDIT, CSize(0, 0) );
m_resizer.SetMinimumSize( _T("InputPanel"), CSize(0, 0) );
m_resizer.CreateSplitContainer( _T("InputOutputSplitter"), _T("InputPanel"), IDC_OUTPUT_EDIT );
m_resizer.SetShowSplitterGrip( _T("InputOutputSplitter"), TRUE );
m_resizer.SetAnchor( _T("InputOutputSplitter"), ANCHOR_ALL );
#endif
m_resizer.SetParent( IDC_OUTPUT_LABEL, IDC_OUTPUT_EDIT );
m_resizer.SetAnchor( IDC_OUTPUT_LABEL, ANCHOR_LEFT | ANCHOR_TOP );
m_resizer.SetParent( IDC_OUTPUT_CLEAR_BUTTON, IDC_OUTPUT_EDIT );
m_resizer.SetAnchor( IDC_OUTPUT_CLEAR_BUTTON, ANCHOR_RIGHT | ANCHOR_TOP );
m_resizer.SetMinimumSize( IDC_OUTPUT_EDIT, CSize(0, 0) );
const UINT options_panel_ids[] = { IDC_ICON_STATIC, IDC_HIDE_TOP_CHECK, IDC_HIDE_BOTTOM_CHECK, 0 };
m_resizer.CreatePanel( _T("OptionsPanel"), options_panel_ids, TRUE );
m_resizer.SetAnchor( _T("OptionsPanel"), ANCHOR_BOTTOMLEFT );
m_resizer.CreateSplitContainer( _T("MainSplitter"), _T("InputOutputSplitter"), _T("OptionsPanel") );
m_resizer.SetAnchor( _T("MainSplitter"), ANCHOR_ALL );
m_resizer.SetIsSplitterFixed( _T("MainSplitter"), TRUE );
m_resizer.SetFixedPanel( _T("MainSplitter"), CWndResizer::FIXED_BOTTOM );
m_resizer.SetAnchor( IDC_OPTIONS_CHECK, ANCHOR_BOTTOMLEFT );
m_resizer.SetAnchor( IDOK, ANCHOR_BOTTOMRIGHT );
m_resizer.SetAnchor( IDCANCEL, ANCHOR_BOTTOMRIGHT );
m_resizer.SetShowResizeGrip();
CRect rcMin;
GetClientRect( &rcMin );
m_resizer.SetMinimumSize( CWndResizer::RootPanelName, CSize(rcMin.Width(), rcMin.Height()) );
CheckDlgButton( IDC_OPTIONS_CHECK, BST_CHECKED );
m_resizer.InvokeOnResized();
return TRUE; }
void CExample11Dlg::OnShowOptionsCheck()
{
if( IsDlgButtonChecked( IDC_OPTIONS_CHECK ) )
m_resizer.SetFixedPanel( _T("MainSplitter"), CWndResizer::FIXED_BOTTOM );
else
m_resizer.SetFixedPanel( _T("MainSplitter"), CWndResizer::FIXED_BOTTOM_HIDDEN );
m_resizer.InvokeOnResized();
}
void CExample11Dlg::OnHideTopPanelCheck()
{
if( IsDlgButtonChecked( IDC_HIDE_TOP_CHECK ) )
{
m_resizer.SetFixedPanel( _T("InputOutputSplitter"), CWndResizer::FIXED_TOP_HIDDEN );
CheckDlgButton( IDC_HIDE_BOTTOM_CHECK, BST_UNCHECKED );
}
else
m_resizer.SetFixedPanel( _T("InputOutputSplitter"), 0 );
m_resizer.InvokeOnResized();
}
void CExample11Dlg::OnHideBottomPanelCheck()
{
if( IsDlgButtonChecked( IDC_HIDE_BOTTOM_CHECK ) )
{
m_resizer.SetFixedPanel( _T("InputOutputSplitter"), CWndResizer::FIXED_BOTTOM_HIDDEN );
CheckDlgButton( IDC_HIDE_TOP_CHECK, BST_UNCHECKED );
}
else
m_resizer.SetFixedPanel( _T("InputOutputSplitter"), 0 );
m_resizer.InvokeOnResized();
}
Control definitions:
#define IDD_EX11_DLG 138
#define IDC_HIDE_TOP_CHECK 1057
#define IDC_TOPLABEL 1058
#define IDC_OPTIONS_CHECK 1059
#define IDC_BOTTOM_HIDE_CHECK 1060
#define IDC_ICON_STATIC 1061
#define IDC_HIDE_BOTTOM_CHECK 1062
#define IDC_OUTPUT_EDIT 1331
#define IDC_INPUT_EDIT 1332
#define IDC_INPUT_LABEL 1351
#define IDC_OUTPUT_LABEL 1352
#define IDC_OUTPUT_CLEAR_BUTTON 1353
#define IDC_INPUT_CLEAR_BUTTON 1354
And Dialog template:
IDD_EX11_DLG DIALOGEX 0, 0, 276, 184
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Example 11: Splitter and hiding"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,167,163,50,14
PUSHBUTTON "Cancel",IDCANCEL,219,163,50,14
LTEXT "This example shows automatic hiding of splitter and maximizing one of the panels in splitter",IDC_TOPLABEL,7,7,262,19
LTEXT "Input data:",IDC_INPUT_LABEL,7,31,38,8
EDITTEXT IDC_INPUT_EDIT,7,40,262,42,ES_MULTILINE | WS_VSCROLL
PUSHBUTTON "x",IDC_INPUT_CLEAR_BUTTON,257,30,12,10,BS_BOTTOM | BS_FLAT
LTEXT "Output data:",IDC_OUTPUT_LABEL,7,84,43,8
EDITTEXT IDC_OUTPUT_EDIT,7,93,262,42,ES_MULTILINE | WS_VSCROLL
PUSHBUTTON "x",IDC_OUTPUT_CLEAR_BUTTON,257,83,12,10,BS_BOTTOM | BS_FLAT
ICON IDR_MAINFRAME,IDC_ICON_STATIC,14,140,21,20
CONTROL "Show options",IDC_OPTIONS_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,167,59,10
CONTROL "Hide top panel",IDC_HIDE_TOP_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,51,140,62,10
CONTROL "Hide bottom panel",IDC_HIDE_BOTTOM_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,51,151,74,10
END
Michał
|