www.gusucode.com > VC++编写的SQL服务端和客户端源码程序 > VC++编写的SQL服务端和客户端源码程序\code\Client\TabBar.cpp

    // TabBar.cpp : implementation file
// Download by http://www.NewXing.com

#include "stdafx.h"
#include "Client.h"
#include "TabBar.h"

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

/////////////////////////////////////////////////////////////////////////////
// CTabBar

CTabBar::CTabBar()
{
}

CTabBar::~CTabBar()
{
}


BEGIN_MESSAGE_MAP(CTabBar, CControlBar)
	//{{AFX_MSG_MAP(CTabBar)
	ON_WM_CREATE()
	ON_WM_WINDOWPOSCHANGED()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTabBar message handlers
void CTabBar::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos) 
{
	CControlBar::OnWindowPosChanged(lpwndpos);
	
	if (IsFloating()) {
		m_RichCtrl.MoveWindow( 5, 5, lpwndpos->cx-10, lpwndpos->cy-10 );
	}

	else if (IsHorzDocked()) {
		m_RichCtrl.MoveWindow( 17, 3, lpwndpos->cx-25, lpwndpos->cy-17 );
	}

	else {
		m_RichCtrl.MoveWindow( 3, 17, lpwndpos->cx-17, lpwndpos->cy-30 );
	}
}

int CTabBar::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CControlBar::OnCreate(lpCreateStruct) == -1)
		return -1;

	if( !m_RichCtrl.Create( WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL |
		ES_AUTOHSCROLL | ES_AUTOVSCROLL |  ES_MULTILINE |
		ES_LEFT | ES_READONLY, CRect(0,0,0,0), this ,1 ) )
	{
		TRACE0("Failed to create view for CTabBar\n");
		return -1;
	}

	m_RichCtrl.SetMenuID(IDR_RICH_POP);
	m_RichCtrl.ModifyStyleEx(0, WS_EX_CLIENTEDGE | WS_EX_WINDOWEDGE);

	m_RichCtrl.SetSel( -1, -1 );
	m_RichCtrl.ReplaceSel( " - - - - - - - - - - - - - - - - Configurations : miniSQL run-time report - - - - - - - - - - - - - - - - " );

	return 0;
}

void CTabBar::Clear()
{
	m_RichCtrl.SetSel( 0, -1 );
	m_RichCtrl.ReplaceSel( NULL );
	m_RichCtrl.SetSel( -1, -1 );
	m_RichCtrl.ReplaceSel( " - - - - - - - - - - - - - - - - Configurations : miniSQL run-time report - - - - - - - - - - - - - - - - " );
}

void CTabBar::InsertText( LPCTSTR text )
{
	m_RichCtrl.SetSel( -1, -1 );
	m_RichCtrl.ReplaceSel( "\n" );
	m_RichCtrl.ReplaceSel( text );
}