⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 etslayout.cpp

📁 PC抄表软件, 用于降数据上载到PC机上, 通过USB传COM口实现.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
		}
		return;
	}
}
*/

void ETSLayoutFormView::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) 
{
	// To use this you'll have to modify your CMainFrame:
	//
	// 1) Add a handler for WM_GETMINMAXINFO()
	// 2) Let this handler be:
	// void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) 
	// {
	// 	CFrameWnd::OnGetMinMaxInfo(lpMMI);
	// 
	// 	if( GetActiveView() && GetActiveView()->IsKindOf( RUNTIME_CLASS(ETSLayoutFormView) ) ) {
	// 		GetActiveView()->SendMessage( WM_GETMINMAXINFO, 0, (LPARAM) lpMMI );
	// 	}
	// }
	// 3) Add "#include "dialogmgr.h" to MainFrm.cpp

	if(m_RootPane.IsValid()) {
		CRect rcClient = GetRect();

		CRect rcWnd;
		GetParent()->GetWindowRect(rcWnd);
	
		// How much do Window and Client differ
		rcWnd-=rcClient;

		// Take into account that there is a border around the rootPane
		lpMMI->ptMinTrackSize = CPoint(m_RootPane->getMinConstrainHorz() + rcWnd.Width() + 2*m_sizeRootBorders.cx,
			m_RootPane->getMinConstrainVert() + rcWnd.Height() + 2*m_sizeRootBorders.cy);

		int maxWidth = m_RootPane->getMaxConstrainHorz();
		int maxHeight = m_RootPane->getMaxConstrainVert();

		if( maxWidth != -1 ) {
			lpMMI->ptMaxTrackSize.x = maxWidth + rcWnd.Width()+ 2*m_sizeRootBorders.cx;
			lpMMI->ptMaxSize.x = maxWidth + rcWnd.Width()+ 2*m_sizeRootBorders.cx;
		}

		if( maxHeight != -1 ) {
			lpMMI->ptMaxTrackSize.y = maxHeight + rcWnd.Height() + 2*m_sizeRootBorders.cy;
			lpMMI->ptMaxSize.y = maxHeight + rcWnd.Height() + 2*m_sizeRootBorders.cy;
		}
	}
}

ETSLayoutFormView::~ETSLayoutFormView() 
{
	// Cleanup
}


/////////////////////////////////////////////////////////////////////////////
// ETSLayoutPropertyPage

#ifdef CS_HELP
	IMPLEMENT_DYNCREATE(ETSLayoutPropertyPage, ETSCSHelpPropPage)
#else
	IMPLEMENT_DYNCREATE(ETSLayoutPropertyPage, CPropertyPage)
#endif

#pragma warning(disable: 4355)
ETSLayoutPropertyPage::ETSLayoutPropertyPage( ) : ETSLayoutMgr( this )
{
	m_bLockMove = false;
}

ETSLayoutPropertyPage::ETSLayoutPropertyPage( UINT nIDTemplate, UINT nIDCaption /*= 0*/ )
	: CBasePropertyPage(nIDTemplate, nIDCaption), ETSLayoutMgr( this )
{
	m_bLockMove = false;
}

ETSLayoutPropertyPage::ETSLayoutPropertyPage( LPCTSTR lpszTemplateName, UINT nIDCaption /*= 0*/ )
	: CBasePropertyPage(lpszTemplateName, nIDCaption), ETSLayoutMgr( this )
{
	m_bLockMove = false;
}
#pragma warning(default: 4355)

ETSLayoutPropertyPage::~ETSLayoutPropertyPage()
{
}


BEGIN_MESSAGE_MAP(ETSLayoutPropertyPage, CBasePropertyPage)
	//{{AFX_MSG_MAP(ETSLayoutPropertyPage)
	ON_WM_SIZE()
	ON_WM_GETMINMAXINFO()
	ON_WM_ERASEBKGND()
	ON_WM_WINDOWPOSCHANGING()
	ON_WM_DESTROY()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// Behandlungsroutinen f黵 Nachrichten ETSLayoutPropertyPage 


void ETSLayoutPropertyPage::OnWindowPosChanging( WINDOWPOS* lpwndpos )
{
	// In WizardMode the System calls SetWindowPos with the 
	// original size at every activation. This could cause
	// some flicker in certain circumstances. Therefore we lock
	// moving the page and unlock it only if _we_ move the page
	if( m_bLockMove)
	{
		lpwndpos->flags |= SWP_NOMOVE | SWP_NOSIZE;
	}
	CBasePropertyPage::OnWindowPosChanging( lpwndpos );
}

BOOL ETSLayoutPropertyPage::OnEraseBkgnd(CDC* pDC) 
{
	EraseBkgnd(pDC);
	return true;
}

void ETSLayoutPropertyPage::OnDestroy() 
{
	// manually delete layout definition if object is reused
	m_RootPane = 0;

	CBasePropertyPage::OnDestroy();
}

void ETSLayoutPropertyPage::OnSize(UINT nType, int cx, int cy) 
{
	CBasePropertyPage::OnSize(nType, cx, cy);
	
	if( abs(cx) + abs(cy) > 0) 
	{
		// Re-Layout all controls
		UpdateLayout();
	}	
}

void ETSLayoutPropertyPage::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) 
{
	if(m_RootPane.IsValid()) {
		CRect rcClient = GetRect();

		CRect rcWnd;
		GetWindowRect(rcWnd);
		
		// How much do Window and Client differ
		int nDiffHorz = rcWnd.Width() - rcClient.Width();
		int nDiffVert = rcWnd.Height() - rcClient.Height();

		// Take into account that there is a border around the rootPane
		lpMMI->ptMinTrackSize = CPoint(m_RootPane->getMinConstrainHorz() + nDiffHorz + 2*m_sizeRootBorders.cx,
			m_RootPane->getMinConstrainVert() + nDiffVert + 2*m_sizeRootBorders.cy);

		int maxWidth = m_RootPane->getMaxConstrainHorz();
		int maxHeight = m_RootPane->getMaxConstrainVert();

		if( maxWidth != -1 ) {
			lpMMI->ptMaxTrackSize.x = maxWidth + nDiffHorz + 2*m_sizeRootBorders.cx;
			lpMMI->ptMaxSize.x = maxWidth + nDiffHorz + 2*m_sizeRootBorders.cx;
		}

		if( maxHeight != -1 ) {
			lpMMI->ptMaxTrackSize.y = maxHeight + nDiffVert + 2*m_sizeRootBorders.cy;
			lpMMI->ptMaxSize.y = maxHeight + nDiffVert + 2*m_sizeRootBorders.cy;
		}
	}
}


CRect ETSLayoutPropertyPage::GetRect() 
{ 
	CRect r; 
	GetClientRect(r);
	return r; 
}


BOOL ETSLayoutPropertyPage::OnInitDialog() 
{
	CBasePropertyPage::OnInitDialog();
	UpdateLayout();

	ETSLayoutPropertySheet* pSheet = (ETSLayoutPropertySheet*) GetParent();

	ASSERT_KINDOF( ETSLayoutPropertySheet, pSheet);
	if(pSheet)
	{
		if(pSheet->IsWizard())
		{
			m_bLockMove = true;
		}
	}

	return TRUE;
}

BOOL ETSLayoutPropertyPage::OnSetActive() 
{
	ETSLayoutPropertySheet* pSheet = (ETSLayoutPropertySheet*) GetParent();

	ASSERT_KINDOF( ETSLayoutPropertySheet, pSheet);
	if(pSheet)
	{
		if(pSheet->IsWizard())
		{
			// In WizardMode the System calls SetWindowPos with the 
			// original size on Page Activation. This will position the
			// page at the correct position
			m_bLockMove = false;
			MoveWindow(pSheet->m_rcPage);
			m_bLockMove = true;
		}
	}

	UpdateLayout();	

	return CBasePropertyPage::OnSetActive();
}

/////////////////////////////////////////////////////////////////////////////
// ETSLayoutPropertySheet

IMPLEMENT_DYNAMIC(ETSLayoutPropertySheet, CPropertySheet)

#pragma warning(disable: 4355)
ETSLayoutPropertySheet::ETSLayoutPropertySheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage, 
											   LPCTSTR strName /*=NULL*/, bool bGripper/*=true*/)
	: CPropertySheet(nIDCaption, pParentWnd, iSelectPage), ETSLayoutMgr( this )
{
	Init(strName, bGripper);
}

ETSLayoutPropertySheet::ETSLayoutPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage, 
											   LPCTSTR strName /*=NULL*/, bool bGripper/*=true*/)
	: CPropertySheet(pszCaption, pParentWnd, iSelectPage), ETSLayoutMgr( this )
{
	Init(strName, bGripper);
}
#pragma warning(default: 4355)

void ETSLayoutPropertySheet::Init(LPCTSTR strName, bool bGripper)
{
	m_bGripper	= bGripper;
	if(strName)
		m_strRegStore = strName;

	m_bAutoDestroy	= false;
	m_bAutoDestroyPages	= false;
	m_bModelessButtons = false;
}

ETSLayoutPropertySheet::~ETSLayoutPropertySheet()
{
}


BEGIN_MESSAGE_MAP(ETSLayoutPropertySheet, CPropertySheet)
	//{{AFX_MSG_MAP(ETSLayoutPropertySheet)
	ON_WM_CREATE()
	ON_WM_SIZE()
	ON_WM_GETMINMAXINFO()
	ON_WM_DESTROY()
	ON_WM_ERASEBKGND()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Behandlungsroutinen f黵 Nachrichten ETSLayoutPropertySheet 

BOOL ETSLayoutPropertySheet::OnEraseBkgnd(CDC* pDC) 
{
	EraseBkgnd(pDC);
	return true;
}


int ETSLayoutPropertySheet::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CPropertySheet::OnCreate(lpCreateStruct) == -1)
		return -1;

	ModifyStyle(0,WS_THICKFRAME| WS_SYSMENU |WS_CLIPCHILDREN);
	return 0;
}


void ETSLayoutPropertySheet::Resize(int cx, int cy)
{
	if( abs(cx) + abs(cy) > 0 && m_RootPane.IsValid() ) 
	{
		UpdateLayout();

		if(IsWizard())
		{
			// manual reposition of the FINISH button
			// can not be done with normaly layouting because it
			// shares position with the NEXT button
			CWnd *pWndFinish;
			pWndFinish=GetDlgItem(ID_WIZFINISH);

			if(pWndFinish)
			{
				CRect rcWnd;
				GetDlgItem(ID_WIZNEXT)->GetWindowRect(&rcWnd);
				ScreenToClient(&rcWnd);
				pWndFinish->MoveWindow(rcWnd);
				pWndFinish->RedrawWindow(0,0, RDW_INVALIDATE | RDW_UPDATENOW );
			}
		}

		// reposition Gripper
		if(m_bGripper)
			RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);

		CPropertyPage* pPage = (CPropertyPage*)GetActivePage();

		if(pPage)
		{
			CRect rcWnd;
			GetTabControl()->GetWindowRect(&rcWnd);
			ScreenToClient(&rcWnd);

			if(!IsWizard()) {
				// get inside of tab
				GetTabControl()->AdjustRect(FALSE, &rcWnd);
			}
			else
			{
				rcWnd.bottom += 5;
			}

			// we need this size in WizardMode in order to 
			// reposition newly activated page correctly
			m_rcPage = rcWnd;
			
			if( IsWizard() && pPage->IsKindOf(RUNTIME_CLASS(ETSLayoutPropertyPage)) )
			{
				ETSLayoutPropertyPage* pEtsPage = reinterpret_cast<ETSLayoutPropertyPage*>(pPage);

				pEtsPage->m_bLockMove = false;
				pEtsPage->MoveWindow(m_rcPage);
				pEtsPage->m_bLockMove = true;
			}
			else 
			{
				pPage->MoveWindow(m_rcPage);
			}
			
		}

		if(IsWindowVisible())
		{
			RedrawWindow(0,0, RDW_INVALIDATE|RDW_UPDATENOW );

			if(!IsWizard())
				GetTabControl()->RedrawWindow(0,0, RDW_INVALIDATE|RDW_UPDATENOW );
		}
	}
}

void ETSLayoutPropertySheet::OnSize(UINT nType, int cx, int cy) 
{
	CPropertySheet::OnSize(nType, cx, cy);
	Resize(cx,cy);
}

// IDs of all PropertySheet controls
long _PropertySheetIDs[] =
{
	ID_WIZBACK,
	ID_WIZNEXT, 
	IDOK, 
	IDCANCEL,
	ID_APPLY_NOW, 
	IDHELP
};


BOOL ETSLayoutPropertySheet::OnInitDialog() 
{
	BOOL bRet = CPropertySheet::OnInitDialog();

	ASSERT(!m_RootPane);

	// Save initial rect
	GetWindowRect(&m_rcStart);

	CPropertyPage* pPage = CPropertySheet::GetActivePage();
	ASSERT(pPage);

	CRect rcPage;
	pPage->GetClientRect(&rcPage);

	CreateRoot(VERTICAL);
	ASSERT(m_RootPane);

	// Add Tabcontrol to root pane
	m_ItemTab = item( GetTabControl(), GREEDY, 0, 0, 0, 0);
	m_RootPane <<  m_ItemTab;

	// Tabcontrol is invisible in WizardMode
	if(IsWizard())
	{
		GetTabControl()->ShowWindow(false);
	}

	// add horizontal line in WizardMode
	if(IsWizard() && GetDlgItem(ID_WIZFINISH+1))
	{
		m_RootPane << item(ID_WIZFINISH+1, ABSOLUTE_VERT, 0, 0, 0, 0);
	}

	if( IsWizard() || !m_bModeless || m_bModelessButtons )
	{
		// No spaces in WizardMode in order to keep BACK & NEXT together
		CPane bottomPane = pane(HORIZONTAL, ABSOLUTE_VERT, IsWizard() ? 0 : 5);

		// first item greedy to keep others right
		bottomPane->addItem (paneNull, GREEDY);


		// add all Controls to the layouting
		bool bFirst = true;
		for(int i = 0; i < (sizeof(_PropertySheetIDs) / sizeof(long)) ; i++)
		{
			CWnd* pWnd = GetDlgItem(_PropertySheetIDs[i]);

			if(pWnd)
			{

				if(!(m_psh.dwFlags & PSH_HASHELP) && _PropertySheetIDs[i] == IDHELP)
				{
					// don't insert
					continue;
				}

				if((m_psh.dwFlags & PSH_NOAPPLYNOW) && _PropertySheetIDs[i] == ID_APPLY_NOW)
				{
					// don't insert
					continue;
				}

				// space before first one and between BACK & NEXT
				if( IsWizard() )
				{
					if( !bFirst && !(_PropertySheetIDs[i]==ID_WIZNEXT) )
					{
						bottomPane->addItem(paneNull, NORESIZE,12,0,0,0);
					}
				}

				pWnd->ShowWindow(true);
				bottomPane->addItem(_PropertySheetIDs[i], NORESIZE);			
				bFirst = false;
			}
		}

		// add bottom (button) pane
		m_RootPane << bottomPane;
	}



	// some Space between Buttons und Gripper
	if(m_bGripper)
	{
		m_RootPane->addItem(paneNull, ABSOLUTE_VERT,0,2);

		if(m_StatusBar.Create(m_pWnd))
		{                           

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -