Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
AppTabManager.cpp
Package: solidgraph_sources.zip [view]
Upload User: kairuinn
Upload Date: 2009-02-07
Package Size: 2922k
Code Size: 5k
Category:
Graph program
Development Platform:
Visual C++
- // AppTabManager.cpp : implementation file
- //
- #include "stdafx.h"
- #include "Solidgraph.h"
- #include "AppTabManager.h"
- #include "DocManagerEx.h"
- // CAppTabManager
- IMPLEMENT_DYNAMIC(CAppTabManager, CControlBar)
- CAppTabManager::CAppTabManager()
- {
- }
- CAppTabManager::~CAppTabManager()
- {
- std::vector<TAB_STRUCT*>::iterator itTabInfo;
- for ( itTabInfo = m_tab_infos.begin(); itTabInfo != m_tab_infos.end(); ++itTabInfo )
- delete (*itTabInfo);
- }
- #define ID_TAB 1
- BEGIN_MESSAGE_MAP(CAppTabManager, CControlBar)
- ON_WM_CREATE()
- ON_WM_SIZE()
- ON_NOTIFY( TCN_SELCHANGE, ID_TAB, OnTabChanged )
- END_MESSAGE_MAP()
- // CTabBar message handlers
- void CAppTabManager::OnTabChanged( NMHDR * /* pNotifyStruct */, LRESULT * /* result */ )
- {
- TC_ITEM tci;
- tci.mask = TCIF_PARAM;
- m_tabs.GetItem(m_tabs.GetCurSel(), &tci );
- ((CDocManagerEx*)theApp.m_pDocManager)->ActivateFrame((CDocTemplate*)tci.lParam);
- }
- void CAppTabManager::AddTab( CDocTemplate* dT, const char* str)
- {
- TAB_STRUCT* lpWndTabInfo = new TAB_STRUCT;
- lpWndTabInfo->rtClass = dT;
- memset( lpWndTabInfo->szText, 0x00, (101)* sizeof( TCHAR ) );
- strcpy(lpWndTabInfo->szText,str);
- //::GetWindowText( hWnd, lpWndTabInfo->szText, 101 );
- lpWndTabInfo->nTabId = m_tabs.InsertItem( TCIF_PARAM | TCIF_TEXT,
- m_tabs.GetItemCount(), lpWndTabInfo->szText, -1, (LPARAM)dT );
- m_tab_infos.push_back( lpWndTabInfo );
- }
- int CAppTabManager::TabIdByRT( CDocTemplate* dT)
- {
- // Get nTabId by HWND-data of tab
- TC_ITEM tci;
- tci.mask = TCIF_PARAM;
- int nCount = m_tabs.GetItemCount();
- for (int i = 0; i < nCount; ++i ) {
- m_tabs.GetItem(i, &tci );
- if ( dT == (CDocTemplate*)tci.lParam )
- return i;
- }
- return -1;
- }
- void CAppTabManager::RemoveTab(CDocTemplate* dT)
- {
- std::vector<TAB_STRUCT*>::iterator itTabInfo;
- // deleting referenced tab infos
- for ( itTabInfo = m_tab_infos.begin(); itTabInfo != m_tab_infos.end(); ++itTabInfo )
- if ( dT == (*itTabInfo)->rtClass ) { // here is
- TAB_STRUCT* lpInfo = (*itTabInfo);
- m_tab_infos.erase( itTabInfo );
- delete lpInfo;
- break;
- }
- // deleting referenced tab
- m_tabs.DeleteItem( TabIdByRT( dT ) );
- // re-initialize nTabId members of WND_TAB_INFO
- for ( itTabInfo = m_tab_infos.begin(); itTabInfo != m_tab_infos.end(); ++itTabInfo )
- (*itTabInfo)->nTabId = TabIdByRT( (*itTabInfo)->rtClass );
- // activate new tab
- /*if ( m_tabs.GetItemCount() > 0 ) {
- ActivateTab( hWndActive );
- }*/
- }
- void CAppTabManager::ActivateTab( CDocTemplate* dT) {
- TC_ITEM tci;
- tci.mask = TCIF_PARAM;
- m_tabs.GetItem( m_tabs.GetCurSel(), &tci );
- if ( dT != (CDocTemplate*)tci.lParam )
- {
- m_tabs.SetCurSel( TabIdByRT( dT ) );
- }
- }
- // CAppTabManager message handlers
- void CAppTabManager::OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL /*bDisableIfNoHndler*/)
- {
- }
- BOOL CAppTabManager::CreateAppTabManager( CFrameWnd* pTarget ) {
- ASSERT( pTarget );
- m_pFrameWnd = pTarget;
- // m_hWndMDIClient = ( (CMDIFrameWnd*)m_pFrameWnd )->m_hWndMDIClient;
- CString strWndclass = ::AfxRegisterWndClass(CS_DBLCLKS, ::LoadCursor(NULL, IDC_ARROW), ::GetSysColorBrush(COLOR_BTNFACE), 0);
- if (!CWnd::Create(strWndclass, _T("AppManager"),
- WS_CHILD | CBRS_TOP | WS_VISIBLE|WS_CLIPCHILDREN | CCS_NOPARENTALIGN | CCS_NOMOVEY | CCS_NORESIZE,
- CRect(0, 0, 100, 26), pTarget, 31255))
- return FALSE;
- SetBarStyle(GetBarStyle() | CBRS_TOP | CBRS_TOOLTIPS /* | CBRS_FLYBY | CBRS_SIZE_DYNAMIC */);
- //EnableDocking( CBRS_ALIGN_TOP );
- //pTarget->DockControlBar(this);
- return TRUE;
- }
- int CAppTabManager::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CControlBar::OnCreate(lpCreateStruct) == -1)
- return -1;
- // 袜耱痤桦