Leaked source code of windows server 2003
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.

758 lines
21 KiB

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