mirror of https://github.com/tongzx/nt5src
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
140 lines
2.9 KiB
140 lines
2.9 KiB
// ChildFrm.cpp : implementation of the CChildFrame class
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "mditest.h"
|
|
|
|
#include "ChildFrm.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_COMMAND(ID_FILE_CLOSE, OnFileClose)
|
|
ON_WM_SETFOCUS()
|
|
ON_WM_CREATE()
|
|
ON_COMMAND(ID_FULLMDIMAXIMIZED, OnFullMdiMaximized)
|
|
ON_UPDATE_COMMAND_UI(ID_FULLMDIMAXIMIZED, OnUpdateFullMdiMaximized)
|
|
ON_WM_GETMINMAXINFO()
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CChildFrame construction/destruction
|
|
|
|
CChildFrame::CChildFrame()
|
|
: m_fFullMdiMax(TRUE)
|
|
{
|
|
}
|
|
|
|
CChildFrame::~CChildFrame()
|
|
{
|
|
}
|
|
|
|
BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
|
|
{
|
|
if( !CMDIChildWnd::PreCreateWindow(cs) )
|
|
return FALSE;
|
|
|
|
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
|
|
cs.lpszClass = AfxRegisterWndClass(0);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CChildFrame diagnostics
|
|
|
|
#ifdef _DEBUG
|
|
void CChildFrame::AssertValid() const
|
|
{
|
|
CMDIChildWnd::AssertValid();
|
|
}
|
|
|
|
void CChildFrame::Dump(CDumpContext& dc) const
|
|
{
|
|
CMDIChildWnd::Dump(dc);
|
|
}
|
|
|
|
#endif //_DEBUG
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CChildFrame message handlers
|
|
void CChildFrame::OnFileClose()
|
|
{
|
|
|
|
SendMessage(WM_CLOSE);
|
|
}
|
|
|
|
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
|
{
|
|
if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
|
|
return -1;
|
|
|
|
// create a view to occupy the client area of the frame
|
|
if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
|
|
CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
|
|
{
|
|
TRACE0("Failed to create view window\n");
|
|
return -1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
void CChildFrame::OnSetFocus(CWnd* pOldWnd)
|
|
{
|
|
CMDIChildWnd::OnSetFocus(pOldWnd);
|
|
|
|
m_wndView.SetFocus();
|
|
}
|
|
|
|
BOOL CChildFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
|
|
{
|
|
// let the view have first crack at the command
|
|
if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
|
|
return TRUE;
|
|
|
|
// otherwise, do default handling
|
|
return CMDIChildWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
|
|
}
|
|
|
|
|
|
void CChildFrame::OnFullMdiMaximized()
|
|
{
|
|
m_fFullMdiMax = !m_fFullMdiMax;
|
|
}
|
|
|
|
void CChildFrame::OnUpdateFullMdiMaximized(CCmdUI* pCmdUI)
|
|
{
|
|
pCmdUI->SetCheck( m_fFullMdiMax );
|
|
}
|
|
|
|
void CChildFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
|
|
{
|
|
CMDIChildWnd::OnGetMinMaxInfo(lpMMI);
|
|
|
|
if( !m_fFullMdiMax )
|
|
{
|
|
CWnd* pParent = GetParent();
|
|
if( pParent )
|
|
{
|
|
RECT rc;
|
|
pParent->GetClientRect( &rc );
|
|
|
|
lpMMI->ptMaxTrackSize.x = (rc.right - rc.left)/2;
|
|
lpMMI->ptMaxTrackSize.y = (rc.bottom - rc.top)/2;
|
|
}
|
|
}
|
|
}
|