-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyTabCtrl.cpp
93 lines (68 loc) · 1.96 KB
/
MyTabCtrl.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// MyTabCtrl.cpp : implementation file
//
#include "stdafx.h"
#include "TenVis.h"
#include "MyTabCtrl.h"
// CMyTabCtrl
IMPLEMENT_DYNAMIC(CMyTabCtrl, CTabCtrl)
CMyTabCtrl::CMyTabCtrl()
: mPage0(NULL)
, mPage1(NULL)
, mPage2(NULL)
{
mPage0 = new CTabPage0;
mPage1 = new CTabPage1;
mPage2 = new CTabPage2;
}
CMyTabCtrl::~CMyTabCtrl()
{
}
BEGIN_MESSAGE_MAP(CMyTabCtrl, CTabCtrl)
ON_WM_CREATE()
ON_NOTIFY_REFLECT(TCN_SELCHANGE, &CMyTabCtrl::OnTcnSelchange)
END_MESSAGE_MAP()
// CMyTabCtrl message handlers
int CMyTabCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CTabCtrl::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
return 0;
}
void CMyTabCtrl::OnTcnSelchange(NMHDR *pNMHDR, LRESULT *pResult)
{
// TODO: Add your control notification handler code here
activatePages();
*pResult = 0;
}
void CMyTabCtrl::activatePages(void)
{
if(mPage0->m_hWnd) mPage0->ShowWindow(SW_HIDE);
if(mPage1->m_hWnd) mPage1->ShowWindow(SW_HIDE);
if(mPage2->m_hWnd) mPage2->ShowWindow(SW_HIDE);
CRect clientRect;
GetClientRect(clientRect);
AdjustRect(FALSE,clientRect); // FALSE: move rect of whole tab contol to display area of tab control
int sel = GetCurSel();
switch(sel)
{
case 0:
mPage0->SetWindowPos(&wndTop,clientRect.left,clientRect.top,clientRect.Width(),clientRect.Height(),SWP_SHOWWINDOW);
mPage0->ShowWindow(SW_SHOW);
break;
case 2:
mPage1->SetWindowPos(&wndTop,clientRect.left,clientRect.top,clientRect.Width(),clientRect.Height(),SWP_SHOWWINDOW);
mPage1->ShowWindow(SW_SHOW);
break;
case 1:
mPage2->SetWindowPos(&wndTop,clientRect.left,clientRect.top,clientRect.Width(),clientRect.Height(),SWP_SHOWWINDOW);
mPage2->ShowWindow(SW_SHOW);
break;
}
}
void CMyTabCtrl::createPages(void)
{
mPage0->Create(CTabPage0::IDD, this);
mPage1->Create(CTabPage1::IDD, this);
mPage2->Create(CTabPage2::IDD, this);
}