/[H6]/MyTabCtrl.cpp
ViewVC logotype

Annotation of /MyTabCtrl.cpp

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.20