-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyTabCtr.cpp
101 lines (81 loc) · 2.24 KB
/
MyTabCtr.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
94
95
96
97
98
99
100
101
// MyTabCtr.cpp : implementation file
//
#include "stdafx.h"
#include "Surface.h"
#include "MyTabCtr.h"
#include "Option.h"
#include "Orders.h"
#include "Result.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyTabCtr
CMyTabCtr::CMyTabCtr()
{
m_tabPages[0]=new COption;
m_tabPages[1]=new COrders;
m_tabPages[2]=new CResult;
m_nNumberOfPages=3;
}
CMyTabCtr::~CMyTabCtr()
{
for(int nCount=0; nCount < m_nNumberOfPages; nCount++){
delete m_tabPages[nCount];
}
}
void CMyTabCtr::SetParent(CSurfaceView * parent)
{
m_pCSurfaceView = parent;
}
void CMyTabCtr::Init()
{
m_tabCurrent=0;
((COption *)m_tabPages[0])->SetView(m_pCSurfaceView);
((COrders *)m_tabPages[1])->SetView(m_pCSurfaceView);
((CResult *)m_tabPages[2])->SetView(m_pCSurfaceView);
m_tabPages[0]->Create(IDD_OPTION, this);
m_tabPages[1]->Create(IDD_ORDERS, this);
m_tabPages[2]->Create(IDD_RESULT, this);
m_tabPages[0]->ShowWindow(SW_SHOW);
m_tabPages[1]->ShowWindow(SW_HIDE);
m_tabPages[2]->ShowWindow(SW_HIDE);
SetRectangle();
}
void CMyTabCtr::SetRectangle()
{
CRect tabRect, itemRect, rc;
int nX, nY, nXc, nYc;
GetClientRect(&tabRect);
GetItemRect(0, &itemRect);
m_tabPages[0]->GetClientRect(&rc);
//SetItemSize(rc.Size());
nX=itemRect.left ;
nY=itemRect.bottom+1;
nXc=tabRect.right-itemRect.left-1;
nYc=tabRect.bottom-nY-1;
m_tabPages[0]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_SHOWWINDOW);
for(int nCount=1; nCount < m_nNumberOfPages; nCount++){
m_tabPages[nCount]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_HIDEWINDOW);
}
}
BEGIN_MESSAGE_MAP(CMyTabCtr, CTabCtrl)
//{{AFX_MSG_MAP(CMyTabCtr)
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyTabCtr message handlers
void CMyTabCtr::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CTabCtrl::OnLButtonDown(nFlags, point);
if(m_tabCurrent != GetCurFocus()){
m_tabPages[m_tabCurrent]->ShowWindow(SW_HIDE);
m_tabCurrent=GetCurFocus();
m_tabPages[m_tabCurrent]->ShowWindow(SW_SHOW);
m_tabPages[m_tabCurrent]->SetFocus();
}
}