/[H6]/MyTabCtrl.cpp
ViewVC logotype

Contents of /MyTabCtrl.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 12 - (show annotations) (download)
Thu Aug 31 09:02:02 2006 UTC (17 years, 8 months ago) by torben
File size: 1924 byte(s)
add a pointer to the tabcontrol to CommonStorage
1 // MyTabCtrl.cpp : implementation file
2 //
3
4 #include "stdafx.h"
5 #include "h6-udlånssystem.h"
6 #include "MyTabCtrl.h"
7 #include ".\mytabctrl.h"
8
9 #include "CommonStorage.h"
10 #include "SearchDialog.h"
11 #include "AdminDialog.h"
12 #include "ResultDialog.h"
13
14
15 // CMyTabCtrl
16
17 IMPLEMENT_DYNAMIC(CMyTabCtrl, CTabCtrl)
18 CMyTabCtrl::CMyTabCtrl()
19 {
20 m_numTabs = 3;
21 m_tabs[0] = new SearchDialog;
22 m_tabs[1] = new ResultDialog;
23 m_tabs[2] = new AdminDialog;
24 }
25
26 CMyTabCtrl::~CMyTabCtrl()
27 {
28 for (int i=0; i<m_numTabs; i++)
29 delete m_tabs[i];
30 }
31
32
33 BEGIN_MESSAGE_MAP(CMyTabCtrl, CTabCtrl)
34 //{{AFX_MSG_MAP(CMyTabCtrl)
35 ON_WM_LBUTTONDOWN()
36 //}}AFX_MSG_MAP
37 END_MESSAGE_MAP()
38
39
40
41 // CMyTabCtrl message handlers
42
43
44 void CMyTabCtrl::Init(void)
45 {
46 OutputDebugString("CMyTabCtrl::Init()\n");
47
48 m_tabCurrent = 0;
49
50 m_tabs[0]->Create(IDD_SEARCH);
51 m_tabs[1]->Create(IDD_RESULT);
52 m_tabs[2]->Create(IDD_ADMIN);
53
54 m_tabs[0]->ShowWindow(SW_SHOW);
55 m_tabs[1]->ShowWindow(SW_HIDE);
56 m_tabs[2]->ShowWindow(SW_HIDE);
57 SetRectangle();
58
59 CommonStorage::Instance()->setTabCtrl(this);
60 }
61
62 void CMyTabCtrl::SetRectangle(void)
63 {
64 CRect tabRect, itemRect;
65 int nX,nY,nXc,nYc;
66
67 GetClientRect(&tabRect);
68 GetItemRect(0, &itemRect);
69
70 nX = itemRect.left+10;
71 nY = itemRect.bottom+15;
72 nXc=tabRect.right-itemRect.left-1;
73 nYc=tabRect.bottom-nY-1;
74
75 m_tabs[0]->SetWindowPos(&wndTop,nX,nY,nXc,nYc,SWP_SHOWWINDOW);
76 for (int i=1; i<m_numTabs; i++) {
77 m_tabs[i]->SetWindowPos(&wndTop,nX,nY,nXc,nYc,SWP_HIDEWINDOW);
78 }
79 }
80 void CMyTabCtrl::OnLButtonDown(UINT nFlags, CPoint point)
81 {
82 CTabCtrl::OnLButtonDown(nFlags,point);
83
84 ChangeFocus();
85 }
86
87
88
89 void CMyTabCtrl::ChangeFocus(void)
90 {
91 if (m_tabCurrent != GetCurFocus()) {
92 m_tabs[m_tabCurrent]->ShowWindow(SW_HIDE);
93 m_tabCurrent = GetCurFocus();
94 m_tabs[m_tabCurrent]->ShowWindow(SW_SHOW);
95 m_tabs[m_tabCurrent]->SetFocus();
96 }
97 }

  ViewVC Help
Powered by ViewVC 1.1.20