Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

808 lines
22 KiB

  1. //Copyright (c) 1998 - 1999 Microsoft Corporation
  2. /*******************************************************************************
  3. *
  4. * allsrvvw.cpp
  5. *
  6. * implementation of the CServerView class
  7. *
  8. *
  9. *******************************************************************************/
  10. #include "stdafx.h"
  11. #include "resource.h"
  12. #include "allsrvvw.h"
  13. #include "admindoc.h"
  14. #ifdef _DEBUG
  15. #define new DEBUG_NEW
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19. PageDef CAllServersView::pages[] = {
  20. { NULL, RUNTIME_CLASS( CAllServerServersPage ), IDS_TAB_SERVERS, PAGE_AS_SERVERS, PF_PICASSO_ONLY},
  21. { NULL, RUNTIME_CLASS( CAllServerUsersPage ), IDS_TAB_USERS, PAGE_AS_USERS, NULL },
  22. { NULL, RUNTIME_CLASS( CAllServerWinStationsPage ),IDS_TAB_WINSTATIONS, PAGE_AS_WINSTATIONS,NULL },
  23. { NULL, RUNTIME_CLASS( CAllServerProcessesPage ), IDS_TAB_PROCESSES, PAGE_AS_PROCESSES, NULL },
  24. { NULL, RUNTIME_CLASS( CAllServerLicensesPage ), IDS_TAB_LICENSES, PAGE_AS_LICENSES, PF_PICASSO_ONLY}
  25. };
  26. //////////////////////////
  27. // MESSAGE MAP: CAllServersView
  28. //
  29. IMPLEMENT_DYNCREATE(CAllServersView, CView)
  30. BEGIN_MESSAGE_MAP(CAllServersView, CView)
  31. //{{AFX_MSG_MAP(CAllServersView)
  32. ON_WM_SIZE()
  33. ON_WM_CREATE()
  34. //}}AFX_MSG_MAP
  35. ON_MESSAGE(WM_WA_SERVER_CHANGEPAGE, OnChangePage)
  36. ON_MESSAGE(WM_ADMIN_ADD_SERVER, OnAdminAddServer)
  37. ON_MESSAGE(WM_ADMIN_REMOVE_SERVER, OnAdminRemoveServer)
  38. ON_MESSAGE(WM_ADMIN_UPDATE_SERVER, OnAdminUpdateServer)
  39. ON_MESSAGE(WM_ADMIN_UPDATE_PROCESSES, OnAdminUpdateProcesses)
  40. ON_MESSAGE(WM_ADMIN_REMOVE_PROCESS, OnAdminRemoveProcess)
  41. ON_MESSAGE(WM_ADMIN_REDISPLAY_PROCESSES, OnAdminRedisplayProcesses)
  42. ON_NOTIFY(TCN_SELCHANGE, IDC_ALL_SERVERS_TABS, OnTabSelChange)
  43. ON_MESSAGE(WM_ADMIN_UPDATE_SERVER_INFO, OnAdminUpdateServerInfo)
  44. ON_MESSAGE(WM_ADMIN_REDISPLAY_LICENSES, OnAdminRedisplayLicenses)
  45. ON_MESSAGE(WM_ADMIN_UPDATE_WINSTATIONS, OnAdminUpdateWinStations)
  46. ON_MESSAGE( WM_ADMIN_TABBED_VIEW , OnTabbed )
  47. ON_MESSAGE( WM_ADMIN_SHIFTTABBED_VIEW , OnShiftTabbed )
  48. ON_MESSAGE( WM_ADMIN_CTRLTABBED_VIEW , OnCtrlTabbed )
  49. ON_MESSAGE( WM_ADMIN_CTRLSHIFTTABBED_VIEW , OnCtrlShiftTabbed )
  50. ON_MESSAGE( WM_ADMIN_NEXTPANE_VIEW , OnNextPane )
  51. END_MESSAGE_MAP()
  52. ///////////////////////
  53. // F'N: CServerView ctor
  54. //
  55. CAllServersView::CAllServersView()
  56. {
  57. m_pTabs = NULL;
  58. m_pTabFont = NULL;
  59. m_CurrPage = PAGE_AS_USERS;
  60. } // end CAllServersView ctor
  61. ///////////////////////
  62. // F'N: CAllServersView dtor
  63. //
  64. CAllServersView::~CAllServersView()
  65. {
  66. if(m_pTabs) delete m_pTabs;
  67. if(m_pTabFont) delete m_pTabFont;
  68. } // end CAllServersView dtor
  69. #ifdef _DEBUG
  70. ///////////////////////////////
  71. // F'N: CAllServersView::AssertValid
  72. //
  73. void CAllServersView::AssertValid() const
  74. {
  75. CView::AssertValid();
  76. } // end CAllServersView::AssertValid
  77. ////////////////////////
  78. // F'N: CAllServersView::Dump
  79. //
  80. void CAllServersView::Dump(CDumpContext& dc) const
  81. {
  82. CView::Dump(dc);
  83. } // end CAllServersView::Dump
  84. #endif //_DEBUG
  85. ////////////////////////////
  86. // F'N: CAllServersView::OnCreate
  87. //
  88. int CAllServersView::OnCreate(LPCREATESTRUCT lpCreateStruct)
  89. {
  90. if (CView::OnCreate(lpCreateStruct) == -1)
  91. return -1;
  92. return 0;
  93. } // end CAllServersView::OnCreate
  94. ///////////////////////////////////
  95. // F'N: CAllServersView::OnInitialUpdate
  96. //
  97. // - pointers to the pages of the sheet are obtained
  98. //
  99. void CAllServersView::OnInitialUpdate()
  100. {
  101. // Determine whether we are running under Picasso
  102. BOOL bPicasso = ((CWinAdminApp*)AfxGetApp())->IsPicasso();
  103. // create the Tabs
  104. m_pTabs = new CMyTabCtrl;
  105. if(!m_pTabs) return;
  106. m_pTabs->Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP, CRect(0,0,0,0), this, IDC_ALL_SERVERS_TABS);
  107. m_pTabFont = new CFont;
  108. if(m_pTabFont) {
  109. m_pTabFont->CreateStockObject(DEFAULT_GUI_FONT);
  110. m_pTabs->SetFont(m_pTabFont, TRUE);
  111. }
  112. TCHAR szTemp[40];
  113. CString tabString;
  114. int index = 0;
  115. for(int i = 0; i < NUMBER_OF_AS_PAGES; i++) {
  116. // If the page is shown under Picasso only and we're not running
  117. // under Picasso, skip to the next one
  118. if((pages[i].flags & PF_PICASSO_ONLY) && !bPicasso) continue;
  119. tabString.LoadString(pages[i].tabStringID);
  120. wcscpy(szTemp,tabString);
  121. AddTab(index, szTemp, i);
  122. pages[i].m_pPage = (CAdminPage*)pages[i].m_pRuntimeClass->CreateObject();
  123. pages[i].m_pPage->Create(NULL, NULL, WS_CHILD, CRect(0, 0, 0, 0), this, i, NULL);
  124. GetDocument()->AddView(pages[i].m_pPage);
  125. index++;
  126. }
  127. m_pTabs->SetCurSel(0);
  128. m_CurrPage = bPicasso ? PAGE_AS_SERVERS : PAGE_AS_USERS;
  129. // post a changepage msg to display the page for the currently selected tab
  130. // PostMessage(WM_WA_SERVER_CHANGEPAGE);
  131. } // end CAllServersView::OnInitialUpdate
  132. //////////////////////////
  133. // F'N: CAllServersView::OnSize
  134. //
  135. //
  136. //
  137. void CAllServersView::OnSize(UINT nType, int cx, int cy)
  138. {
  139. RECT rect;
  140. GetClientRect(&rect);
  141. if(m_pTabs->GetSafeHwnd()) { // make sure the Tabs object is valid
  142. m_pTabs->MoveWindow(&rect, TRUE); // size the tabs
  143. // for the next part (sizing of pages), we might want to add a member var
  144. // that keeps track of which page/tab is current... this way we could
  145. // only actually do a redraw (MoveWindow second parm == TRUE) for the
  146. // guy who is currently visible--DJM
  147. // we want to size the pages, too
  148. m_pTabs->AdjustRect(FALSE, &rect);
  149. for(int i = 0; i < NUMBER_OF_AS_PAGES; i++) {
  150. if(pages[i].m_pPage && pages[i].m_pPage->GetSafeHwnd())
  151. pages[i].m_pPage->MoveWindow(&rect, TRUE);
  152. }
  153. }
  154. } // end CAllServersView::OnSize
  155. //////////////////////////
  156. // F'N: CAllServersView::OnDraw
  157. //
  158. // - the CAllServersView and it's pages draw themselves, so there isn't anything
  159. // to do here...
  160. //
  161. void CAllServersView::OnDraw(CDC* pDC)
  162. {
  163. CDocument* pDoc = GetDocument();
  164. // TODO: add draw code here
  165. } // end CAllServersView::OnDraw
  166. /////////////////////////
  167. // F'N: CAllServersView::Reset
  168. //
  169. // - 'resets' the view
  170. //
  171. void CAllServersView::Reset(void *p)
  172. {
  173. CWaitCursor Nikki;
  174. SendMessage(WM_WA_SERVER_CHANGEPAGE); // ??? Post
  175. // Clear out the selected flags for each server
  176. // Get a pointer to our document
  177. CWinAdminDoc *doc = (CWinAdminDoc*)GetDocument();
  178. // Get a pointer to the list of servers
  179. doc->LockServerList();
  180. CObList *pServerList = doc->GetServerList();
  181. // Iterate through the Server list
  182. POSITION pos = pServerList->GetHeadPosition();
  183. while(pos) {
  184. CServer *pServer = (CServer*)pServerList->GetNext(pos);
  185. pServer->ClearAllSelected();
  186. }
  187. doc->UnlockServerList();
  188. // This is necessary until we update on the fly
  189. for(int i = 0; i < NUMBER_OF_AS_PAGES; i++) {
  190. if(pages[i].m_pPage)
  191. pages[i].m_pPage->Reset( p ); //NULL);
  192. }
  193. ((CWinAdminDoc*)GetDocument())->SetCurrentPage(m_CurrPage);
  194. } // end CAllServersView::Reset
  195. //////////////////////////
  196. // F'N: CAllServersView::AddTab
  197. //
  198. void CAllServersView::AddTab(int index, TCHAR* text, ULONG pageindex)
  199. {
  200. TC_ITEM tc;
  201. tc.mask = TCIF_TEXT | TCIF_PARAM;
  202. tc.pszText = text;
  203. tc.lParam = pageindex;
  204. m_pTabs->InsertItem(index, &tc);
  205. } // end CAllServersView::AddTab
  206. ////////////////////////////////
  207. // F'N: CAllServersView::OnChangePage
  208. //
  209. // - changes to a new server page based on currently selected tab
  210. // - OnChangePage needs to force recalculation of scroll bars!!!--DJM
  211. //
  212. // If wParam is set, sets the focus to the page. This is currently
  213. // only done when the user clicks on a tab
  214. //
  215. LRESULT CAllServersView::OnChangePage(WPARAM wParam, LPARAM lParam)
  216. {
  217. // find out which tab is now selected
  218. int tab = m_pTabs->GetCurSel();
  219. TC_ITEM tc;
  220. tc.mask = TCIF_PARAM;
  221. m_pTabs->GetItem(tab, &tc);
  222. int index = (int)tc.lParam;
  223. // switch to the appropriate view
  224. pages[m_CurrPage].m_pPage->ModifyStyle(WS_VISIBLE, WS_DISABLED);
  225. pages[m_CurrPage].m_pPage->ClearSelections();
  226. m_CurrPage = index;
  227. ((CWinAdminDoc*)GetDocument())->SetCurrentPage(index);
  228. // show the new page
  229. pages[index].m_pPage->ModifyStyle(WS_DISABLED, WS_VISIBLE);
  230. pages[index].m_pPage->ScrollToPosition(CPoint(0,0));
  231. pages[index].m_pPage->Invalidate();
  232. if( wParam )
  233. {
  234. pages[index].m_pPage->SetFocus();
  235. }
  236. // Clear out the selected flags for each server
  237. // Get a pointer to our document
  238. CWinAdminDoc *doc = (CWinAdminDoc*)GetDocument();
  239. // Get a pointer to the list of servers
  240. doc->LockServerList();
  241. CObList *pServerList = doc->GetServerList();
  242. // Iterate through the Server list
  243. POSITION pos = pServerList->GetHeadPosition();
  244. while(pos) {
  245. CServer *pServer = (CServer*)pServerList->GetNext(pos);
  246. pServer->ClearAllSelected();
  247. }
  248. doc->UnlockServerList();
  249. // If the new page is the processes page, we want to display the processes now
  250. if(index == PAGE_AS_PROCESSES)
  251. {
  252. void *pCurrentSelectedNode = ((CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument())->GetCurrentSelectedNode();
  253. CNodeType *pNodeType = ( CNodeType * )pCurrentSelectedNode;
  254. NODETYPE m;
  255. if( pNodeType == NULL )
  256. {
  257. m = NODE_NONE;
  258. }
  259. else
  260. {
  261. m = pNodeType->m_nodetype;
  262. }
  263. ((CAllServerProcessesPage*)pages[PAGE_AS_PROCESSES].m_pPage)->DisplayProcesses( m );
  264. }
  265. return 0;
  266. } // end CAllServersView::OnChangeview
  267. void CAllServersView::OnTabSelChange(NMHDR* pNMHDR, LRESULT* pResult)
  268. {
  269. ODS( L"AllServersView::OnTabSelChange\n" );
  270. OnChangePage( 0 , 0);
  271. *pResult = 0;
  272. } // end CAllServersView::OnTabSelChange
  273. LRESULT CAllServersView::OnAdminAddServer(WPARAM wParam, LPARAM lParam)
  274. {
  275. if(pages[PAGE_AS_SERVERS].m_pPage) {
  276. ((CAllServerServersPage*)pages[PAGE_AS_SERVERS].m_pPage)->AddServer((CServer*)lParam);
  277. }
  278. ((CAllServerUsersPage*)pages[PAGE_AS_USERS].m_pPage)->AddServer((CServer*)lParam);
  279. ((CAllServerWinStationsPage*)pages[PAGE_AS_WINSTATIONS].m_pPage)->AddServer((CServer*)lParam);
  280. ((CAllServerProcessesPage*)pages[PAGE_AS_PROCESSES].m_pPage)->AddServer((CServer*)lParam);
  281. if(pages[PAGE_AS_LICENSES].m_pPage) {
  282. ((CAllServerLicensesPage*)pages[PAGE_AS_LICENSES].m_pPage)->AddServer((CServer*)lParam);
  283. }
  284. return 0;
  285. } // end CAllServersView::OnAdminAddServer
  286. LRESULT CAllServersView::OnAdminRemoveServer(WPARAM wParam, LPARAM lParam)
  287. {
  288. if(pages[PAGE_AS_SERVERS].m_pPage) {
  289. ((CAllServerServersPage*)pages[PAGE_AS_SERVERS].m_pPage)->RemoveServer((CServer*)lParam);
  290. }
  291. ((CAllServerUsersPage*)pages[PAGE_AS_USERS].m_pPage)->RemoveServer((CServer*)lParam);
  292. ((CAllServerWinStationsPage*)pages[PAGE_AS_WINSTATIONS].m_pPage)->RemoveServer((CServer*)lParam);
  293. ((CAllServerProcessesPage*)pages[PAGE_AS_PROCESSES].m_pPage)->RemoveServer((CServer*)lParam);
  294. if(pages[PAGE_AS_LICENSES].m_pPage) {
  295. ((CAllServerLicensesPage*)pages[PAGE_AS_LICENSES].m_pPage)->RemoveServer((CServer*)lParam);
  296. }
  297. return 0;
  298. } // end CAllServersView::OnAdminRemoveServer
  299. LRESULT CAllServersView::OnAdminUpdateServer(WPARAM wParam, LPARAM lParam)
  300. {
  301. if(pages[PAGE_AS_SERVERS].m_pPage) {
  302. ((CAllServerServersPage*)pages[PAGE_AS_SERVERS].m_pPage)->UpdateServer((CServer*)lParam);
  303. }
  304. ((CAllServerUsersPage*)pages[PAGE_AS_USERS].m_pPage)->UpdateServer((CServer*)lParam);
  305. ((CAllServerWinStationsPage*)pages[PAGE_AS_WINSTATIONS].m_pPage)->UpdateServer((CServer*)lParam);
  306. ((CAllServerProcessesPage*)pages[PAGE_AS_PROCESSES].m_pPage)->UpdateServer((CServer*)lParam);
  307. if(pages[PAGE_AS_LICENSES].m_pPage) {
  308. ((CAllServerLicensesPage*)pages[PAGE_AS_LICENSES].m_pPage)->UpdateServer((CServer*)lParam);
  309. }
  310. return 0;
  311. } // end CAllServersView::OnAdminUpdateServer
  312. LRESULT CAllServersView::OnAdminUpdateProcesses(WPARAM wParam, LPARAM lParam)
  313. {
  314. ((CAllServerProcessesPage*)pages[PAGE_AS_PROCESSES].m_pPage)->UpdateProcesses((CServer*)lParam);
  315. return 0;
  316. } // end CAllServersView::OnAdminUpdateProcesses
  317. LRESULT CAllServersView::OnAdminRemoveProcess(WPARAM wParam, LPARAM lParam)
  318. {
  319. ((CAllServerProcessesPage*)pages[PAGE_AS_PROCESSES].m_pPage)->RemoveProcess((CProcess*)lParam);
  320. return 0;
  321. } // end CAllServersView::OnAdminRemoveProcess
  322. LRESULT CAllServersView::OnAdminRedisplayProcesses(WPARAM wParam, LPARAM lParam)
  323. {
  324. NODETYPE m;
  325. CNodeType *pNodeType = ( CNodeType * )lParam;
  326. if( pNodeType == NULL )
  327. {
  328. m = NODE_NONE;
  329. }
  330. else
  331. {
  332. m = pNodeType->m_nodetype;
  333. }
  334. ((CAllServerProcessesPage*)pages[PAGE_AS_PROCESSES].m_pPage)->DisplayProcesses( m );
  335. return 0;
  336. } // end CAllServersView::OnAdminRedisplayProcesses
  337. LRESULT CAllServersView::OnAdminUpdateWinStations(WPARAM wParam, LPARAM lParam)
  338. {
  339. ((CAllServerUsersPage*)pages[PAGE_AS_USERS].m_pPage)->UpdateWinStations((CServer*)lParam);
  340. ((CAllServerWinStationsPage*)pages[PAGE_AS_WINSTATIONS].m_pPage)->UpdateWinStations((CServer*)lParam);
  341. return 0;
  342. } // end CAllServersView::OnAdminUpdateWinStations
  343. LRESULT CAllServersView::OnAdminUpdateServerInfo(WPARAM wParam, LPARAM lParam)
  344. {
  345. if(pages[PAGE_AS_SERVERS].m_pPage)
  346. ((CAllServerServersPage*)pages[PAGE_AS_SERVERS].m_pPage)->UpdateServer((CServer*)lParam);
  347. if(pages[PAGE_AS_LICENSES].m_pPage)
  348. ((CAllServerLicensesPage*)pages[PAGE_AS_LICENSES].m_pPage)->DisplayLicenseCounts();
  349. return 0;
  350. } // end CAllServersView::OnAdminUpdateServerInfo
  351. LRESULT CAllServersView::OnAdminRedisplayLicenses(WPARAM wParam, LPARAM lParam)
  352. {
  353. if(pages[PAGE_AS_LICENSES].m_pPage)
  354. ((CAllServerLicensesPage*)pages[PAGE_AS_LICENSES].m_pPage)->Reset((CServer*)lParam);
  355. return 0;
  356. } // end CAllServersView::OnAdminRedisplayLicenses
  357. //=-------------------------------------------------------------------------
  358. // OnTabbed is called when the mainframe received VK_TAB
  359. // this hacked fix takes advantage of the known ui layout of tsadmin
  360. // we know we are in either three places -- treeview tabctrl listctrl
  361. // tabbing is a forward motion so focus is moved with respect to the layout
  362. // this code is duplicated in all view classes
  363. //
  364. LRESULT CAllServersView::OnTabbed( WPARAM wp , LPARAM lp )
  365. {
  366. ODS( L"CAllServersView::OnTabbed " );
  367. if( m_pTabs != NULL )
  368. {
  369. CWinAdminDoc *pDoc = (CWinAdminDoc*)GetDocument();
  370. if( pDoc != NULL )
  371. {
  372. FOCUS_STATE nFocus = pDoc->GetLastRegisteredFocus( );
  373. //
  374. // treeview should've started off with initial focus
  375. // we should
  376. if( nFocus == TREE_VIEW )
  377. {
  378. ODS( L"from tree to tab\n" );
  379. int nTab = m_pTabs->GetCurSel();
  380. m_pTabs->SetFocus( );
  381. m_pTabs->SetCurFocus( nTab );
  382. pDoc->RegisterLastFocus( TAB_CTRL );
  383. }
  384. else if( nFocus == TAB_CTRL )
  385. {
  386. ODS( L"from tab to item\n" );
  387. // set focus to item in page
  388. pages[ m_CurrPage ].m_pPage->SetFocus( );
  389. pDoc->RegisterLastFocus( PAGED_ITEM );
  390. }
  391. else
  392. {
  393. ODS( L"from item to treeview\n" );
  394. // set focus back to treeview
  395. CFrameWnd *p = (CFrameWnd*)pDoc->GetMainWnd();
  396. p->SendMessage( WM_FORCE_TREEVIEW_FOCUS , 0 , 0 );
  397. pDoc->RegisterLastFocus( TREE_VIEW );
  398. }
  399. pDoc->SetPrevFocus( nFocus );
  400. }
  401. }
  402. return 0;
  403. }
  404. //=-------------------------------------------------------------------------
  405. // OnShiftTabbed is called when the user wants to go back one
  406. // this code is duplicated in all view classes
  407. LRESULT CAllServersView::OnShiftTabbed( WPARAM , LPARAM )
  408. {
  409. ODS( L"CAllServersView::OnShiftTabbed " );
  410. if( m_pTabs != NULL )
  411. {
  412. CWinAdminDoc *pDoc = (CWinAdminDoc*)GetDocument();
  413. if( pDoc != NULL )
  414. {
  415. FOCUS_STATE nFocus = pDoc->GetLastRegisteredFocus( );
  416. switch( nFocus )
  417. {
  418. case TREE_VIEW:
  419. ODS( L"going back from tree to paged item\n" );
  420. pages[ m_CurrPage ].m_pPage->SetFocus( );
  421. pDoc->RegisterLastFocus( PAGED_ITEM );
  422. break;
  423. case TAB_CTRL:
  424. {
  425. ODS( L"going back from tab to treeview\n" );
  426. CFrameWnd *p = (CFrameWnd*)pDoc->GetMainWnd();
  427. p->SendMessage( WM_FORCE_TREEVIEW_FOCUS , 0 , 0 );
  428. pDoc->RegisterLastFocus( TREE_VIEW );
  429. }
  430. break;
  431. case PAGED_ITEM:
  432. {
  433. ODS( L"going back from paged item to tab\n" );
  434. int nTab = m_pTabs->GetCurSel();
  435. m_pTabs->SetFocus( );
  436. m_pTabs->SetCurFocus( nTab );
  437. pDoc->RegisterLastFocus( TAB_CTRL );
  438. }
  439. break;
  440. }
  441. pDoc->SetPrevFocus( nFocus );
  442. }
  443. }
  444. return 0;
  445. }
  446. //=-------------------------------------------------------------------------
  447. // ctrl + tab works the same as tab but because of our unorthodox ui
  448. // when under a tab control it will cycle over the tabs and back to the treeview
  449. //
  450. LRESULT CAllServersView::OnCtrlTabbed( WPARAM , LPARAM )
  451. {
  452. ODS( L"CAllServersView::OnCtrlTabbed " );
  453. int nTab;
  454. int nMaxTab;
  455. if( m_pTabs != NULL )
  456. {
  457. CWinAdminDoc *pDoc = (CWinAdminDoc*)GetDocument();
  458. if( pDoc != NULL )
  459. {
  460. FOCUS_STATE nFocus = pDoc->GetLastRegisteredFocus( );
  461. if( nFocus == TREE_VIEW )
  462. {
  463. ODS( L"from tree to tab\n" );
  464. nTab = m_pTabs->GetCurSel();
  465. nMaxTab = m_pTabs->GetItemCount( );
  466. if( nTab >= nMaxTab - 1 )
  467. {
  468. m_pTabs->SetCurSel( 0 );
  469. OnChangePage( 0 , 0 );
  470. nTab = 0;
  471. }
  472. m_pTabs->SetFocus( );
  473. m_pTabs->SetCurFocus( nTab );
  474. pDoc->RegisterLastFocus( TAB_CTRL );
  475. }
  476. else
  477. {
  478. nTab = m_pTabs->GetCurSel();
  479. nMaxTab = m_pTabs->GetItemCount( );
  480. if( nTab >= nMaxTab - 1 )
  481. {
  482. ODS( L"...back to treeview\n" );
  483. CFrameWnd *p = (CFrameWnd*)pDoc->GetMainWnd();
  484. p->SendMessage( WM_FORCE_TREEVIEW_FOCUS , 0 , 0 );
  485. pDoc->RegisterLastFocus( TREE_VIEW );
  486. }
  487. else
  488. {
  489. ODS( L" ...next tab...\n" );
  490. m_pTabs->SetCurSel( nTab + 1 );
  491. OnChangePage( 0 , 0 );
  492. m_pTabs->SetFocus( );
  493. m_pTabs->SetCurFocus( nTab + 1 );
  494. }
  495. }
  496. pDoc->SetPrevFocus( nFocus );
  497. }
  498. }
  499. return 0;
  500. }
  501. //=----------------------------------------------------------------------------
  502. // same as OnCtrlTab but we focus on moving in the other direction
  503. // tree_view to last tab -- current tab to ct - 1
  504. //
  505. LRESULT CAllServersView::OnCtrlShiftTabbed( WPARAM , LPARAM )
  506. {
  507. ODS( L"CAllServersView::OnCtrlShiftTabbed " );
  508. int nTab;
  509. int nMaxTab;
  510. if( m_pTabs != NULL )
  511. {
  512. CWinAdminDoc *pDoc = (CWinAdminDoc*)GetDocument();
  513. if( pDoc != NULL )
  514. {
  515. FOCUS_STATE nFocus = pDoc->GetLastRegisteredFocus( );
  516. if( nFocus == TREE_VIEW )
  517. {
  518. ODS( L"from tree to tab\n" );
  519. nMaxTab = m_pTabs->GetItemCount( );
  520. m_pTabs->SetCurSel( nMaxTab - 1 );
  521. OnChangePage( 0 , 0 );
  522. m_pTabs->SetFocus( );
  523. m_pTabs->SetCurFocus( nMaxTab - 1 );
  524. pDoc->RegisterLastFocus( TAB_CTRL );
  525. }
  526. else
  527. {
  528. nTab = m_pTabs->GetCurSel();
  529. nMaxTab = m_pTabs->GetItemCount( );
  530. if( nTab > 0 )
  531. {
  532. ODS( L" ...next tab...\n" );
  533. m_pTabs->SetCurSel( nTab - 1 );
  534. OnChangePage( 0 , 0 );
  535. m_pTabs->SetFocus( );
  536. m_pTabs->SetCurFocus( nTab - 1 );
  537. }
  538. else
  539. {
  540. ODS( L"...back to treeview\n" );
  541. CFrameWnd *p = (CFrameWnd*)pDoc->GetMainWnd();
  542. p->SendMessage( WM_FORCE_TREEVIEW_FOCUS , 0 , 0 );
  543. pDoc->RegisterLastFocus( TREE_VIEW );
  544. }
  545. }
  546. pDoc->SetPrevFocus( nFocus );
  547. }
  548. }
  549. return 0;
  550. }
  551. //=----------------------------------------------------------------------------
  552. // When the user hits F6 we need to switch between pains
  553. LRESULT CAllServersView::OnNextPane( WPARAM , LPARAM )
  554. {
  555. ODS( L"CAllServersView::OnNextPane\n" );
  556. int nTab;
  557. int nMaxTab;
  558. if( m_pTabs != NULL )
  559. {
  560. CWinAdminDoc *pDoc = (CWinAdminDoc*)GetDocument();
  561. if( pDoc != NULL )
  562. {
  563. FOCUS_STATE nFocus = pDoc->GetLastRegisteredFocus( );
  564. FOCUS_STATE nPrevFocus = pDoc->GetPrevFocus( );
  565. if( nFocus == TREE_VIEW )
  566. {
  567. if( nPrevFocus == TAB_CTRL )
  568. {
  569. int nTab = m_pTabs->GetCurSel();
  570. m_pTabs->SetFocus( );
  571. m_pTabs->SetCurFocus( nTab );
  572. pDoc->RegisterLastFocus( TAB_CTRL );
  573. }
  574. else
  575. {
  576. pages[ m_CurrPage ].m_pPage->SetFocus( );
  577. pDoc->RegisterLastFocus( PAGED_ITEM );
  578. }
  579. }
  580. else
  581. {
  582. CFrameWnd *p = (CFrameWnd*)pDoc->GetMainWnd();
  583. p->SendMessage( WM_FORCE_TREEVIEW_FOCUS , 0 , 0 );
  584. pDoc->RegisterLastFocus( TREE_VIEW );
  585. }
  586. pDoc->SetPrevFocus( nFocus );
  587. }
  588. }
  589. return 0;
  590. }