www.pudn.com > DiskInfo.tgz > SplitWnd.cpp


// SplitWnd.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "..\diskinfo.h" 
#include "splitwnd.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CSplitWnd 
 
CSplitWnd::CSplitWnd() 
{ 
	m_bVerticle = TRUE; 
	m_bDrawBorder = FALSE; 
} 
 
CSplitWnd::~CSplitWnd() 
{ 
} 
 
 
BEGIN_MESSAGE_MAP(CSplitWnd, CWnd) 
	//{{AFX_MSG_MAP(CSplitWnd) 
		// NOTE - the ClassWizard will add and remove mapping macros here. 
	//}}AFX_MSG_MAP 
	ON_MESSAGE(WM_ENTERSIZEMOVE,OnEnterSM) 
	ON_MESSAGE(WM_EXITSIZEMOVE,OnExitSM) 
	ON_WM_PAINT() 
	ON_WM_NCHITTEST() 
	ON_WM_CREATE() 
	ON_WM_MOVING() 
	ON_WM_SETCURSOR() 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CSplitWnd message handlers 
void CSplitWnd::OnPaint()  
{ 
	CPaintDC dc(this); // device context for painting 
 
	CRect rect; 
	GetClientRect(&rect); 
	 
	dc.FillSolidRect(rect, GetSysColor(COLOR_3DFACE)); 
 
	if (m_bDrawBorder) 
	{ 
		dc.DrawEdge(rect, BDR_RAISEDINNER, BF_RECT); 
	} 
	 
} 
 
UINT CSplitWnd::OnNcHitTest(CPoint point)  
{ 
	 
	return HTCAPTION; 
} 
 
 
 
int CSplitWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)  
{ 
	if (CWnd::OnCreate(lpCreateStruct) == -1) 
		return -1; 
	 
	GetWindowRect(&m_rect); 
	SetWindowPos(&CWnd::wndTop,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_DRAWFRAME); 
	 
	return 0; 
} 
 
void CSplitWnd::OnMoving(UINT fwSide, LPRECT pRect)  
{ 
	if (m_bVerticle) 
	{ 
		pRect->top = m_rect.top; 
		pRect->bottom = m_rect.bottom; 
	}else 
	{ 
		pRect->left = m_rect.left; 
		pRect->right = m_rect.right; 
	} 
 
	CWnd::OnMoving(fwSide, pRect); 
	// TODO: Add your message handler code here 
	 
} 
 
BOOL CSplitWnd::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)  
{ 
	//return CWnd::OnSetCursor(pWnd, /*nHitTest*/HTSIZE, message); 
	 
	if (m_bVerticle) 
		SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZEWE)); 
	else 
		SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZENS)); 
 
	return 0; 
} 
 
 
 
LRESULT CSplitWnd::OnEnterSM(WPARAM wp,LPARAM lp) 
{ 
	m_d=1; 
	GetWindowRect(&m_rect); 
	return Default(); 
} 
 
LRESULT CSplitWnd::OnExitSM(WPARAM wp,LPARAM lp) 
{ 
	GetParent()->SendMessage(WM_COMMAND,GetDlgCtrlID(),0); 
	m_d=0; 
	return Default(); 
} 
 
void CSplitWnd::EnableBorder(BOOL b) 
{ 
	m_bDrawBorder = b; 
}