设为首页 加入收藏

TOP

多标签视图类CTabView的设计实现 (五)
2014-11-24 00:12:00 来源: 作者: 【 】 浏览:96
Tags:标签 CTabView 设计 实现
turn FALSE;
73 _tcscpy(ti.view.pszTitle,pszTitle);
74 }
75 else
76 {
77 ti.view.pszTitle = NULL;
78 }
79 ti.header.iImage = iImage;
80 ti.view.pWnd = pWnd;
81 ti.view.pData = pData;
82 if (-1==GetTabCtrl().InsertItem(iIndex,ti))
83 {
84 if (pszTitle) delete []ti.view.pszTitle;
85 return FALSE;
86 }
87 pWnd->SetParent(this);
88 if (bActivate)
89 {
90 SetActiveViewIndex(iIndex);
91 OnViewActivated(iIndex);
92 }
93 return TRUE;
94}
95
96void CTabView::RemoveView(CWnd* pWnd,BOOL bDestroy)
97{
98 RemoveView(GetIndex(pWnd),bDestroy);
99}
100
101void CTabView::RemoveView(int iIndex,BOOL bDestroy)
102{
103 ASSERT(::IsWindow(CCtrlView::m_hWnd));
104 ASSERT(IsValidViewIndex(iIndex));
105
106 CWnd* pWnd = GetView(iIndex);
107 ASSERT(pWnd);
108
109 BOOL bInner;
110 if (IsInnerView(iIndex,bInner) && bInner)
111 m_UniqueIDs.Add(pWnd->GetDlgCtrlID());
112 bDestroy pWnd->DestroyWindow() : pWnd->ShowWindow(SW_HIDE);
113
114 LPTSTR pszTitle;
115 if (GetViewTitle(iIndex,pszTitle))
116 delete []pszTitle;
117
118 ATLVERIFY(GetTabCtrl().DeleteItem(iIndex));
119 if(m_iActiveView == iIndex)
120 {
121 m_iActiveView = -1;
122 if(iIndex > 0)
123 {
124 SetActiveViewIndex(iIndex-1);
125 }
126 else if(GetViewCount() > 0)
127 {
128 SetActiveViewIndex(iIndex);
129 }
130 else
131 {
132 SetRedraw(TRUE);
133 Invalidate();
134 UpdateWindow();
135 }
136 }
137 else
138 {
139 iIndex = (iIndex < m_iActiveView) (m_iActiveView - 1) : m_iActiveView;
140 m_iActiveView = -1;
141 SetActiveViewIndex(iIndex);
142 }
143 if (-1!=m_iActiveView)
144 {
145 OnViewActivated(m_iActiveView);
146 }
147}
148
149void CTabView::RemoveAllView()
150{
151 LPTSTR pszTitle;
152 for (int iIndex=0;iIndex 153 {
154 GetView(iIndex)->DestroyWindow();
155 if (GetViewTitle(iIndex,pszTitle))
156 delete []pszTitle;
157 }
158 GetTabCtrl().DeleteAllItems();
159}
160
161int CTabView::GetViewCount() const
162{
163 ASSERT(::IsWindow(CCtrlView::m_hWnd));
164 return GetTabCtrl().GetItemCount();
165}
166
167CWnd* CTabView::GetView(int iIndex) const
168{
169 ASSERT(::IsWindow(CCtrlView::m_hWnd));
170 ASSERT(IsValidViewIndex(iIndex));
171
172 TC_EXTRA_ITEM ti;
173 ti.header.mask = TCIF_PARAM;
174 if (!GetTabCtrl().GetItem(iIndex,ti))
175 return NULL;
176 return ti.view.pWnd;
177}
178
179int CTabView::GetIndex(const CWnd* pWnd) const
180{
181 ASSERT(::IsWindow(CCtrlView::m_hWnd));
182
183 int count = GetTabCtrl().GetItemCount();
184 for (int i=0;i 185 {
186 if (GetView(i)==pWnd)
187 return i;
188 }
189 return -1;
190}
191
192CWnd* CTabView::GetActiveView() const
193{
194 ASSERT(::IsWindow(CCtrlView::m_hWnd));
195 return (-1==m_iActiveView) NULL : GetView(m_iActiveView);
196}
197
198int CTabView::GetActiveViewIndex() const
199{
200 return m_iActiveView;
201}
202
203void CTabView::SetActiveView(const CWnd* pWnd)
204{
205 SetActiveViewIndex(GetIndex(pWnd));
206}
207
208void CTabView::SetActiveViewIndex(int iIndex)
209{
210 ASSERT(::IsWin
首页 上一页 2 3 4 5 6 下一页 尾页 5/6/6
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇数组中a和&a的区别 下一篇红黑树及生成超过32768随机数

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: