转贴指明作者

#if !defined(AFX_MYSPLITER_H__A78B35E4_9855_43EE_9046_AF7B3A3AE2A9__INCLUDED_)
#define AFX_MYSPLITER_H__A78B35E4_9855_43EE_9046_AF7B3A3AE2A9__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// MySpliter.h : header file

#pragma warning( disable:4786 )
#include <list>
#include <map>
using namespace std;

class CMySpliter : public CSplitterWnd
{
// Construction
public:
 CMySpliter();

// Attributes
public:

// Operations
public:

// Overrides
 // ClassWizard generated virtual function overrides
 //{{AFX_VIRTUAL(CMySpliter)
 //}}AFX_VIRTUAL

// Implementation
public:
 virtual ~CMySpliter();
 virtual void HideRow(int row);
 void ShowRow( int row );
 // Generated message map functions
protected:
 //{{AFX_MSG(CMySpliter)
  // NOTE - the ClassWizard will add and remove member functions here.
 //}}AFX_MSG

virtual void OnDrawSplitter( CDC* pDC, ESplitType nType, const CRect& rect );

struct _HideSubUnit
 {
  CWnd* pWnd;
  int nCur;
  int nMin;
 };

typedef list< _HideSubUnit > SUBLIST;

struct _HideUnit
 {
  SUBLIST Sublist;
  int nCur;
  int nMin;
 };

map< int, _HideUnit* > m_mapDelete;

map< int, int > m_mapRowRow;

DECLARE_MESSAGE_MAP()
};

// MySpliter.cpp : implementation file
//

#include "stdafx.h"
#include "fsdf.h"
#include "MySpliter.h"

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

/
// CMySpliter

CMySpliter::CMySpliter()
{
 /*
 m_cxSplitter = m_cySplitter = 2 + 1 + 1;
 m_cxBorderShare = m_cyBorderShare = 0;
 m_cxSplitterGap = m_cySplitterGap = 2 + 1 + 1;
 m_cxBorder = m_cyBorder = 1;
 m_uIDCount = 0;
 */
}

CMySpliter::~CMySpliter()
{
}

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

/
// CMySpliter message handlers

void CMySpliter::OnDrawSplitter( CDC* pDC, ESplitType nType, const CRect& rect )
{
 CSplitterWnd::OnDrawSplitter( pDC, nType, rect );
// if( pDC && splitBar == nType)
// pDC->FillSolidRect(rect, RGB(0, 0, 255));
}

void CMySpliter::HideRow(int rowVal)
{
 if( m_mapRowRow.empty() )
 {
  for( int i = 0; i < m_nRows; i++ )
   m_mapRowRow.insert( map< int, int >::value_type(i, i));
 }

map< int, int >::iterator iter = m_mapRowRow.find(rowVal);
 if( iter == m_mapRowRow.end()  )
  return;

map< int, int >::iterator iter1 = iter;
 for( ;iter != m_mapRowRow.end() ; iter++ )
 {
  iter->second--;
 }

m_mapRowRow.erase( iter1 );

int rowActive, colActive;
 if (GetActivePane(&rowActive, &colActive) != NULL && rowActive == rowVal)
 {
  if (++rowActive >= m_nRows)
   rowActive = 0;
  SetActivePane(rowActive, colActive);
 }

CWnd* pScrollDel = m_bHasVScroll ?
  GetDlgItem(AFX_IDW_VSCROLL_FIRST+rowVal) : NULL;

_HideUnit * pUnit = new _HideUnit;
 m_mapDelete.insert( map< int, _HideUnit* >::value_type( rowVal, pUnit ) );
 GetRowInfo( rowVal, pUnit->nCur, pUnit->nMin );

for (int col = 0; col < m_nCols; col++)
 {
  _HideSubUnit sub;
  sub.pWnd = GetPane(rowVal, col);
  GetColumnInfo( col, sub.nCur, sub.nMin );
  pUnit->Sublist.push_back( sub );
  sub.pWnd->SetDlgCtrlID( 0 );
  sub.pWnd->ShowWindow( SW_HIDE );

for (int row = rowVal+1; row < m_nRows; row++)
  {
   CWnd* pPane = GetPane(row, col);
   ASSERT(pPane != NULL);
   pPane->SetDlgCtrlID(IdFromRowCol(row-1, col));
   if (m_bHasVScroll && col == m_nCols-1)
   {
    CWnd* pScroll = GetDlgItem(AFX_IDW_VSCROLL_FIRST+row);
    if (pScroll != NULL)
     pScroll->SetDlgCtrlID(AFX_IDW_VSCROLL_FIRST+row-1);
   }
  }
 }
 m_nRows--;
 if (pScrollDel != NULL)
  pScrollDel->DestroyWindow();

RecalcLayout();     // re-assign the space

}

void CMySpliter::ShowRow( int rowVal )
{
 map< int, _HideUnit* >::iterator iter = m_mapDelete.find( rowVal );
 if(  iter == m_mapDelete.end() )
  return;

int nPos = 0;
 map< int, int>::iterator iter1 = m_mapRowRow.begin();
 for( ; iter1 != m_mapRowRow.end(); iter1++ )
 {
  if( iter1->first > rowVal )
  {
   iter1->second++;
  }
  else
  {
   nPos++;
  }
 }

m_mapRowRow.insert( map< int, int>::value_type( rowVal, nPos ) );

for (int col = 0; col < m_nCols; col++)
 {
  for (int row = nPos; row < m_nRows; row++)
  {
   CWnd* pPane = GetPane(row, col);
   ASSERT(pPane != NULL);
   pPane->SetDlgCtrlID(IdFromRowCol(row , col) + 16 );
   if (m_bHasVScroll && col == m_nCols-1)
   {
    CWnd* pScroll = GetDlgItem(AFX_IDW_VSCROLL_FIRST+row);
    if (pScroll != NULL)
     pScroll->SetDlgCtrlID(AFX_IDW_VSCROLL_FIRST+row + 1);
   }
  }
 }

m_nRows++;
 SUBLIST::iterator listiter = iter->second->Sublist.begin();
 for ( col = 0; col < m_nCols; col++, listiter++)
 {
  listiter->pWnd->SetDlgCtrlID(IdFromRowCol(nPos, col) );
  listiter->pWnd->ShowWindow( SW_SHOW );
 }

delete iter->second;
 m_mapDelete.erase( iter );

if (m_bHasVScroll &&
  !CreateScrollBarCtrl(SBS_VERT, AFX_IDW_VSCROLL_FIRST + nPos))
 {
  TRACE0("Warning: SplitRow failed to create scroll bar./n");
 }

RecalcLayout();
}

static Splitterwnd hide and show --by wyj相关推荐

  1. C#2.0实例程序STEP BY STEP--实例二:数据类型

    C#2.0实例程序STEP BY STEP--实例二:数据类型 与其他.NET语言一样,C#支持Common Type Sysem(CTS),其中的数据类型集合不仅包含我们熟悉的基本类型,例如int, ...

  2. ESFramewor使用技巧(2)-- 在插件中使用NHibernate

        我们来讨论一下这种情景,你采用基于ESFramework的4层架构进行应用开发,你分析用户的需求,并将其分类整理为几大块,考虑每一块使用一个功能插件来完成.在这几个插件中,有个插件需要访问某个 ...

  3. (转)C#2.0泛型--Dictionary,List用法

    C#2.0泛型--Dictionary,List用法 泛型是 C#2.0 语言和公共语言运行库 (CLR) 中的一个新功能.泛型将类型参数的概念引入 .NET Framework,类型参数使得设计如下 ...

  4. 设计模式---命令模式

    考虑这样一种场景:某个方法需要完成某一个行为,但是这个行为的具体实现无法确定,必须等到执行该方法时才可以确定. 具体一点:假设有一个方法是遍历某个数组的数组元素,但是无法确定在遍历的数组的元素的时候如 ...

  5. 设计模式---单例模式(多线程下的单例模式)

    1>单例类 package com.test.sigleton;public class SingletonTest {public static int num=0;//用于记录该类被实例化的 ...

  6. Handler 基本用法--线程间传值

    Handler 作用:主要接受子线程发送的数据, 并用此数据配合主线程更新UI. 解释: 当应用程序启动时,Android首先会开启一个主线程 (也就是UI线程) , 主线程为管理界面中的UI控件,进 ...

  7. 数据管理(八)--CD程序

    CD程序 我们已经了解了环境以及管理数据的相关内容了,现在是更新程序的时候了.dbm数据库看起来对于存储我们的CD信息是十分合适的,所以我们会将dbm数据用作我们的新实现的基础. 更新设计 因为这次更 ...

  8. iptables--静态防火墙实例教程

    iptables--静态防火墙实例教程 follow me 介绍: 这篇文章是本人原创,向读者展示了如何一步一步建立静态防火墙来保护您的计算机,同时在每一步中,我力图向读者讲述清楚原理.在这篇教程之后 ...

  9. ASP.NET3.5 企业级项目开发 -- 第二章 数据访问层(DAL)的开发

    为什么80%的码农都做不了架构师?>>>    ASP.NET3.5 企业级项目开发 -- 第二章 数据访问层(DAL)的开发          前言:本篇主要讲述数据访问层的开发, ...

  10. 【转载】ESFramewor使用技巧(2)-- 在插件中使用NHibernate

    ESFramewor使用技巧(2)-- 在插件中使用NHibernate     我们来讨论一下这种情景,你采用基于ESFramework的4层架构进行应用开发,你分析用户的需求,并将其分类整理为几大 ...

最新文章

  1. ICLR 2019计算机视觉、NLP、图模型、对抗学习、表示学习和元学习
  2. PHP学习笔记-字符串操作2
  3. JQuery中ajax方法访问web服务
  4. Ubuntu: 创建PlayOnLinux快捷键 Create PlayOnLinux Application Desktop
  5. 大学物理光学思维导图_在线思维导图软件安利:简单、方便画图,大学生、小学生都能用...
  6. eclipse/myeclipse添加插件3种方式
  7. Android异常总结---ActivityManager: Warning: Activity not started,its current task has been brought to th
  8. android gesture,Android Gesture 手势创建以及使用示例
  9. php tcpdf 没有头部,TCPDF - 设置头部Logo不显示问题
  10. 电脑查看wifi密码
  11. Debian 10 安装fonts-noto-cjk
  12. 松翰单片机--SN8F5702学习笔记(七)TIMER0、TIMER1
  13. 《C专家编程》随笔1:读者心得
  14. RGB TO ARGB
  15. zigbee中的CSMA-CA载波检测多路访问-碰撞避免和信标(Beacon)VS非信标(Nonbeacon)网络
  16. Java常用缓存组件和方法
  17. 银行信用评分卡建模原理
  18. 打开虚拟机时出现不能为虚拟电脑打开一个新任务
  19. 车牌识别停车系统无法链接服务器,停车场车牌识别系统识别不了的处理方法有哪些?...
  20. DIY USB3.0 SM2246XT+双贴闪迪15131颗粒256G固态U盘

热门文章

  1. Laravel快速创建统计图表
  2. 智能机器人建房子后房价走势_重磅!机器人建房时代将至,工作效率是人的4倍,有助房价下跌?...
  3. 三层交换技术与链路聚合
  4. word文档太大怎么压缩?
  5. 最小二乘法求回归直线方程的详细推导过程
  6. c语言绝对值函数作用,C语言实现abs和fabs绝对值
  7. 每周全球科技十大新闻(2019.8.12-8.18)
  8. 宝塔面板配置SSL证书
  9. pycharm “collecting data“
  10. microsoftedge无限弹出_Win10升级之后edge浏览器总是弹出欢迎页面解决方法