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

📄 split.cpp

📁 一个执行SYBASE SQL语言的工具示例源代码 功能特色 1 语法颜色显示 2 执行DDL语句 3 在执行SQL Select 语句时使用异步多线程处理方式
💻 CPP
字号:
// Split.cpp : implementation file
//

#include "stdafx.h"
#include "SYBTool.h"
#include "Split.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CPoint CToC( CWnd *C1, CWnd *C2 , CPoint &P );
/////////////////////////////////////////////////////////////////////////////
// CSplit

CSplit::CSplit()
{
}

CSplit::~CSplit()
{
}


BEGIN_MESSAGE_MAP(CSplit, CStatic)
	//{{AFX_MSG_MAP(CSplit)
	ON_WM_LBUTTONDOWN()
	ON_WM_LBUTTONUP()
	ON_WM_MOUSEMOVE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSplit message handlers

void CSplit::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	CStatic::OnLButtonDown(nFlags, point);
	BeginSizing();
	AfxMessageBox("ok");
}



void CSplit::OnLButtonUp(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	
	CStatic::OnLButtonUp(nFlags, point);
	if (Sizing) EndSizing() ; //若获得分隔线对象,结束移动
}

void CSplit::OnMouseMove(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	
	CStatic::OnMouseMove(nFlags, point);
	if (Sizing ) ChangeSizing(point.x, point.y);
}

void CSplit::GetComponents()
{ //{获得分隔线和目标实例}
}
bool CSplit::GetSizing()
{//判断分隔线状态
	return FSplitControl !=NULL;
}
void CSplit::DrawSizingLine()
 {
	CPoint P;
	P  = CToC(TForm, FSplitControl, FSplit);

	//while (Canvas )
	CPaintDC dc(this);
	dc.MoveTo(P.x, P.y);
	CRect rect;
	this->GetClientRect(&rect);

	if (FVertical )//{若为上下移动的分隔线,画横向阴影线}
		dc.LineTo(CToC(TForm, FSplitControl , CPoint( rect.Width() , 0)).x, P.y);

	else //{否则}

		dc.LineTo(P.x, CToC(TForm, FSplitControl, CPoint(0, rect.Height() )).y); //{画竖直的阴影线}

//画分隔线阴影
}

void CSplit::BeginSizing()
{//移动前初始化
	GetComponents();

	this->SetCapture(); //{使分隔线可接受鼠标事件}
	
	CRect rect;	
	FSplitControl->GetClientRect(&rect);
	
	if (FVertical ) //{获得分隔线的坐标}
		FSplit = CPoint(0, rect.top);
	else
		FSplit = CPoint(rect.left, 0);
 
	 //{设置画笔状态模式}
	CPen Pen;
 
	if (FVertical)
		Pen.CreatePen(PS_SOLID  , rect. Height(), RGB(255,255,255) ) ;
	else
		Pen.CreatePen(PS_SOLID  , rect. Width(), RGB(255,255,255) ); 

	//Pen.Mode := pmXOR;

	DrawSizingLine();

}

void CSplit::ChangeSizing( int X, int Y)
{//	改变分隔线位置
	DrawSizingLine();
	if ( FVertical ) 
		FSplit.y = Y ;
	else 
		FSplit.x = X; //{移动分隔线位置}
	DrawSizingLine();

}

void  CSplit::EndSizing()
{//终止移动
}

BOOL CSplit::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) 
{
	// TODO: Add your specialized code here and/or call the base class
	FAOwner = pParentWnd;
	TForm = pParentWnd; //{定义分隔线所在的窗口类}

	return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
}

CPoint CToC( CWnd *C1, CWnd *C2 , CPoint &P )
//转换分隔线坐标函数
{	CPoint P1;
	//将分隔线坐标转化为窗口坐标
	C2->ClientToScreen( &P);
	//C1.ScreenToClient(C2.ClientToScreen(P)); 
	C1->ScreenToClient( &P );
	return P;

}

⌨️ 快捷键说明

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