// MyTabCtrl.cpp : implementation file // #include "stdafx.h" #include "h6-udlånssystem.h" #include "MyTabCtrl.h" #include ".\mytabctrl.h" #include "CommonStorage.h" #include "SearchDialog.h" #include "AdminDialog.h" #include "ResultDialog.h" // CMyTabCtrl IMPLEMENT_DYNAMIC(CMyTabCtrl, CTabCtrl) CMyTabCtrl::CMyTabCtrl() { m_numTabs = 3; m_tabs[0] = new SearchDialog; m_tabs[1] = new ResultDialog; m_tabs[2] = new AdminDialog; } CMyTabCtrl::~CMyTabCtrl() { for (int i=0; iCreate(IDD_SEARCH); m_tabs[1]->Create(IDD_RESULT); m_tabs[2]->Create(IDD_ADMIN); m_tabs[0]->ShowWindow(SW_SHOW); m_tabs[1]->ShowWindow(SW_HIDE); m_tabs[2]->ShowWindow(SW_HIDE); SetRectangle(); CommonStorage::Instance()->setTabCtrl(this); } void CMyTabCtrl::SetRectangle(void) { CRect tabRect, itemRect; int nX,nY,nXc,nYc; GetClientRect(&tabRect); GetItemRect(0, &itemRect); nX = itemRect.left+10; nY = itemRect.bottom+15; nXc=tabRect.right-itemRect.left-1; nYc=tabRect.bottom-nY-1; m_tabs[0]->SetWindowPos(&wndTop,nX,nY,nXc,nYc,SWP_SHOWWINDOW); for (int i=1; iSetWindowPos(&wndTop,nX,nY,nXc,nYc,SWP_HIDEWINDOW); } } void CMyTabCtrl::OnLButtonDown(UINT nFlags, CPoint point) { CTabCtrl::OnLButtonDown(nFlags,point); ChangeFocus(); } void CMyTabCtrl::ChangeFocus(void) { if (m_tabCurrent != GetCurFocus()) { m_tabs[m_tabCurrent]->ShowWindow(SW_HIDE); m_tabCurrent = GetCurFocus(); m_tabs[m_tabCurrent]->ShowWindow(SW_SHOW); m_tabs[m_tabCurrent]->SetFocus(); } }