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

📄 cxsplitterwnd.cpp

📁 对话框子类设计
💻 CPP
字号:
// spsp.cpp : implementation file
//

#include "stdafx.h"
#include "CxSplitterWnd.h"

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

/////////////////////////////////////////////////////////////////////////////
// spsp

IMPLEMENT_DYNCREATE(CxSplitterWnd, CMDIChildWnd)

CxSplitterWnd::CxSplitterWnd()
{

}

CxSplitterWnd::~CxSplitterWnd()
{
}


BEGIN_MESSAGE_MAP(CxSplitterWnd, CSplitterWnd)
	//{{AFX_MSG_MAP(CxSplitterWnd)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// spsp message handlers


enum HitTestValue 
{ 
      noHit = 0,//表示没有选中任何对象
      vSplitterBox = 1,
      hSplitterBox = 2,
      bothSplitterBox = 3,
      vSplitterBar1 = 101,//代表各个方向的水平分割条
      vSplitterBar15 = 115,
      hSplitterBar1 = 201,//代表垂直方向的各个分割条
      hSplitterBar15 = 215,
      splitterIntersection1 = 301,//代表各个交叉点
      splitterIntersection225 = 525
};
          
CWnd* CxSplitterWnd::GetActivePane(int* pRow, int* pCol)
{
      ASSERT_VALID(this); 
      //获得当前的获得焦点的窗口
      //下面注释粗体的是原有的代码的主要部分。
      // CWnd* pView = NULL;
      //CFrameWnd* pFrameWnd = GetParentFrame();
      //ASSERT_VALID(pFrameWnd);
      //pView = pFrameWnd->GetActiveView();
      //if (pView == NULL)
      // pView = GetFocus();
      CWnd* pView = GetFocus();
      if (pView != NULL && !IsChildPane(pView, pRow, pCol))
              pView = NULL;
      return pView; 
} 
          
void CxSplitterWnd::SetActivePane( int row, int col, CWnd* pWnd) 
{
      CWnd* pPane = pWnd == NULL ? GetPane(row, col) : pWnd; 
      //下面加注释粗体的是原有代码的主要部分。
      //FrameWnd* pFrameWnd = GetParentFrame();
      //ASSERT_VALID(pFrameWnd); 
      //pFrameWnd->SetActiveView((CView*)pPane); 
      pPane->SetFocus();//修改后的语句 
}
          
void CxSplitterWnd::StartTracking(int ht)
{
          ASSERT_VALID(this); 
          if (ht == noHit) 
                  return;
          // GetHitRect will restrict ''''m_rectLimit'''' as appropriate 
  
          GetInsideRect(m_rectLimit);
          if (ht >= splitterIntersection1 && ht <= splitterIntersection225) 
  
          { 
                  // split two directions (two tracking rectangles) 
  
                  int row = (ht - splitterIntersection1) / 15; 
  
                  int col = (ht - splitterIntersection1) % 15; 
  
                  GetHitRect(row + vSplitterBar1, m_rectTracker); 
  
                  int yTrackOffset = m_ptTrackOffset.y; 
                  m_bTracking2 = TRUE; 
                  GetHitRect(col + hSplitterBar1, m_rectTracker2); 
  
                  m_ptTrackOffset.y = yTrackOffset; 
          } 
          else if (ht == bothSplitterBox) 
          { 
          // hit on splitter boxes (for keyboard) 
          GetHitRect(vSplitterBox, m_rectTracker); 
          int yTrackOffset = m_ptTrackOffset.y; 
          m_bTracking2 = TRUE; 
          GetHitRect(hSplitterBox, m_rectTracker2); 
          m_ptTrackOffset.y = yTrackOffset; // center it 
          m_rectTracker.OffsetRect(0, m_rectLimit.Height()/2); m_rectTracker2.OffsetRect(m_rectLimit.Width()/2,  0); 
          } 
          else
          { 
          // only hit one bar 
          GetHitRect(ht, m_rectTracker); 
          } 
  
  //下面加注释的将从程序中删去。 
  //CView* pView = (CView*)GetActivePane(); 
  //if (pView != NULL && pView->IsKindOf(RUNTIME_CLASS(CView))) 
  //{ 
  // ASSERT_VALID(pView); 
  // CFrameWnd* pFrameWnd = GetParentFrame(); 
  //ASSERT_VALID(pFrameWnd); 
  //pView->OnActivateFrame(WA_INACTIVE, pFrameWnd); 
  // } 
  // steal focus and capture
          SetCapture();
          SetFocus();
          // make sure no updates are pending 
          RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW); 
  
          // set tracking state and appropriate cursor
          m_bTracking = TRUE;
          OnInvertTracker(m_rectTracker); 
          if (m_bTracking2) 
                  OnInvertTracker(m_rectTracker2); 
          m_htTrack = ht; 
          SetSplitCursor(ht); 
}
          
BOOL CxSplitterWnd::OnCommand(WPARAM wParam, LPARAM lParam) 
{ 
          if (CWnd::OnCommand(wParam, lParam)) 
                  return TRUE; 
          //下面粗体的是原程序的语句 
  //return GetParentFrame()->SendMessage(WM_COMMAND, wParam, lParam); 
  
          return GetParent()->SendMessage(WM_COMMAND, wParam, lParam); 
          
}
BOOL CxSplitterWnd::OnNotify( WPARAM wParam, LPARAM lParam, LRESULT* pResult )
{
      if (CWnd::OnNotify(wParam, lParam, pResult)) 
              return TRUE; 
      //下面粗体的是源程序的语句
      //*pResult = GetParentFrame()->SendMessage(WM_NOTIFY,  wParam, lParam);
      *pResult = GetParent()->SendMessage(WM_NOTIFY, wParam, lParam);
      return TRUE;
} 
          
BOOL CxSplitterWnd::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult) 
{ 
      // The code line below is necessary if using CxSplitterWnd     in a regular dll 
      // AFX_MANAGE_STATE(AfxGetStaticModuleState());
      return CWnd::OnWndMsg(message, wParam, lParam, pResult); 
          
} 

void CxSplitterWnd::OnSize(UINT nType, int cx, int cy) 
{
	
	// TODO: Add your message handler code here
	
}

⌨️ 快捷键说明

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