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

📄 container.cpp

📁 模拟电子课程的教学演示程序
💻 CPP
字号:
// Container.cpp : implementation file
//

#include "stdafx.h"
#include "elecdemo.h"
#include "Container.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CContainer

CContainer::CContainer()
{
	m_bFirst=FALSE;
}

CContainer::~CContainer()
{
	m_containWnds.RemoveAll();
}


BEGIN_MESSAGE_MAP(CContainer, CButton)
	//{{AFX_MSG_MAP(CContainer)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CContainer message handlers
BOOL CContainer::MoveWindow(int x,int y,BOOL bRepaint)
{
	if(!m_bFirst)
	{
		GetContainCtrl();
		ShowWindow(SW_HIDE);
	}
	CRect rect=m_rcContain;
	int xDelt=x-rect.left;
	int yDelt=y-rect.top;

	for(int i=0;i<m_containWnds.GetSize();i++)
	{
		CWnd*pWnd=(CWnd*)m_containWnds.GetAt(i);
		CRect rc;
		pWnd->GetWindowRect(&rc);
//		pWnd->ClientToScreen(&rc);
		int w=rc.Width();
		int h=rc.Height();
		rc.left+=xDelt;
		rc.right=rc.left+w;
		rc.top+=yDelt;
		rc.bottom=rc.top+h;
		pWnd->MoveWindow(rc,bRepaint);
	}
	
	return ::MoveWindow(this->GetSafeHwnd(),x,y,rect.Width(),rect.Height(),bRepaint);
	
}
void CContainer::CenterWindow()
{
/*	CRect rcParent;
	GetParent()->GetWindowRect(rcParent);
	int x=(rcParent.Width()-m_rcContain.Width())/2;
	int y=(rcParent.Height()-m_rcContain.Height())/2;
	MoveWindow(x,y);*/
}
void CContainer::GetContainCtrl()
{
	m_bFirst=TRUE;
	CWnd*m_pCtrls=GetParent()->GetWindow(GW_CHILD);
	while(m_pCtrls)
	{
		GetWindowRect(&m_rcContain);
		CRect rect;
		//这个控件在Group的范围之内
		m_pCtrls->GetWindowRect(&rect);
		if(rect.left>m_rcContain.left&&rect.right<m_rcContain.right&&
			rect.top>m_rcContain.top&&rect.bottom<m_rcContain.bottom)
		{
			m_containWnds.Add(m_pCtrls);
		}
		m_pCtrls = m_pCtrls->GetWindow (GW_HWNDNEXT);
	}
}

⌨️ 快捷键说明

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