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

📄 tabctrlex.cpp

📁 酒店管理系统 1.先建立数据库HOTEL 2.选中HOTEL数据库
💻 CPP
字号:
// TabCtrlEx.cpp : implementation file
//

#include "stdafx.h"
#include "TabCtrlEx.h"

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

/////////////////////////////////////////////////////////////////////////////
// CTabCtrlEx

CTabCtrlEx::CTabCtrlEx()
{
	m_pwndFrame1 = NULL;
	m_pwndFrame2 = NULL;
	m_pwndFrame3 = NULL;
	m_pwndFrame4 = NULL;
	m_pwndFrame5 = NULL;
}

CTabCtrlEx::~CTabCtrlEx()
{
}


BEGIN_MESSAGE_MAP(CTabCtrlEx, CTabCtrl)
	//{{AFX_MSG_MAP(CTabCtrlEx)
	ON_WM_CREATE()
	ON_WM_SIZE()
	ON_NOTIFY_REFLECT(TCN_SELCHANGE, OnSelchange)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTabCtrlEx message handlers

int CTabCtrlEx::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CTabCtrl::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here
	m_pwndFrame1 = new CUserOrderFrame;
	m_pwndFrame1->Create(NULL, "客户预订", WS_CHILD|WS_VISIBLE, CRect(), this);
	
	m_pwndFrame2=new CUserRegFrame;
	m_pwndFrame2->Create(NULL,"客户登记",WS_CHILD,CRect(),this);

	m_pwndFrame3=new CQueryEmptyFrame;
	m_pwndFrame3->Create(NULL,"空房查询",WS_CHILD,CRect(),this);

	m_pwndFrame4=new CServiceRegFrame;
	m_pwndFrame4->Create(NULL,"服务登记",WS_CHILD,CRect(),this);

	m_pwndFrame5=new CCheckOutFrame;
	m_pwndFrame5->Create(NULL,"用户结帐",WS_CHILD,CRect(),this);

	return 0;
}

void CTabCtrlEx::OnSize(UINT nType, int cx, int cy) 
{
	CTabCtrl::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here
	if (m_pwndFrame1->GetSafeHwnd())
	{
		CRect rc;
		GetWindowRect(&rc);
		ScreenToClient(&rc);
		rc.top += 20;
		rc.DeflateRect(5,5);

		m_pwndFrame1->MoveWindow(rc);
	}

	if (m_pwndFrame2->GetSafeHwnd())
	{
		CRect rc;
		GetWindowRect(&rc);
		ScreenToClient(&rc);
		rc.top += 20;
		rc.DeflateRect(5,5);

		m_pwndFrame2->MoveWindow(rc);
	}

	if (m_pwndFrame3->GetSafeHwnd())
	{
		CRect rc;
		GetWindowRect(&rc);
		ScreenToClient(&rc);
		rc.top += 20;
		rc.DeflateRect(5,5);

		m_pwndFrame3->MoveWindow(rc);
	}

	if (m_pwndFrame4->GetSafeHwnd())
	{
		CRect rc;
		GetWindowRect(&rc);
		ScreenToClient(&rc);
		rc.top += 20;
		rc.DeflateRect(5,5);

		m_pwndFrame4->MoveWindow(rc);
	}

	if (m_pwndFrame5->GetSafeHwnd())
	{
		CRect rc;
		GetWindowRect(&rc);
		ScreenToClient(&rc);
		rc.top += 20;
		rc.DeflateRect(5,5);

		m_pwndFrame5->MoveWindow(rc);
	}
}

void CTabCtrlEx::OnSelchange(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	int nSel = GetCurSel();

	if(m_pwndFrame1)
		m_pwndFrame1->ShowWindow(nSel==0?SW_SHOW:SW_HIDE);
	
	if(m_pwndFrame2)
		m_pwndFrame2->ShowWindow(nSel==1?SW_SHOW:SW_HIDE);

	if(m_pwndFrame3)
		m_pwndFrame3->ShowWindow(nSel==2?SW_SHOW:SW_HIDE);

	if(m_pwndFrame4)
		m_pwndFrame4->ShowWindow(nSel==3?SW_SHOW:SW_HIDE);

	if(m_pwndFrame5)
		m_pwndFrame5->ShowWindow(nSel==4?SW_SHOW:SW_HIDE);

	*pResult = 0;
}

void CTabCtrlEx::OnPaint() 
{
	// TODO: Add your message handler code here
	ASSERT(GetItemCount()>0);

	//以下代码不是很规范
	//目的:防止在缩放窗体的时候有闪烁现象

	if (GetCurSel() == 0)
	{
		CPaintDC dc(this); // device context for painting
		
		CRect rc;
		GetClientRect(&rc);
		
		CRgn rgnAll;
		rgnAll.CreateRectRgnIndirect(rc);

		CRect rcHead;
		GetItemRect(0, rcHead);
		CRect rcMid = rc;
		rcMid.DeflateRect(5,5);
		rcMid.top = rcHead.bottom+5;

		CRgn rgnMid;
		rgnMid.CreateRectRgnIndirect(rcMid);

		CRgn rgnUpdate;
		rgnUpdate.CreateRectRgn(0,0,1,1);
		rgnUpdate.CombineRgn(&rgnAll, &rgnMid, RGN_XOR);
		
		rgnAll.DeleteObject();
		rgnMid.DeleteObject();

		dc.SelectClipRgn(&rgnUpdate);
		DefWindowProc(WM_PAINT, (WPARAM)dc.m_hDC, 0);

		rgnUpdate.DeleteObject();
	}
	else
		Default();

}

⌨️ 快捷键说明

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