问题:
自己写了个基于对话框的拆分窗口,左边是ListCtrl控件,中间是Edit控件右边也是Edit的控件。就是把对话框3拆分了,
基本实现了功能,但是今天在测试的时候发现,当你不点击左边的ListCtrl里面的ITEM时,移动分割条没问题,但是点击了Item
就崩溃了。如果你这样操作,点了左边的ListCtrl中的Item在点击Edit(好像输入焦点切换后)再移动就没问题了。。。。自己想不明白,如果是输入焦点的问题,那Edit拥有输入焦点怎没就没问题呢?????
11 个解决方案
#1
崩溃的问题应该很好调试的,自己动手,你这样别人都是在猜测问题,是摸瞎子。
而且和你实现分割的方式有关
而且和你实现分割的方式有关
#2
可以Debug模式运行,然后点击出错的时候,看出错的地方,具体在哪...
#3
debug 模式下一切正常,不存在这个问题
#4
那你崩溃的时候,用编译器调试一下,查看一下Call stack等,看由什么触发的
#5
我是菜鸟,对vc的调试方法也不是很知道,SendMessage,
#6
#if !defined(AFX_SMYSPLLITER_H__DD921E3A_E889_4049_A786_71E75A4D44D0__INCLUDED_)
#define AFX_SMYSPLLITER_H__DD921E3A_E889_4049_A786_71E75A4D44D0__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// SMySplliter.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CSMySplliter window
#include "ResMessage.h"
#include"resource.h"
#include "MyView.h"
#include "SplliterBarWnd.h"
#include "vector"
using namespace std;
class CSMySplliter : public CWnd
{
public:
CSMySplliter();
virtual ~CSMySplliter();
private:
// enum{EditWnd=0,OpenFileEdit
// };
private:
// std::vector<CWnd *> m_pRightWndVector;
CWnd * m_pParentWnd;
CWnd * m_pLeftWnd;
CWnd * m_pRightWnd;
CWnd * m_pTopWnd;
CWnd * m_pBottomWnd;
CSplliterBarWnd * m_pVertSplliterWnd;
CWnd * m_pHorizeSplliterWnd;
private: //m_uSplliterBarWidth
UINT m_uSplliterBarWidth;
UINT m_uRightWndWidth;
UINT m_uLeftWndWidth;
UINT m_nID;
//记录水平或者分割条的矩形大小
CRect m_rcLeftWnd;
CRect m_rcRightWnd;
CRect m_rcVertSplliterBar;
CRect m_rcHorizSplliterBar;
//CPoint
private:
CPoint m_ptVertPrevious;
//标记是竖直还是水平分割
BOOL m_bIsVertSplliter;
BOOL m_bIsHorizSplliter;
//标记鼠标在分割条上并且按下了鼠标的左键
BOOL m_bDraggingVert;
BOOL m_bDraggingHoriz;
BOOL m_bIsMovingVertSplliterBar;
private:
CBrush m_brush;
CBitmap m_btmp;
public:
void Create(CWnd * pPaentWnd,DWORD dwStyle,CWnd *pLeftWnd,CWnd * pRigntWnd,
CRect &rect,UINT nId,UINT uLeftWndWidth=200,UINT uRightWndWidth=40);
public:
void CheckTheMousePoint(CPoint & point);
void AddRightWnd(CWnd * pWnd);
void SetVertSplliterRect(const CPoint &point);
void SetRightWndRect(const CPoint &point);
void SetLeftWndRect(const CPoint &point);
void ImplementMoveWindow();
void SetSplliterBarWndRect(CPoint & rect);
void SetSplliterBarWndRect(CRect & rect);
void SetBrush(UINT uRid);
void SetLeftWndWidth(CPoint & point);
void SetHorizSpillterBar();
void SetVertSplliterBarColor();
CPoint SetPointVert(CPoint & point);
void SetPoint(CPoint & point);
void SetVertConstraint(CPoint & point);
void AmendVertSplliterWidth(UINT & width);
void AmendHorizSplliterWidth(UINT &width);
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
//{{AFX_MSG(CSMySplliter)
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnMoverUserWindow(UINT nType=0,int cx=0, int cy=0);
afx_msg void OnDestroy();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SMYSPLLITER_H__DD921E3A_E889_4049_A786_71E75A4D44D0__INCLUDED_)
#define AFX_SMYSPLLITER_H__DD921E3A_E889_4049_A786_71E75A4D44D0__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// SMySplliter.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CSMySplliter window
#include "ResMessage.h"
#include"resource.h"
#include "MyView.h"
#include "SplliterBarWnd.h"
#include "vector"
using namespace std;
class CSMySplliter : public CWnd
{
public:
CSMySplliter();
virtual ~CSMySplliter();
private:
// enum{EditWnd=0,OpenFileEdit
// };
private:
// std::vector<CWnd *> m_pRightWndVector;
CWnd * m_pParentWnd;
CWnd * m_pLeftWnd;
CWnd * m_pRightWnd;
CWnd * m_pTopWnd;
CWnd * m_pBottomWnd;
CSplliterBarWnd * m_pVertSplliterWnd;
CWnd * m_pHorizeSplliterWnd;
private: //m_uSplliterBarWidth
UINT m_uSplliterBarWidth;
UINT m_uRightWndWidth;
UINT m_uLeftWndWidth;
UINT m_nID;
//记录水平或者分割条的矩形大小
CRect m_rcLeftWnd;
CRect m_rcRightWnd;
CRect m_rcVertSplliterBar;
CRect m_rcHorizSplliterBar;
//CPoint
private:
CPoint m_ptVertPrevious;
//标记是竖直还是水平分割
BOOL m_bIsVertSplliter;
BOOL m_bIsHorizSplliter;
//标记鼠标在分割条上并且按下了鼠标的左键
BOOL m_bDraggingVert;
BOOL m_bDraggingHoriz;
BOOL m_bIsMovingVertSplliterBar;
private:
CBrush m_brush;
CBitmap m_btmp;
public:
void Create(CWnd * pPaentWnd,DWORD dwStyle,CWnd *pLeftWnd,CWnd * pRigntWnd,
CRect &rect,UINT nId,UINT uLeftWndWidth=200,UINT uRightWndWidth=40);
public:
void CheckTheMousePoint(CPoint & point);
void AddRightWnd(CWnd * pWnd);
void SetVertSplliterRect(const CPoint &point);
void SetRightWndRect(const CPoint &point);
void SetLeftWndRect(const CPoint &point);
void ImplementMoveWindow();
void SetSplliterBarWndRect(CPoint & rect);
void SetSplliterBarWndRect(CRect & rect);
void SetBrush(UINT uRid);
void SetLeftWndWidth(CPoint & point);
void SetHorizSpillterBar();
void SetVertSplliterBarColor();
CPoint SetPointVert(CPoint & point);
void SetPoint(CPoint & point);
void SetVertConstraint(CPoint & point);
void AmendVertSplliterWidth(UINT & width);
void AmendHorizSplliterWidth(UINT &width);
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
//{{AFX_MSG(CSMySplliter)
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnMoverUserWindow(UINT nType=0,int cx=0, int cy=0);
afx_msg void OnDestroy();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SMYSPLLITER_H__DD921E3A_E889_4049_A786_71E75A4D44D0__INCLUDED_)
#7
// SMySplliter.cpp : implementation file
//
#include "stdafx.h"
//#include "CSDialog.h"
#include "SMySplliter.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSMySplliter
CSMySplliter::CSMySplliter()
{
m_pParentWnd=NULL;
m_pLeftWnd=NULL;
m_pRightWnd=NULL;
m_pTopWnd=NULL;
m_pBottomWnd=NULL;
m_bIsVertSplliter=FALSE;
m_bIsHorizSplliter=FALSE;
m_uSplliterBarWidth=3;
m_bDraggingVert=FALSE;
m_bDraggingHoriz=FALSE;
m_pVertSplliterWnd=NULL;
// m_pVertSplliterWnd=NULL;
// m_pHorizeSplliterWnd=NULL;
/*
CWnd * m_pParentWnd;
CWnd * m_pLeftWnd;
CWnd * m_pRightWnd;
CWnd * m_pTopWnd;
CWnd * m_pBottomWnd;
CSplliterBarWnd * m_pVertSplliterWnd;
CWnd * m_pHorizeSplliterWnd;
*/
}
CSMySplliter::~CSMySplliter()
{
delete m_pVertSplliterWnd;
}
//OnSize
//OnMoverUserWindow
BEGIN_MESSAGE_MAP(CSMySplliter, CWnd)
//{{AFX_MSG_MAP(CSMySplliter)
ON_WM_SIZE()
ON_WM_DESTROY()
ON_MESSAGE(WM_USER_MOVE_WINDOW,OnMoverUserWindow)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
void CSMySplliter:: Create(CWnd * pPaentWnd,DWORD dwStyle,CWnd *pLeftWnd,CWnd * pRigntWnd,
CRect &rect,UINT nId,UINT uLeftWndWidth,UINT uRightWndWidth)
{
m_pParentWnd=pPaentWnd;
m_nID = nId;
CWnd::Create(NULL,NULL,dwStyle,rect,pPaentWnd,nId);
CPoint InitPoint(350,0);
m_pLeftWnd=pLeftWnd;
m_pRightWnd=pRigntWnd;
ShowWindow(SW_SHOW);
pLeftWnd->SetOwner(pPaentWnd);
pRigntWnd->SetOwner(pPaentWnd);
if(dwStyle&SS_VERT){
CRect rect;
GetClientRect(rect);
m_pVertSplliterWnd=new(CSplliterBarWnd);
m_pVertSplliterWnd->Create(NULL,NULL,WS_CHILD,rect,this,SPLLITERBARID);
if(m_pVertSplliterWnd->GetSafeHwnd()){
m_pVertSplliterWnd->SetVertAttr(TRUE);
m_pVertSplliterWnd->SetSplliterVertBarWidth(m_uSplliterBarWidth);
}
SetLeftWndRect(InitPoint);
SetRightWndRect(InitPoint);
SetVertSplliterRect(InitPoint);
m_pVertSplliterWnd->SetOwner(this);
m_pVertSplliterWnd->ShowWindow(5);
m_pLeftWnd=pLeftWnd;
m_pRightWnd=pRigntWnd;
m_bIsVertSplliter=TRUE;
}
else if(dwStyle&SS_HORIZ){
m_pTopWnd=pLeftWnd;
m_pBottomWnd=pRigntWnd;
m_bIsHorizSplliter=TRUE;
}
ImplementMoveWindow();
}
BOOL CSMySplliter::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style|=SS_NOTIFY; // to notify its parent of mouse events
return CWnd::PreCreateWindow(cs);
}
void CSMySplliter::AmendVertSplliterWidth(UINT &width)
{
CDC dc;
}
void CSMySplliter::AmendHorizSplliterWidth(UINT &width)
{
// m_ucHorizSplitterWidth=width;
}
void CSMySplliter::SetPoint(CPoint &point)
{
CRect rect;
GetClientRect(&rect);
if(point.x>rect.right)
point.x=rect.right-m_uSplliterBarWidth;
if(point.x<rect.left)
point.x=rect.left+m_uSplliterBarWidth;
}
CPoint CSMySplliter::SetPointVert(CPoint &point)
{
return CPoint(point.x,0);
}
BOOL CSMySplliter::PreTranslateMessage(MSG* pMsg)
{
return CWnd::PreTranslateMessage(pMsg);
}
void CSMySplliter::SetVertSplliterBarColor()
{
}
void CSMySplliter::SetHorizSpillterBar()
{
}
void CSMySplliter::OnSize(UINT nType, int cx, int cy)
{
CRect rect;
m_pParentWnd->GetClientRect(&rect);
MoveWindow(&rect);
CPoint pt(m_rcLeftWnd.right,0);
CheckTheMousePoint(pt);
if(m_pVertSplliterWnd){
SetLeftWndRect(pt);
SetRightWndRect(pt);
SetVertSplliterRect(pt);
}
ImplementMoveWindow();
}
void CSMySplliter::OnDestroy()
{
}
void CSMySplliter::SetLeftWndWidth(CPoint &point)
{
m_uLeftWndWidth=point.x;
}
void CSMySplliter::SetBrush(UINT uRid)
{
m_btmp.LoadBitmap(IDB_VertSplliterBar);
CBrush old;
m_brush.CreatePatternBrush(&m_btmp);
}
void CSMySplliter::SetSplliterBarWndRect(CRect &rect)
{
m_rcVertSplliterBar=rect;
}
void CSMySplliter::SetSplliterBarWndRect(CPoint &rect)
{
}
void CSMySplliter::OnMoverUserWindow(UINT nType,int cx, int cy)
{
CPoint point(cx,cy);
GetCursorPos(&point);
ScreenToClient(&point);
CRect rect;
GetClientRect(&rect);
rect.left=point.x;
point.y=0;
CheckTheMousePoint(point);
SetLeftWndRect(point);
SetRightWndRect(point);
SetVertSplliterRect(point);
// MessageBox("CSMySplliter::OnMoverUserWindow");
ImplementMoveWindow();
}
void CSMySplliter::ImplementMoveWindow()
{
// MessageBox("CSMySplliter::ImplementMoveWindow()");
if(m_pLeftWnd->GetSafeHwnd()){
m_pLeftWnd->MoveWindow(&m_rcLeftWnd);
// MessageBox("MoveWindow");
}
if(m_pVertSplliterWnd->GetSafeHwnd()){
m_pVertSplliterWnd->MoveWindow(&m_rcHorizSplliterBar);
}
if(m_pRightWnd->GetSafeHwnd()){
m_pRightWnd->MoveWindow(&m_rcRightWnd);
}
}
void CSMySplliter::SetLeftWndRect(const CPoint &point)
{
CRect rect;
GetClientRect(&rect);
m_rcLeftWnd=CRect(rect.left,rect.top,point.x,rect.bottom);
}
void CSMySplliter::SetVertSplliterRect(const CPoint &point)
{
m_rcHorizSplliterBar=CRect(point.x,m_rcLeftWnd.top,m_pVertSplliterWnd->GetSplliterVertBarWitdh()+point.x,
m_rcLeftWnd.bottom);
}
void CSMySplliter::SetRightWndRect(const CPoint &point)
{
CRect rect;
GetClientRect(&rect);
m_rcRightWnd=CRect(point.x+m_pVertSplliterWnd->GetSplliterVertBarWitdh()+1,m_rcLeftWnd.top,
rect.right,rect.bottom);
}
void CSMySplliter::AddRightWnd(CWnd *pWnd)
{
}
void CSMySplliter::CheckTheMousePoint(CPoint &point)
{
CRect rect;
GetClientRect(&rect);
if(point.x>rect.right){
point.x=rect.right-m_pVertSplliterWnd->GetSplliterVertBarWitdh();
}
if(point.x<rect.left){
point.x=rect.left;
}
}
//
#include "stdafx.h"
//#include "CSDialog.h"
#include "SMySplliter.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSMySplliter
CSMySplliter::CSMySplliter()
{
m_pParentWnd=NULL;
m_pLeftWnd=NULL;
m_pRightWnd=NULL;
m_pTopWnd=NULL;
m_pBottomWnd=NULL;
m_bIsVertSplliter=FALSE;
m_bIsHorizSplliter=FALSE;
m_uSplliterBarWidth=3;
m_bDraggingVert=FALSE;
m_bDraggingHoriz=FALSE;
m_pVertSplliterWnd=NULL;
// m_pVertSplliterWnd=NULL;
// m_pHorizeSplliterWnd=NULL;
/*
CWnd * m_pParentWnd;
CWnd * m_pLeftWnd;
CWnd * m_pRightWnd;
CWnd * m_pTopWnd;
CWnd * m_pBottomWnd;
CSplliterBarWnd * m_pVertSplliterWnd;
CWnd * m_pHorizeSplliterWnd;
*/
}
CSMySplliter::~CSMySplliter()
{
delete m_pVertSplliterWnd;
}
//OnSize
//OnMoverUserWindow
BEGIN_MESSAGE_MAP(CSMySplliter, CWnd)
//{{AFX_MSG_MAP(CSMySplliter)
ON_WM_SIZE()
ON_WM_DESTROY()
ON_MESSAGE(WM_USER_MOVE_WINDOW,OnMoverUserWindow)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
void CSMySplliter:: Create(CWnd * pPaentWnd,DWORD dwStyle,CWnd *pLeftWnd,CWnd * pRigntWnd,
CRect &rect,UINT nId,UINT uLeftWndWidth,UINT uRightWndWidth)
{
m_pParentWnd=pPaentWnd;
m_nID = nId;
CWnd::Create(NULL,NULL,dwStyle,rect,pPaentWnd,nId);
CPoint InitPoint(350,0);
m_pLeftWnd=pLeftWnd;
m_pRightWnd=pRigntWnd;
ShowWindow(SW_SHOW);
pLeftWnd->SetOwner(pPaentWnd);
pRigntWnd->SetOwner(pPaentWnd);
if(dwStyle&SS_VERT){
CRect rect;
GetClientRect(rect);
m_pVertSplliterWnd=new(CSplliterBarWnd);
m_pVertSplliterWnd->Create(NULL,NULL,WS_CHILD,rect,this,SPLLITERBARID);
if(m_pVertSplliterWnd->GetSafeHwnd()){
m_pVertSplliterWnd->SetVertAttr(TRUE);
m_pVertSplliterWnd->SetSplliterVertBarWidth(m_uSplliterBarWidth);
}
SetLeftWndRect(InitPoint);
SetRightWndRect(InitPoint);
SetVertSplliterRect(InitPoint);
m_pVertSplliterWnd->SetOwner(this);
m_pVertSplliterWnd->ShowWindow(5);
m_pLeftWnd=pLeftWnd;
m_pRightWnd=pRigntWnd;
m_bIsVertSplliter=TRUE;
}
else if(dwStyle&SS_HORIZ){
m_pTopWnd=pLeftWnd;
m_pBottomWnd=pRigntWnd;
m_bIsHorizSplliter=TRUE;
}
ImplementMoveWindow();
}
BOOL CSMySplliter::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style|=SS_NOTIFY; // to notify its parent of mouse events
return CWnd::PreCreateWindow(cs);
}
void CSMySplliter::AmendVertSplliterWidth(UINT &width)
{
CDC dc;
}
void CSMySplliter::AmendHorizSplliterWidth(UINT &width)
{
// m_ucHorizSplitterWidth=width;
}
void CSMySplliter::SetPoint(CPoint &point)
{
CRect rect;
GetClientRect(&rect);
if(point.x>rect.right)
point.x=rect.right-m_uSplliterBarWidth;
if(point.x<rect.left)
point.x=rect.left+m_uSplliterBarWidth;
}
CPoint CSMySplliter::SetPointVert(CPoint &point)
{
return CPoint(point.x,0);
}
BOOL CSMySplliter::PreTranslateMessage(MSG* pMsg)
{
return CWnd::PreTranslateMessage(pMsg);
}
void CSMySplliter::SetVertSplliterBarColor()
{
}
void CSMySplliter::SetHorizSpillterBar()
{
}
void CSMySplliter::OnSize(UINT nType, int cx, int cy)
{
CRect rect;
m_pParentWnd->GetClientRect(&rect);
MoveWindow(&rect);
CPoint pt(m_rcLeftWnd.right,0);
CheckTheMousePoint(pt);
if(m_pVertSplliterWnd){
SetLeftWndRect(pt);
SetRightWndRect(pt);
SetVertSplliterRect(pt);
}
ImplementMoveWindow();
}
void CSMySplliter::OnDestroy()
{
}
void CSMySplliter::SetLeftWndWidth(CPoint &point)
{
m_uLeftWndWidth=point.x;
}
void CSMySplliter::SetBrush(UINT uRid)
{
m_btmp.LoadBitmap(IDB_VertSplliterBar);
CBrush old;
m_brush.CreatePatternBrush(&m_btmp);
}
void CSMySplliter::SetSplliterBarWndRect(CRect &rect)
{
m_rcVertSplliterBar=rect;
}
void CSMySplliter::SetSplliterBarWndRect(CPoint &rect)
{
}
void CSMySplliter::OnMoverUserWindow(UINT nType,int cx, int cy)
{
CPoint point(cx,cy);
GetCursorPos(&point);
ScreenToClient(&point);
CRect rect;
GetClientRect(&rect);
rect.left=point.x;
point.y=0;
CheckTheMousePoint(point);
SetLeftWndRect(point);
SetRightWndRect(point);
SetVertSplliterRect(point);
// MessageBox("CSMySplliter::OnMoverUserWindow");
ImplementMoveWindow();
}
void CSMySplliter::ImplementMoveWindow()
{
// MessageBox("CSMySplliter::ImplementMoveWindow()");
if(m_pLeftWnd->GetSafeHwnd()){
m_pLeftWnd->MoveWindow(&m_rcLeftWnd);
// MessageBox("MoveWindow");
}
if(m_pVertSplliterWnd->GetSafeHwnd()){
m_pVertSplliterWnd->MoveWindow(&m_rcHorizSplliterBar);
}
if(m_pRightWnd->GetSafeHwnd()){
m_pRightWnd->MoveWindow(&m_rcRightWnd);
}
}
void CSMySplliter::SetLeftWndRect(const CPoint &point)
{
CRect rect;
GetClientRect(&rect);
m_rcLeftWnd=CRect(rect.left,rect.top,point.x,rect.bottom);
}
void CSMySplliter::SetVertSplliterRect(const CPoint &point)
{
m_rcHorizSplliterBar=CRect(point.x,m_rcLeftWnd.top,m_pVertSplliterWnd->GetSplliterVertBarWitdh()+point.x,
m_rcLeftWnd.bottom);
}
void CSMySplliter::SetRightWndRect(const CPoint &point)
{
CRect rect;
GetClientRect(&rect);
m_rcRightWnd=CRect(point.x+m_pVertSplliterWnd->GetSplliterVertBarWitdh()+1,m_rcLeftWnd.top,
rect.right,rect.bottom);
}
void CSMySplliter::AddRightWnd(CWnd *pWnd)
{
}
void CSMySplliter::CheckTheMousePoint(CPoint &point)
{
CRect rect;
GetClientRect(&rect);
if(point.x>rect.right){
point.x=rect.right-m_pVertSplliterWnd->GetSplliterVertBarWitdh();
}
if(point.x<rect.left){
point.x=rect.left;
}
}
#8
你响应了哪些消息?
出错对话框上有没有“重试”或者“中断”按钮?如果有,点击这两个按钮就可以调试。
出错对话框上有没有“重试”或者“中断”按钮?如果有,点击这两个按钮就可以调试。
#9
#if !defined(AFX_SPLLITERBARWND_H__A2ACF6BE_63A6_4BC7_942B_5FC4CA2DB453__INCLUDED_)
#define AFX_SPLLITERBARWND_H__A2ACF6BE_63A6_4BC7_942B_5FC4CA2DB453__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// SplliterBarWnd.h : header file
//
//#include "StdAfx.h"
/////////////////////////////////////////////////////////////////////////////
// CSplliterBarWnd window
#define WM_USER_MOVE_WINDOW (WM_USER+1000)
#define WM_USER_MOVE_BAR (WM_USER+1001)
class CSplliterBarWnd : public CWnd
{
// Construction
public:
CSplliterBarWnd();
// Attributes
public:
// Operations
public:
private:
CBitmap m_bitmap;
CBrush m_brush;
BOOL m_IsVertSplliter;
BOOL m_IsHorizSplliter;
UINT m_uSplliterVertBarWidth;
UINT m_uSplliterHorzBarWidth;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSplliterBarWnd)
//}}AFX_VIRTUAL
// Implementation
public:
BOOL m_bDragBar;
UINT GetSplliterHorzBarWidth();
UINT GetSplliterVertBarWitdh();
void SetSplliterHorBarWitdh(UINT width);
void SetSplliterVertBarWidth(UINT width);
void SetBkGround();
void SetBmap(UINT uRid);
void DrawBar();
void SetHorztAttr(BOOL flg);
void SetVertAttr(BOOL flg);
virtual ~CSplliterBarWnd();
// Generated message map functions
protected:
//{{AFX_MSG(CSplliterBarWnd)
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnPaint();
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SPLLITERBARWND_H__A2ACF6BE_63A6_4BC7_942B_5FC4CA2DB453__INCLUDED_)
#define AFX_SPLLITERBARWND_H__A2ACF6BE_63A6_4BC7_942B_5FC4CA2DB453__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// SplliterBarWnd.h : header file
//
//#include "StdAfx.h"
/////////////////////////////////////////////////////////////////////////////
// CSplliterBarWnd window
#define WM_USER_MOVE_WINDOW (WM_USER+1000)
#define WM_USER_MOVE_BAR (WM_USER+1001)
class CSplliterBarWnd : public CWnd
{
// Construction
public:
CSplliterBarWnd();
// Attributes
public:
// Operations
public:
private:
CBitmap m_bitmap;
CBrush m_brush;
BOOL m_IsVertSplliter;
BOOL m_IsHorizSplliter;
UINT m_uSplliterVertBarWidth;
UINT m_uSplliterHorzBarWidth;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSplliterBarWnd)
//}}AFX_VIRTUAL
// Implementation
public:
BOOL m_bDragBar;
UINT GetSplliterHorzBarWidth();
UINT GetSplliterVertBarWitdh();
void SetSplliterHorBarWitdh(UINT width);
void SetSplliterVertBarWidth(UINT width);
void SetBkGround();
void SetBmap(UINT uRid);
void DrawBar();
void SetHorztAttr(BOOL flg);
void SetVertAttr(BOOL flg);
virtual ~CSplliterBarWnd();
// Generated message map functions
protected:
//{{AFX_MSG(CSplliterBarWnd)
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnPaint();
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SPLLITERBARWND_H__A2ACF6BE_63A6_4BC7_942B_5FC4CA2DB453__INCLUDED_)
#10
// SplliterBarWnd.cpp : implementation file
//
#include "stdafx.h"
#include "01.h"
#include "SplliterBarWnd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSplliterBarWnd
CSplliterBarWnd::CSplliterBarWnd()
{
m_IsVertSplliter=FALSE;
m_IsHorizSplliter=FALSE;
m_bDragBar=FALSE;
SetBmap(1);
}
CSplliterBarWnd::~CSplliterBarWnd()
{
}
BEGIN_MESSAGE_MAP(CSplliterBarWnd, CWnd)
//{{AFX_MSG_MAP(CSplliterBarWnd)
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_PAINT()
ON_WM_SIZE()
ON_WM_ACTIVATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSplliterBarWnd message handlers
void CSplliterBarWnd::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if ( m_IsVertSplliter ){
::SetCursor( AfxGetApp()->LoadStandardCursor ((LPCTSTR)IDC_SIZEWE));
}
CWnd::OnMouseMove(nFlags, point);
}
void CSplliterBarWnd::SetVertAttr(BOOL flg)
{
m_IsVertSplliter=TRUE;
}
void CSplliterBarWnd::SetHorztAttr(BOOL flg)
{
m_IsHorizSplliter=TRUE;
}
void CSplliterBarWnd::OnLButtonDown(UINT nFlags, CPoint point)
{
CWnd::OnLButtonDown(nFlags, point);
if ( m_IsVertSplliter ){
::SetCursor( AfxGetApp()->LoadStandardCursor ((LPCTSTR)IDC_SIZEWE));
}
// OnSetCursor(this,0,0);
m_bDragBar=TRUE;
SetCapture();
DrawBar();
}
void CSplliterBarWnd::OnLButtonUp(UINT nFlags, CPoint point)
{
CDC *pDC;
pDC=GetDC();
CWnd::OnLButtonUp(nFlags, point);
CWnd * pParentWnd=NULL;
pParentWnd=GetParent();
m_bDragBar=FALSE;
::SendMessage(pParentWnd->m_hWnd,WM_USER_MOVE_WINDOW,point.x,point.y);
SendMessage(WM_PAINT);
ReleaseCapture();
}
void CSplliterBarWnd::DrawBar()
{
CRect rect;
GetClientRect(&rect);
CDC * pDc;
pDc=GetDC();
pDc->PatBlt(rect.left,rect.top,rect.Width(),rect.Height(),PATINVERT);
}
void CSplliterBarWnd ::SetBmap(UINT uRid)
{
m_bitmap.LoadBitmap(IDB_VertSplliterBar);
}
void CSplliterBarWnd::OnPaint()
{
CPaintDC dc(this); // device context for painting
SetBkGround();
}
void CSplliterBarWnd::SetBkGround()
{
CDC *pDC=GetDC(); // device context for painting
CRect rectbk;
GetClientRect(&rectbk);
pDC->FillSolidRect(rectbk,RGB(0,0,255));
CRect rectPanel;
CDC dcMen;
BITMAP stBitmap;
m_bitmap.GetObject(sizeof(BITMAP), &stBitmap);
CSize bmsize(stBitmap.bmWidth, stBitmap.bmHeight);
dcMen.CreateCompatibleDC(pDC);
CBitmap *pold=dcMen.SelectObject(&m_bitmap);
pDC->StretchBlt(rectbk.left,rectbk.top,rectbk.Width(),
rectbk.Height(),&dcMen,0,0,bmsize.cx,bmsize.cy,SRCCOPY);
dcMen.SelectObject(pold);
dcMen.DeleteDC();
}
void CSplliterBarWnd::OnSize(UINT nType, int cx, int cy)
{
CWnd::OnSize(nType, cx, cy);
CWnd * pParentWnd=GetParent();
CRect patentRect;
CRect rect;
GetClientRect(&rect);
pParentWnd->GetClientRect(&patentRect);
rect.bottom=patentRect.bottom;
}
void CSplliterBarWnd::SetSplliterVertBarWidth(UINT width)
{
m_uSplliterVertBarWidth=width;
}
void CSplliterBarWnd::SetSplliterHorBarWitdh(UINT width)
{
m_uSplliterHorzBarWidth=width;
}
UINT CSplliterBarWnd::GetSplliterVertBarWitdh()
{
return m_uSplliterVertBarWidth;
}
UINT CSplliterBarWnd::GetSplliterHorzBarWidth()
{
return m_uSplliterHorzBarWidth;
}
//
#include "stdafx.h"
#include "01.h"
#include "SplliterBarWnd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSplliterBarWnd
CSplliterBarWnd::CSplliterBarWnd()
{
m_IsVertSplliter=FALSE;
m_IsHorizSplliter=FALSE;
m_bDragBar=FALSE;
SetBmap(1);
}
CSplliterBarWnd::~CSplliterBarWnd()
{
}
BEGIN_MESSAGE_MAP(CSplliterBarWnd, CWnd)
//{{AFX_MSG_MAP(CSplliterBarWnd)
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_PAINT()
ON_WM_SIZE()
ON_WM_ACTIVATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSplliterBarWnd message handlers
void CSplliterBarWnd::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if ( m_IsVertSplliter ){
::SetCursor( AfxGetApp()->LoadStandardCursor ((LPCTSTR)IDC_SIZEWE));
}
CWnd::OnMouseMove(nFlags, point);
}
void CSplliterBarWnd::SetVertAttr(BOOL flg)
{
m_IsVertSplliter=TRUE;
}
void CSplliterBarWnd::SetHorztAttr(BOOL flg)
{
m_IsHorizSplliter=TRUE;
}
void CSplliterBarWnd::OnLButtonDown(UINT nFlags, CPoint point)
{
CWnd::OnLButtonDown(nFlags, point);
if ( m_IsVertSplliter ){
::SetCursor( AfxGetApp()->LoadStandardCursor ((LPCTSTR)IDC_SIZEWE));
}
// OnSetCursor(this,0,0);
m_bDragBar=TRUE;
SetCapture();
DrawBar();
}
void CSplliterBarWnd::OnLButtonUp(UINT nFlags, CPoint point)
{
CDC *pDC;
pDC=GetDC();
CWnd::OnLButtonUp(nFlags, point);
CWnd * pParentWnd=NULL;
pParentWnd=GetParent();
m_bDragBar=FALSE;
::SendMessage(pParentWnd->m_hWnd,WM_USER_MOVE_WINDOW,point.x,point.y);
SendMessage(WM_PAINT);
ReleaseCapture();
}
void CSplliterBarWnd::DrawBar()
{
CRect rect;
GetClientRect(&rect);
CDC * pDc;
pDc=GetDC();
pDc->PatBlt(rect.left,rect.top,rect.Width(),rect.Height(),PATINVERT);
}
void CSplliterBarWnd ::SetBmap(UINT uRid)
{
m_bitmap.LoadBitmap(IDB_VertSplliterBar);
}
void CSplliterBarWnd::OnPaint()
{
CPaintDC dc(this); // device context for painting
SetBkGround();
}
void CSplliterBarWnd::SetBkGround()
{
CDC *pDC=GetDC(); // device context for painting
CRect rectbk;
GetClientRect(&rectbk);
pDC->FillSolidRect(rectbk,RGB(0,0,255));
CRect rectPanel;
CDC dcMen;
BITMAP stBitmap;
m_bitmap.GetObject(sizeof(BITMAP), &stBitmap);
CSize bmsize(stBitmap.bmWidth, stBitmap.bmHeight);
dcMen.CreateCompatibleDC(pDC);
CBitmap *pold=dcMen.SelectObject(&m_bitmap);
pDC->StretchBlt(rectbk.left,rectbk.top,rectbk.Width(),
rectbk.Height(),&dcMen,0,0,bmsize.cx,bmsize.cy,SRCCOPY);
dcMen.SelectObject(pold);
dcMen.DeleteDC();
}
void CSplliterBarWnd::OnSize(UINT nType, int cx, int cy)
{
CWnd::OnSize(nType, cx, cy);
CWnd * pParentWnd=GetParent();
CRect patentRect;
CRect rect;
GetClientRect(&rect);
pParentWnd->GetClientRect(&patentRect);
rect.bottom=patentRect.bottom;
}
void CSplliterBarWnd::SetSplliterVertBarWidth(UINT width)
{
m_uSplliterVertBarWidth=width;
}
void CSplliterBarWnd::SetSplliterHorBarWitdh(UINT width)
{
m_uSplliterHorzBarWidth=width;
}
UINT CSplliterBarWnd::GetSplliterVertBarWitdh()
{
return m_uSplliterVertBarWidth;
}
UINT CSplliterBarWnd::GetSplliterHorzBarWidth()
{
return m_uSplliterHorzBarWidth;
}
#11
算了算了。。。谢谢,自己来吧。
#1
崩溃的问题应该很好调试的,自己动手,你这样别人都是在猜测问题,是摸瞎子。
而且和你实现分割的方式有关
而且和你实现分割的方式有关
#2
可以Debug模式运行,然后点击出错的时候,看出错的地方,具体在哪...
#3
debug 模式下一切正常,不存在这个问题
#4
那你崩溃的时候,用编译器调试一下,查看一下Call stack等,看由什么触发的
#5
我是菜鸟,对vc的调试方法也不是很知道,SendMessage,
#6
#if !defined(AFX_SMYSPLLITER_H__DD921E3A_E889_4049_A786_71E75A4D44D0__INCLUDED_)
#define AFX_SMYSPLLITER_H__DD921E3A_E889_4049_A786_71E75A4D44D0__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// SMySplliter.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CSMySplliter window
#include "ResMessage.h"
#include"resource.h"
#include "MyView.h"
#include "SplliterBarWnd.h"
#include "vector"
using namespace std;
class CSMySplliter : public CWnd
{
public:
CSMySplliter();
virtual ~CSMySplliter();
private:
// enum{EditWnd=0,OpenFileEdit
// };
private:
// std::vector<CWnd *> m_pRightWndVector;
CWnd * m_pParentWnd;
CWnd * m_pLeftWnd;
CWnd * m_pRightWnd;
CWnd * m_pTopWnd;
CWnd * m_pBottomWnd;
CSplliterBarWnd * m_pVertSplliterWnd;
CWnd * m_pHorizeSplliterWnd;
private: //m_uSplliterBarWidth
UINT m_uSplliterBarWidth;
UINT m_uRightWndWidth;
UINT m_uLeftWndWidth;
UINT m_nID;
//记录水平或者分割条的矩形大小
CRect m_rcLeftWnd;
CRect m_rcRightWnd;
CRect m_rcVertSplliterBar;
CRect m_rcHorizSplliterBar;
//CPoint
private:
CPoint m_ptVertPrevious;
//标记是竖直还是水平分割
BOOL m_bIsVertSplliter;
BOOL m_bIsHorizSplliter;
//标记鼠标在分割条上并且按下了鼠标的左键
BOOL m_bDraggingVert;
BOOL m_bDraggingHoriz;
BOOL m_bIsMovingVertSplliterBar;
private:
CBrush m_brush;
CBitmap m_btmp;
public:
void Create(CWnd * pPaentWnd,DWORD dwStyle,CWnd *pLeftWnd,CWnd * pRigntWnd,
CRect &rect,UINT nId,UINT uLeftWndWidth=200,UINT uRightWndWidth=40);
public:
void CheckTheMousePoint(CPoint & point);
void AddRightWnd(CWnd * pWnd);
void SetVertSplliterRect(const CPoint &point);
void SetRightWndRect(const CPoint &point);
void SetLeftWndRect(const CPoint &point);
void ImplementMoveWindow();
void SetSplliterBarWndRect(CPoint & rect);
void SetSplliterBarWndRect(CRect & rect);
void SetBrush(UINT uRid);
void SetLeftWndWidth(CPoint & point);
void SetHorizSpillterBar();
void SetVertSplliterBarColor();
CPoint SetPointVert(CPoint & point);
void SetPoint(CPoint & point);
void SetVertConstraint(CPoint & point);
void AmendVertSplliterWidth(UINT & width);
void AmendHorizSplliterWidth(UINT &width);
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
//{{AFX_MSG(CSMySplliter)
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnMoverUserWindow(UINT nType=0,int cx=0, int cy=0);
afx_msg void OnDestroy();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SMYSPLLITER_H__DD921E3A_E889_4049_A786_71E75A4D44D0__INCLUDED_)
#define AFX_SMYSPLLITER_H__DD921E3A_E889_4049_A786_71E75A4D44D0__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// SMySplliter.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CSMySplliter window
#include "ResMessage.h"
#include"resource.h"
#include "MyView.h"
#include "SplliterBarWnd.h"
#include "vector"
using namespace std;
class CSMySplliter : public CWnd
{
public:
CSMySplliter();
virtual ~CSMySplliter();
private:
// enum{EditWnd=0,OpenFileEdit
// };
private:
// std::vector<CWnd *> m_pRightWndVector;
CWnd * m_pParentWnd;
CWnd * m_pLeftWnd;
CWnd * m_pRightWnd;
CWnd * m_pTopWnd;
CWnd * m_pBottomWnd;
CSplliterBarWnd * m_pVertSplliterWnd;
CWnd * m_pHorizeSplliterWnd;
private: //m_uSplliterBarWidth
UINT m_uSplliterBarWidth;
UINT m_uRightWndWidth;
UINT m_uLeftWndWidth;
UINT m_nID;
//记录水平或者分割条的矩形大小
CRect m_rcLeftWnd;
CRect m_rcRightWnd;
CRect m_rcVertSplliterBar;
CRect m_rcHorizSplliterBar;
//CPoint
private:
CPoint m_ptVertPrevious;
//标记是竖直还是水平分割
BOOL m_bIsVertSplliter;
BOOL m_bIsHorizSplliter;
//标记鼠标在分割条上并且按下了鼠标的左键
BOOL m_bDraggingVert;
BOOL m_bDraggingHoriz;
BOOL m_bIsMovingVertSplliterBar;
private:
CBrush m_brush;
CBitmap m_btmp;
public:
void Create(CWnd * pPaentWnd,DWORD dwStyle,CWnd *pLeftWnd,CWnd * pRigntWnd,
CRect &rect,UINT nId,UINT uLeftWndWidth=200,UINT uRightWndWidth=40);
public:
void CheckTheMousePoint(CPoint & point);
void AddRightWnd(CWnd * pWnd);
void SetVertSplliterRect(const CPoint &point);
void SetRightWndRect(const CPoint &point);
void SetLeftWndRect(const CPoint &point);
void ImplementMoveWindow();
void SetSplliterBarWndRect(CPoint & rect);
void SetSplliterBarWndRect(CRect & rect);
void SetBrush(UINT uRid);
void SetLeftWndWidth(CPoint & point);
void SetHorizSpillterBar();
void SetVertSplliterBarColor();
CPoint SetPointVert(CPoint & point);
void SetPoint(CPoint & point);
void SetVertConstraint(CPoint & point);
void AmendVertSplliterWidth(UINT & width);
void AmendHorizSplliterWidth(UINT &width);
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
//{{AFX_MSG(CSMySplliter)
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnMoverUserWindow(UINT nType=0,int cx=0, int cy=0);
afx_msg void OnDestroy();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SMYSPLLITER_H__DD921E3A_E889_4049_A786_71E75A4D44D0__INCLUDED_)
#7
// SMySplliter.cpp : implementation file
//
#include "stdafx.h"
//#include "CSDialog.h"
#include "SMySplliter.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSMySplliter
CSMySplliter::CSMySplliter()
{
m_pParentWnd=NULL;
m_pLeftWnd=NULL;
m_pRightWnd=NULL;
m_pTopWnd=NULL;
m_pBottomWnd=NULL;
m_bIsVertSplliter=FALSE;
m_bIsHorizSplliter=FALSE;
m_uSplliterBarWidth=3;
m_bDraggingVert=FALSE;
m_bDraggingHoriz=FALSE;
m_pVertSplliterWnd=NULL;
// m_pVertSplliterWnd=NULL;
// m_pHorizeSplliterWnd=NULL;
/*
CWnd * m_pParentWnd;
CWnd * m_pLeftWnd;
CWnd * m_pRightWnd;
CWnd * m_pTopWnd;
CWnd * m_pBottomWnd;
CSplliterBarWnd * m_pVertSplliterWnd;
CWnd * m_pHorizeSplliterWnd;
*/
}
CSMySplliter::~CSMySplliter()
{
delete m_pVertSplliterWnd;
}
//OnSize
//OnMoverUserWindow
BEGIN_MESSAGE_MAP(CSMySplliter, CWnd)
//{{AFX_MSG_MAP(CSMySplliter)
ON_WM_SIZE()
ON_WM_DESTROY()
ON_MESSAGE(WM_USER_MOVE_WINDOW,OnMoverUserWindow)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
void CSMySplliter:: Create(CWnd * pPaentWnd,DWORD dwStyle,CWnd *pLeftWnd,CWnd * pRigntWnd,
CRect &rect,UINT nId,UINT uLeftWndWidth,UINT uRightWndWidth)
{
m_pParentWnd=pPaentWnd;
m_nID = nId;
CWnd::Create(NULL,NULL,dwStyle,rect,pPaentWnd,nId);
CPoint InitPoint(350,0);
m_pLeftWnd=pLeftWnd;
m_pRightWnd=pRigntWnd;
ShowWindow(SW_SHOW);
pLeftWnd->SetOwner(pPaentWnd);
pRigntWnd->SetOwner(pPaentWnd);
if(dwStyle&SS_VERT){
CRect rect;
GetClientRect(rect);
m_pVertSplliterWnd=new(CSplliterBarWnd);
m_pVertSplliterWnd->Create(NULL,NULL,WS_CHILD,rect,this,SPLLITERBARID);
if(m_pVertSplliterWnd->GetSafeHwnd()){
m_pVertSplliterWnd->SetVertAttr(TRUE);
m_pVertSplliterWnd->SetSplliterVertBarWidth(m_uSplliterBarWidth);
}
SetLeftWndRect(InitPoint);
SetRightWndRect(InitPoint);
SetVertSplliterRect(InitPoint);
m_pVertSplliterWnd->SetOwner(this);
m_pVertSplliterWnd->ShowWindow(5);
m_pLeftWnd=pLeftWnd;
m_pRightWnd=pRigntWnd;
m_bIsVertSplliter=TRUE;
}
else if(dwStyle&SS_HORIZ){
m_pTopWnd=pLeftWnd;
m_pBottomWnd=pRigntWnd;
m_bIsHorizSplliter=TRUE;
}
ImplementMoveWindow();
}
BOOL CSMySplliter::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style|=SS_NOTIFY; // to notify its parent of mouse events
return CWnd::PreCreateWindow(cs);
}
void CSMySplliter::AmendVertSplliterWidth(UINT &width)
{
CDC dc;
}
void CSMySplliter::AmendHorizSplliterWidth(UINT &width)
{
// m_ucHorizSplitterWidth=width;
}
void CSMySplliter::SetPoint(CPoint &point)
{
CRect rect;
GetClientRect(&rect);
if(point.x>rect.right)
point.x=rect.right-m_uSplliterBarWidth;
if(point.x<rect.left)
point.x=rect.left+m_uSplliterBarWidth;
}
CPoint CSMySplliter::SetPointVert(CPoint &point)
{
return CPoint(point.x,0);
}
BOOL CSMySplliter::PreTranslateMessage(MSG* pMsg)
{
return CWnd::PreTranslateMessage(pMsg);
}
void CSMySplliter::SetVertSplliterBarColor()
{
}
void CSMySplliter::SetHorizSpillterBar()
{
}
void CSMySplliter::OnSize(UINT nType, int cx, int cy)
{
CRect rect;
m_pParentWnd->GetClientRect(&rect);
MoveWindow(&rect);
CPoint pt(m_rcLeftWnd.right,0);
CheckTheMousePoint(pt);
if(m_pVertSplliterWnd){
SetLeftWndRect(pt);
SetRightWndRect(pt);
SetVertSplliterRect(pt);
}
ImplementMoveWindow();
}
void CSMySplliter::OnDestroy()
{
}
void CSMySplliter::SetLeftWndWidth(CPoint &point)
{
m_uLeftWndWidth=point.x;
}
void CSMySplliter::SetBrush(UINT uRid)
{
m_btmp.LoadBitmap(IDB_VertSplliterBar);
CBrush old;
m_brush.CreatePatternBrush(&m_btmp);
}
void CSMySplliter::SetSplliterBarWndRect(CRect &rect)
{
m_rcVertSplliterBar=rect;
}
void CSMySplliter::SetSplliterBarWndRect(CPoint &rect)
{
}
void CSMySplliter::OnMoverUserWindow(UINT nType,int cx, int cy)
{
CPoint point(cx,cy);
GetCursorPos(&point);
ScreenToClient(&point);
CRect rect;
GetClientRect(&rect);
rect.left=point.x;
point.y=0;
CheckTheMousePoint(point);
SetLeftWndRect(point);
SetRightWndRect(point);
SetVertSplliterRect(point);
// MessageBox("CSMySplliter::OnMoverUserWindow");
ImplementMoveWindow();
}
void CSMySplliter::ImplementMoveWindow()
{
// MessageBox("CSMySplliter::ImplementMoveWindow()");
if(m_pLeftWnd->GetSafeHwnd()){
m_pLeftWnd->MoveWindow(&m_rcLeftWnd);
// MessageBox("MoveWindow");
}
if(m_pVertSplliterWnd->GetSafeHwnd()){
m_pVertSplliterWnd->MoveWindow(&m_rcHorizSplliterBar);
}
if(m_pRightWnd->GetSafeHwnd()){
m_pRightWnd->MoveWindow(&m_rcRightWnd);
}
}
void CSMySplliter::SetLeftWndRect(const CPoint &point)
{
CRect rect;
GetClientRect(&rect);
m_rcLeftWnd=CRect(rect.left,rect.top,point.x,rect.bottom);
}
void CSMySplliter::SetVertSplliterRect(const CPoint &point)
{
m_rcHorizSplliterBar=CRect(point.x,m_rcLeftWnd.top,m_pVertSplliterWnd->GetSplliterVertBarWitdh()+point.x,
m_rcLeftWnd.bottom);
}
void CSMySplliter::SetRightWndRect(const CPoint &point)
{
CRect rect;
GetClientRect(&rect);
m_rcRightWnd=CRect(point.x+m_pVertSplliterWnd->GetSplliterVertBarWitdh()+1,m_rcLeftWnd.top,
rect.right,rect.bottom);
}
void CSMySplliter::AddRightWnd(CWnd *pWnd)
{
}
void CSMySplliter::CheckTheMousePoint(CPoint &point)
{
CRect rect;
GetClientRect(&rect);
if(point.x>rect.right){
point.x=rect.right-m_pVertSplliterWnd->GetSplliterVertBarWitdh();
}
if(point.x<rect.left){
point.x=rect.left;
}
}
//
#include "stdafx.h"
//#include "CSDialog.h"
#include "SMySplliter.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSMySplliter
CSMySplliter::CSMySplliter()
{
m_pParentWnd=NULL;
m_pLeftWnd=NULL;
m_pRightWnd=NULL;
m_pTopWnd=NULL;
m_pBottomWnd=NULL;
m_bIsVertSplliter=FALSE;
m_bIsHorizSplliter=FALSE;
m_uSplliterBarWidth=3;
m_bDraggingVert=FALSE;
m_bDraggingHoriz=FALSE;
m_pVertSplliterWnd=NULL;
// m_pVertSplliterWnd=NULL;
// m_pHorizeSplliterWnd=NULL;
/*
CWnd * m_pParentWnd;
CWnd * m_pLeftWnd;
CWnd * m_pRightWnd;
CWnd * m_pTopWnd;
CWnd * m_pBottomWnd;
CSplliterBarWnd * m_pVertSplliterWnd;
CWnd * m_pHorizeSplliterWnd;
*/
}
CSMySplliter::~CSMySplliter()
{
delete m_pVertSplliterWnd;
}
//OnSize
//OnMoverUserWindow
BEGIN_MESSAGE_MAP(CSMySplliter, CWnd)
//{{AFX_MSG_MAP(CSMySplliter)
ON_WM_SIZE()
ON_WM_DESTROY()
ON_MESSAGE(WM_USER_MOVE_WINDOW,OnMoverUserWindow)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
void CSMySplliter:: Create(CWnd * pPaentWnd,DWORD dwStyle,CWnd *pLeftWnd,CWnd * pRigntWnd,
CRect &rect,UINT nId,UINT uLeftWndWidth,UINT uRightWndWidth)
{
m_pParentWnd=pPaentWnd;
m_nID = nId;
CWnd::Create(NULL,NULL,dwStyle,rect,pPaentWnd,nId);
CPoint InitPoint(350,0);
m_pLeftWnd=pLeftWnd;
m_pRightWnd=pRigntWnd;
ShowWindow(SW_SHOW);
pLeftWnd->SetOwner(pPaentWnd);
pRigntWnd->SetOwner(pPaentWnd);
if(dwStyle&SS_VERT){
CRect rect;
GetClientRect(rect);
m_pVertSplliterWnd=new(CSplliterBarWnd);
m_pVertSplliterWnd->Create(NULL,NULL,WS_CHILD,rect,this,SPLLITERBARID);
if(m_pVertSplliterWnd->GetSafeHwnd()){
m_pVertSplliterWnd->SetVertAttr(TRUE);
m_pVertSplliterWnd->SetSplliterVertBarWidth(m_uSplliterBarWidth);
}
SetLeftWndRect(InitPoint);
SetRightWndRect(InitPoint);
SetVertSplliterRect(InitPoint);
m_pVertSplliterWnd->SetOwner(this);
m_pVertSplliterWnd->ShowWindow(5);
m_pLeftWnd=pLeftWnd;
m_pRightWnd=pRigntWnd;
m_bIsVertSplliter=TRUE;
}
else if(dwStyle&SS_HORIZ){
m_pTopWnd=pLeftWnd;
m_pBottomWnd=pRigntWnd;
m_bIsHorizSplliter=TRUE;
}
ImplementMoveWindow();
}
BOOL CSMySplliter::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style|=SS_NOTIFY; // to notify its parent of mouse events
return CWnd::PreCreateWindow(cs);
}
void CSMySplliter::AmendVertSplliterWidth(UINT &width)
{
CDC dc;
}
void CSMySplliter::AmendHorizSplliterWidth(UINT &width)
{
// m_ucHorizSplitterWidth=width;
}
void CSMySplliter::SetPoint(CPoint &point)
{
CRect rect;
GetClientRect(&rect);
if(point.x>rect.right)
point.x=rect.right-m_uSplliterBarWidth;
if(point.x<rect.left)
point.x=rect.left+m_uSplliterBarWidth;
}
CPoint CSMySplliter::SetPointVert(CPoint &point)
{
return CPoint(point.x,0);
}
BOOL CSMySplliter::PreTranslateMessage(MSG* pMsg)
{
return CWnd::PreTranslateMessage(pMsg);
}
void CSMySplliter::SetVertSplliterBarColor()
{
}
void CSMySplliter::SetHorizSpillterBar()
{
}
void CSMySplliter::OnSize(UINT nType, int cx, int cy)
{
CRect rect;
m_pParentWnd->GetClientRect(&rect);
MoveWindow(&rect);
CPoint pt(m_rcLeftWnd.right,0);
CheckTheMousePoint(pt);
if(m_pVertSplliterWnd){
SetLeftWndRect(pt);
SetRightWndRect(pt);
SetVertSplliterRect(pt);
}
ImplementMoveWindow();
}
void CSMySplliter::OnDestroy()
{
}
void CSMySplliter::SetLeftWndWidth(CPoint &point)
{
m_uLeftWndWidth=point.x;
}
void CSMySplliter::SetBrush(UINT uRid)
{
m_btmp.LoadBitmap(IDB_VertSplliterBar);
CBrush old;
m_brush.CreatePatternBrush(&m_btmp);
}
void CSMySplliter::SetSplliterBarWndRect(CRect &rect)
{
m_rcVertSplliterBar=rect;
}
void CSMySplliter::SetSplliterBarWndRect(CPoint &rect)
{
}
void CSMySplliter::OnMoverUserWindow(UINT nType,int cx, int cy)
{
CPoint point(cx,cy);
GetCursorPos(&point);
ScreenToClient(&point);
CRect rect;
GetClientRect(&rect);
rect.left=point.x;
point.y=0;
CheckTheMousePoint(point);
SetLeftWndRect(point);
SetRightWndRect(point);
SetVertSplliterRect(point);
// MessageBox("CSMySplliter::OnMoverUserWindow");
ImplementMoveWindow();
}
void CSMySplliter::ImplementMoveWindow()
{
// MessageBox("CSMySplliter::ImplementMoveWindow()");
if(m_pLeftWnd->GetSafeHwnd()){
m_pLeftWnd->MoveWindow(&m_rcLeftWnd);
// MessageBox("MoveWindow");
}
if(m_pVertSplliterWnd->GetSafeHwnd()){
m_pVertSplliterWnd->MoveWindow(&m_rcHorizSplliterBar);
}
if(m_pRightWnd->GetSafeHwnd()){
m_pRightWnd->MoveWindow(&m_rcRightWnd);
}
}
void CSMySplliter::SetLeftWndRect(const CPoint &point)
{
CRect rect;
GetClientRect(&rect);
m_rcLeftWnd=CRect(rect.left,rect.top,point.x,rect.bottom);
}
void CSMySplliter::SetVertSplliterRect(const CPoint &point)
{
m_rcHorizSplliterBar=CRect(point.x,m_rcLeftWnd.top,m_pVertSplliterWnd->GetSplliterVertBarWitdh()+point.x,
m_rcLeftWnd.bottom);
}
void CSMySplliter::SetRightWndRect(const CPoint &point)
{
CRect rect;
GetClientRect(&rect);
m_rcRightWnd=CRect(point.x+m_pVertSplliterWnd->GetSplliterVertBarWitdh()+1,m_rcLeftWnd.top,
rect.right,rect.bottom);
}
void CSMySplliter::AddRightWnd(CWnd *pWnd)
{
}
void CSMySplliter::CheckTheMousePoint(CPoint &point)
{
CRect rect;
GetClientRect(&rect);
if(point.x>rect.right){
point.x=rect.right-m_pVertSplliterWnd->GetSplliterVertBarWitdh();
}
if(point.x<rect.left){
point.x=rect.left;
}
}
#8
你响应了哪些消息?
出错对话框上有没有“重试”或者“中断”按钮?如果有,点击这两个按钮就可以调试。
出错对话框上有没有“重试”或者“中断”按钮?如果有,点击这两个按钮就可以调试。
#9
#if !defined(AFX_SPLLITERBARWND_H__A2ACF6BE_63A6_4BC7_942B_5FC4CA2DB453__INCLUDED_)
#define AFX_SPLLITERBARWND_H__A2ACF6BE_63A6_4BC7_942B_5FC4CA2DB453__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// SplliterBarWnd.h : header file
//
//#include "StdAfx.h"
/////////////////////////////////////////////////////////////////////////////
// CSplliterBarWnd window
#define WM_USER_MOVE_WINDOW (WM_USER+1000)
#define WM_USER_MOVE_BAR (WM_USER+1001)
class CSplliterBarWnd : public CWnd
{
// Construction
public:
CSplliterBarWnd();
// Attributes
public:
// Operations
public:
private:
CBitmap m_bitmap;
CBrush m_brush;
BOOL m_IsVertSplliter;
BOOL m_IsHorizSplliter;
UINT m_uSplliterVertBarWidth;
UINT m_uSplliterHorzBarWidth;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSplliterBarWnd)
//}}AFX_VIRTUAL
// Implementation
public:
BOOL m_bDragBar;
UINT GetSplliterHorzBarWidth();
UINT GetSplliterVertBarWitdh();
void SetSplliterHorBarWitdh(UINT width);
void SetSplliterVertBarWidth(UINT width);
void SetBkGround();
void SetBmap(UINT uRid);
void DrawBar();
void SetHorztAttr(BOOL flg);
void SetVertAttr(BOOL flg);
virtual ~CSplliterBarWnd();
// Generated message map functions
protected:
//{{AFX_MSG(CSplliterBarWnd)
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnPaint();
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SPLLITERBARWND_H__A2ACF6BE_63A6_4BC7_942B_5FC4CA2DB453__INCLUDED_)
#define AFX_SPLLITERBARWND_H__A2ACF6BE_63A6_4BC7_942B_5FC4CA2DB453__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// SplliterBarWnd.h : header file
//
//#include "StdAfx.h"
/////////////////////////////////////////////////////////////////////////////
// CSplliterBarWnd window
#define WM_USER_MOVE_WINDOW (WM_USER+1000)
#define WM_USER_MOVE_BAR (WM_USER+1001)
class CSplliterBarWnd : public CWnd
{
// Construction
public:
CSplliterBarWnd();
// Attributes
public:
// Operations
public:
private:
CBitmap m_bitmap;
CBrush m_brush;
BOOL m_IsVertSplliter;
BOOL m_IsHorizSplliter;
UINT m_uSplliterVertBarWidth;
UINT m_uSplliterHorzBarWidth;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSplliterBarWnd)
//}}AFX_VIRTUAL
// Implementation
public:
BOOL m_bDragBar;
UINT GetSplliterHorzBarWidth();
UINT GetSplliterVertBarWitdh();
void SetSplliterHorBarWitdh(UINT width);
void SetSplliterVertBarWidth(UINT width);
void SetBkGround();
void SetBmap(UINT uRid);
void DrawBar();
void SetHorztAttr(BOOL flg);
void SetVertAttr(BOOL flg);
virtual ~CSplliterBarWnd();
// Generated message map functions
protected:
//{{AFX_MSG(CSplliterBarWnd)
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnPaint();
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SPLLITERBARWND_H__A2ACF6BE_63A6_4BC7_942B_5FC4CA2DB453__INCLUDED_)
#10
// SplliterBarWnd.cpp : implementation file
//
#include "stdafx.h"
#include "01.h"
#include "SplliterBarWnd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSplliterBarWnd
CSplliterBarWnd::CSplliterBarWnd()
{
m_IsVertSplliter=FALSE;
m_IsHorizSplliter=FALSE;
m_bDragBar=FALSE;
SetBmap(1);
}
CSplliterBarWnd::~CSplliterBarWnd()
{
}
BEGIN_MESSAGE_MAP(CSplliterBarWnd, CWnd)
//{{AFX_MSG_MAP(CSplliterBarWnd)
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_PAINT()
ON_WM_SIZE()
ON_WM_ACTIVATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSplliterBarWnd message handlers
void CSplliterBarWnd::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if ( m_IsVertSplliter ){
::SetCursor( AfxGetApp()->LoadStandardCursor ((LPCTSTR)IDC_SIZEWE));
}
CWnd::OnMouseMove(nFlags, point);
}
void CSplliterBarWnd::SetVertAttr(BOOL flg)
{
m_IsVertSplliter=TRUE;
}
void CSplliterBarWnd::SetHorztAttr(BOOL flg)
{
m_IsHorizSplliter=TRUE;
}
void CSplliterBarWnd::OnLButtonDown(UINT nFlags, CPoint point)
{
CWnd::OnLButtonDown(nFlags, point);
if ( m_IsVertSplliter ){
::SetCursor( AfxGetApp()->LoadStandardCursor ((LPCTSTR)IDC_SIZEWE));
}
// OnSetCursor(this,0,0);
m_bDragBar=TRUE;
SetCapture();
DrawBar();
}
void CSplliterBarWnd::OnLButtonUp(UINT nFlags, CPoint point)
{
CDC *pDC;
pDC=GetDC();
CWnd::OnLButtonUp(nFlags, point);
CWnd * pParentWnd=NULL;
pParentWnd=GetParent();
m_bDragBar=FALSE;
::SendMessage(pParentWnd->m_hWnd,WM_USER_MOVE_WINDOW,point.x,point.y);
SendMessage(WM_PAINT);
ReleaseCapture();
}
void CSplliterBarWnd::DrawBar()
{
CRect rect;
GetClientRect(&rect);
CDC * pDc;
pDc=GetDC();
pDc->PatBlt(rect.left,rect.top,rect.Width(),rect.Height(),PATINVERT);
}
void CSplliterBarWnd ::SetBmap(UINT uRid)
{
m_bitmap.LoadBitmap(IDB_VertSplliterBar);
}
void CSplliterBarWnd::OnPaint()
{
CPaintDC dc(this); // device context for painting
SetBkGround();
}
void CSplliterBarWnd::SetBkGround()
{
CDC *pDC=GetDC(); // device context for painting
CRect rectbk;
GetClientRect(&rectbk);
pDC->FillSolidRect(rectbk,RGB(0,0,255));
CRect rectPanel;
CDC dcMen;
BITMAP stBitmap;
m_bitmap.GetObject(sizeof(BITMAP), &stBitmap);
CSize bmsize(stBitmap.bmWidth, stBitmap.bmHeight);
dcMen.CreateCompatibleDC(pDC);
CBitmap *pold=dcMen.SelectObject(&m_bitmap);
pDC->StretchBlt(rectbk.left,rectbk.top,rectbk.Width(),
rectbk.Height(),&dcMen,0,0,bmsize.cx,bmsize.cy,SRCCOPY);
dcMen.SelectObject(pold);
dcMen.DeleteDC();
}
void CSplliterBarWnd::OnSize(UINT nType, int cx, int cy)
{
CWnd::OnSize(nType, cx, cy);
CWnd * pParentWnd=GetParent();
CRect patentRect;
CRect rect;
GetClientRect(&rect);
pParentWnd->GetClientRect(&patentRect);
rect.bottom=patentRect.bottom;
}
void CSplliterBarWnd::SetSplliterVertBarWidth(UINT width)
{
m_uSplliterVertBarWidth=width;
}
void CSplliterBarWnd::SetSplliterHorBarWitdh(UINT width)
{
m_uSplliterHorzBarWidth=width;
}
UINT CSplliterBarWnd::GetSplliterVertBarWitdh()
{
return m_uSplliterVertBarWidth;
}
UINT CSplliterBarWnd::GetSplliterHorzBarWidth()
{
return m_uSplliterHorzBarWidth;
}
//
#include "stdafx.h"
#include "01.h"
#include "SplliterBarWnd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSplliterBarWnd
CSplliterBarWnd::CSplliterBarWnd()
{
m_IsVertSplliter=FALSE;
m_IsHorizSplliter=FALSE;
m_bDragBar=FALSE;
SetBmap(1);
}
CSplliterBarWnd::~CSplliterBarWnd()
{
}
BEGIN_MESSAGE_MAP(CSplliterBarWnd, CWnd)
//{{AFX_MSG_MAP(CSplliterBarWnd)
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_PAINT()
ON_WM_SIZE()
ON_WM_ACTIVATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSplliterBarWnd message handlers
void CSplliterBarWnd::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if ( m_IsVertSplliter ){
::SetCursor( AfxGetApp()->LoadStandardCursor ((LPCTSTR)IDC_SIZEWE));
}
CWnd::OnMouseMove(nFlags, point);
}
void CSplliterBarWnd::SetVertAttr(BOOL flg)
{
m_IsVertSplliter=TRUE;
}
void CSplliterBarWnd::SetHorztAttr(BOOL flg)
{
m_IsHorizSplliter=TRUE;
}
void CSplliterBarWnd::OnLButtonDown(UINT nFlags, CPoint point)
{
CWnd::OnLButtonDown(nFlags, point);
if ( m_IsVertSplliter ){
::SetCursor( AfxGetApp()->LoadStandardCursor ((LPCTSTR)IDC_SIZEWE));
}
// OnSetCursor(this,0,0);
m_bDragBar=TRUE;
SetCapture();
DrawBar();
}
void CSplliterBarWnd::OnLButtonUp(UINT nFlags, CPoint point)
{
CDC *pDC;
pDC=GetDC();
CWnd::OnLButtonUp(nFlags, point);
CWnd * pParentWnd=NULL;
pParentWnd=GetParent();
m_bDragBar=FALSE;
::SendMessage(pParentWnd->m_hWnd,WM_USER_MOVE_WINDOW,point.x,point.y);
SendMessage(WM_PAINT);
ReleaseCapture();
}
void CSplliterBarWnd::DrawBar()
{
CRect rect;
GetClientRect(&rect);
CDC * pDc;
pDc=GetDC();
pDc->PatBlt(rect.left,rect.top,rect.Width(),rect.Height(),PATINVERT);
}
void CSplliterBarWnd ::SetBmap(UINT uRid)
{
m_bitmap.LoadBitmap(IDB_VertSplliterBar);
}
void CSplliterBarWnd::OnPaint()
{
CPaintDC dc(this); // device context for painting
SetBkGround();
}
void CSplliterBarWnd::SetBkGround()
{
CDC *pDC=GetDC(); // device context for painting
CRect rectbk;
GetClientRect(&rectbk);
pDC->FillSolidRect(rectbk,RGB(0,0,255));
CRect rectPanel;
CDC dcMen;
BITMAP stBitmap;
m_bitmap.GetObject(sizeof(BITMAP), &stBitmap);
CSize bmsize(stBitmap.bmWidth, stBitmap.bmHeight);
dcMen.CreateCompatibleDC(pDC);
CBitmap *pold=dcMen.SelectObject(&m_bitmap);
pDC->StretchBlt(rectbk.left,rectbk.top,rectbk.Width(),
rectbk.Height(),&dcMen,0,0,bmsize.cx,bmsize.cy,SRCCOPY);
dcMen.SelectObject(pold);
dcMen.DeleteDC();
}
void CSplliterBarWnd::OnSize(UINT nType, int cx, int cy)
{
CWnd::OnSize(nType, cx, cy);
CWnd * pParentWnd=GetParent();
CRect patentRect;
CRect rect;
GetClientRect(&rect);
pParentWnd->GetClientRect(&patentRect);
rect.bottom=patentRect.bottom;
}
void CSplliterBarWnd::SetSplliterVertBarWidth(UINT width)
{
m_uSplliterVertBarWidth=width;
}
void CSplliterBarWnd::SetSplliterHorBarWitdh(UINT width)
{
m_uSplliterHorzBarWidth=width;
}
UINT CSplliterBarWnd::GetSplliterVertBarWitdh()
{
return m_uSplliterVertBarWidth;
}
UINT CSplliterBarWnd::GetSplliterHorzBarWidth()
{
return m_uSplliterHorzBarWidth;
}
#11
算了算了。。。谢谢,自己来吧。