splitex.h

  1. // splitex.h
  2. // (c) 1997, Oleg G. Galkin
  3. class CSplitterWndEx : public CSplitterWnd
  4. {
  5. protected:
  6.    int m_nHidedCol;    // hide column number, -1 if all columns
  7.                        // are shown
  8. public:
  9.    CSplitterWndEx();
  10.    void ShowColumn();
  11.    void HideColumn(int colHide);
  12. // ClassWizard generated virtual function overrides
  13.    //{{AFX_VIRTUAL(CSplitterWndEx)
  14.    //}}AFX_VIRTUAL
  15. // Generated message map functions
  16. protected:
  17.    //{{AFX_MSG(CSplitterWndEx)
  18.       // NOTE - the ClassWizard will add and remove member
  19.       //        functions here.
  20.       //}}AFX_MSG
  21.     DECLARE_MESSAGE_MAP()
  22. };
  23. //
  24. //
  25. // splitex.cpp
  26. // (c) 1997, Oleg G. Galkin
  27. #include "stdafx.h"
  28. #include "splitex.h"
  29. #ifdef _DEBUG
  30. #define new DEBUG_NEW
  31. #undef THIS_FILE
  32. static char THIS_FILE[] = __FILE__;
  33. #endif
  34. //
  35. /
  36. // CSplitterWndEx
  37. CSplitterWndEx::CSplitterWndEx() :
  38.     m_nHidedCol(-1)
  39. {
  40. }
  41. void CSplitterWndEx::ShowColumn()
  42. {
  43.    ASSERT_VALID(this);
  44.    ASSERT(m_nCols < m_nMaxCols);
  45.    ASSERT(m_nHidedCol != -1);
  46.    int colNew = m_nHidedCol;
  47.    m_nHidedCol = -1;
  48.    int cxNew = m_pColInfo[m_nCols].nCurSize;
  49.    m_nCols++;    // add a column
  50.    ASSERT(m_nCols == m_nMaxCols);
  51.    // fill the hidden column
  52.    int col;
  53.    for (int row = 0; row < m_nRows; row++)
  54.    {
  55.       CWnd* pPaneShow = GetDlgItem(
  56.          AFX_IDW_PANE_FIRST + row * 16 + m_nCols);
  57.       ASSERT(pPaneShow != NULL);
  58.       pPaneShow->ShowWindow(SW_SHOWNA);
  59.       for (col = m_nCols - 2; col >= colNew; col--)
  60.       {
  61.          CWnd* pPane = GetPane(row, col);
  62.          ASSERT(pPane != NULL);
  63.          pPane->SetDlgCtrlID(IdFromRowCol(row, col + 1));
  64.       }
  65.       pPaneShow->SetDlgCtrlID(IdFromRowCol(row, colNew));
  66.    }
  67.    // new panes have been created -- recalculate layout
  68.    for (col = colNew + 1; col < m_nCols; col++)
  69.       m_pColInfo[col].nIdealSize = m_pColInfo[col - 1].nCurSize;
  70.    m_pColInfo[colNew].nIdealSize = cxNew;
  71.    RecalcLayout();
  72. }
  73. void CSplitterWndEx::HideColumn(int colHide)
  74. {
  75.    ASSERT_VALID(this);
  76.    ASSERT(m_nCols > 1);
  77.    ASSERT(colHide < m_nCols);
  78.    ASSERT(m_nHidedCol == -1);
  79.    m_nHidedCol = colHide;
  80.    // if the column has an active window -- change it
  81.    int rowActive, colActive;
  82.    if (GetActivePane(&rowActive, &colActive) != NULL &&
  83.        colActive == colHide)
  84.    {
  85.       if (++colActive >= m_nCols)
  86.          colActive = 0;
  87.       SetActivePane(rowActive, colActive);
  88.    }
  89.    // hide all column panes
  90.    for (int row = 0; row < m_nRows; row++)
  91.    {
  92.       CWnd* pPaneHide = GetPane(row, colHide);
  93.       ASSERT(pPaneHide != NULL);
  94.       pPaneHide->ShowWindow(SW_HIDE);
  95.       pPaneHide->SetDlgCtrlID(
  96.          AFX_IDW_PANE_FIRST + row * 16 + m_nCols);
  97.       for (int col = colHide + 1; col < m_nCols; col++)
  98.       {
  99.          CWnd* pPane = GetPane(row, col);
  100.          ASSERT(pPane != NULL);
  101.          pPane->SetDlgCtrlID(IdFromRowCol(row, col - 1));
  102.       }
  103.    }
  104.    m_nCols--;
  105.    m_pColInfo[m_nCols].nCurSize = m_pColInfo[colHide].nCurSize;
  106.     RecalcLayout();
  107. }
  108. BEGIN_MESSAGE_MAP(CSplitterWndEx, CSplitterWnd)
  109. //{{AFX_MSG_MAP(CSplitterWndEx)
  110.    // NOTE - the ClassWizard will add and remove mapping macros here.
  111. //}}AFX_MSG_MAP
  112. END_MESSAGE_MAP()
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值