home *** CD-ROM | disk | FTP | other *** search
- // ChildFrm.cpp : implementation of the CChildFrame class
- //
-
- #include "stdafx.h"
- #include "MinSplitSize.h"
-
- #include "ChildFrm.h"
-
- #include "MinSplitSizeView.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CChildFrame
-
- IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
-
- BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
- //{{AFX_MSG_MAP(CChildFrame)
- ON_WM_WINDOWPOSCHANGING()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CChildFrame construction/destruction
-
- CChildFrame::CChildFrame()
- {
- // TODO: add member initialization code here
-
- }
-
- CChildFrame::~CChildFrame()
- {
- }
-
- BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
-
- return CMDIChildWnd::PreCreateWindow(cs);
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CChildFrame diagnostics
-
- #ifdef _DEBUG
- void CChildFrame::AssertValid() const
- {
- CMDIChildWnd::AssertValid();
- }
-
- void CChildFrame::Dump(CDumpContext& dc) const
- {
- CMDIChildWnd::Dump(dc);
- }
-
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // CChildFrame message handlers
-
- BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/, CCreateContext* pContext)
- {
- m_wndSplitter.CreateStatic( this, 3, 3 );
- m_wndSplitter.CreateView( 0, 0, RUNTIME_CLASS( CMinSplitSizeView ), CSize( 50, 50 ), pContext );
- m_wndSplitter.CreateView( 0, 1, RUNTIME_CLASS( CMinSplitSizeView ), CSize( 50, 60 ), pContext );
- m_wndSplitter.CreateView( 0, 2, RUNTIME_CLASS( CMinSplitSizeView ), CSize( 50, 70 ), pContext );
- m_wndSplitter.CreateView( 1, 0, RUNTIME_CLASS( CMinSplitSizeView ), CSize( 60, 50 ), pContext );
- m_wndSplitter.CreateView( 1, 1, RUNTIME_CLASS( CMinSplitSizeView ), CSize( 60, 60 ), pContext );
- m_wndSplitter.CreateView( 1, 2, RUNTIME_CLASS( CMinSplitSizeView ), CSize( 60, 70 ), pContext );
- m_wndSplitter.CreateView( 2, 0, RUNTIME_CLASS( CMinSplitSizeView ), CSize( 70, 50 ), pContext );
- m_wndSplitter.CreateView( 2, 1, RUNTIME_CLASS( CMinSplitSizeView ), CSize( 70, 60 ), pContext );
- m_wndSplitter.CreateView( 2, 2, RUNTIME_CLASS( CMinSplitSizeView ), CSize( 70, 70 ), pContext );
-
- m_wndSplitter.SetColumnInfo( 0, 50, 50 );
- m_wndSplitter.SetColumnInfo( 1, 60, 60 );
- m_wndSplitter.SetColumnInfo( 2, 70, 70 );
- m_wndSplitter.SetRowInfo( 0, 50, 50 );
- m_wndSplitter.SetRowInfo( 1, 60, 60 );
- m_wndSplitter.SetRowInfo( 2, 70, 70 );
-
- return TRUE;
- }
-
- void CChildFrame::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)
- {
- // Don't do anything if minimized.
- if ( IsIconic() )
- {
- CMDIChildWnd::OnWindowPosChanging( lpwndpos );
- return;
- } // if
-
- // Calculate the window rect if we have no client area.
- CRect rc( 0, 0, 0, 0 );
- CalcWindowRect( rc );
-
- // Add on the minimum client width and height from the splitter.
- int nMinWidth = rc.Width() + m_wndSplitter.GetMinClientWidth();
- int nMinHeight = rc.Height() + m_wndSplitter.GetMinClientHeight();
-
- // Get the current window size.
- CRect rcWindow;
- GetWindowRect( rcWindow );
- GetParent()->ScreenToClient( rcWindow );
-
- // If trying to size too small...
- if ( lpwndpos->cx < nMinWidth )
- {
- // If dragging left border right...
- if ( rcWindow.left < lpwndpos->x )
- {
- // How much over are we?
- int nOver = nMinWidth - lpwndpos->cx;
-
- // Adjust left coord.
- lpwndpos->x -= nOver;
-
- } // if
-
- // Fix width.
- lpwndpos->cx = nMinWidth;
- } // if
-
- // If trying to size too small...
- if ( lpwndpos->cy < nMinHeight )
- {
- // If dragging top border down...
- if ( rcWindow.top < lpwndpos->y )
- {
- // How much over are we?
- int nOver = nMinHeight - lpwndpos->cy;
-
- // Adjust left coord.
- lpwndpos->y -= nOver;
- } // if
-
- // Fix height.
- lpwndpos->cy = nMinHeight;
- } // if
- }
-