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.

1518 lines
43 KiB

  1. //Copyright (c) 1998 - 1999 Microsoft Corporation
  2. /*******************************************************************************
  3. *
  4. * appsvvw.cpp
  5. *
  6. * implementation of the CAppServerView class
  7. *
  8. * copyright notice: Copyright 1994, Citrix Systems Inc.
  9. *
  10. * $Author: butchd $ Butch Davis
  11. *
  12. * $Log: M:\nt\private\utils\citrix\winutils\wincfg\VCS\appsvvw.cpp $
  13. *
  14. * Rev 1.24 22 Oct 1997 09:43:52 butchd
  15. * MS changes: added r-button popup menu
  16. *
  17. * Rev 1.23 19 Jun 1997 19:21:12 kurtp
  18. * update
  19. *
  20. * Rev 1.22 25 Mar 1997 08:59:52 butchd
  21. * update
  22. *
  23. * Rev 1.21 21 Mar 1997 16:25:52 butchd
  24. * update
  25. *
  26. * Rev 1.20 04 Mar 1997 08:35:16 butchd
  27. * update
  28. *
  29. * Rev 1.19 24 Sep 1996 16:21:24 butchd
  30. * update
  31. *
  32. * Rev 1.18 13 Sep 1996 17:57:06 butchd
  33. * update
  34. *
  35. * Rev 1.17 12 Sep 1996 16:15:52 butchd
  36. * update
  37. *
  38. *******************************************************************************/
  39. /*
  40. * include files
  41. */
  42. #include "stdafx.h"
  43. #include "wincfg.h"
  44. #include "rowview.h"
  45. #include "appsvdoc.h"
  46. #include "appsvvw.h"
  47. #ifdef _DEBUG
  48. #undef THIS_FILE
  49. static char BASED_CODE THIS_FILE[] = __FILE__;
  50. #endif
  51. extern CWincfgApp *pApp;
  52. ////////////////////////////////////////////////////////////////////////////////
  53. // CAppServerView class implementation / construction, destruction
  54. IMPLEMENT_DYNCREATE(CAppServerView, CRowView)
  55. /*******************************************************************************
  56. *
  57. * CAppServerView - CAppServerView constructor
  58. *
  59. * ENTRY:
  60. * EXIT:
  61. *
  62. ******************************************************************************/
  63. CAppServerView::CAppServerView()
  64. {
  65. m_nActiveRow = 0;
  66. m_bThumbTrack = FALSE; // Turn off thumbtrack scrolling
  67. } // end CAppServerView::CAppServerView
  68. /*******************************************************************************
  69. *
  70. * CAppServerView - CAppServerView destructor
  71. *
  72. * ENTRY:
  73. * EXIT:
  74. *
  75. ******************************************************************************/
  76. CAppServerView::~CAppServerView()
  77. {
  78. } // end CAppServerView::~CAppServerView
  79. ////////////////////////////////////////////////////////////////////////////////
  80. // CAppServerView class override member functions
  81. /*******************************************************************************
  82. *
  83. * GetDocument - CAppServerDoc member function: CView class override
  84. *
  85. * Return a pointer to this view's document.
  86. *
  87. * (Refer to the MFC CView::GetDocument documentation)
  88. *
  89. ******************************************************************************/
  90. CAppServerDoc*
  91. CAppServerView::GetDocument()
  92. {
  93. VERIFY ( m_pDocument->IsKindOf( RUNTIME_CLASS(CAppServerDoc) ) );
  94. return ( (CAppServerDoc*)m_pDocument );
  95. } // end CAppServerView::GetDocument
  96. /*******************************************************************************
  97. *
  98. * OnUpdate - CAppServerDoc member function: CView class override
  99. *
  100. * Respond to a change in this view's document.
  101. *
  102. * (Refer to the MFC CView::OnUpdate documentation)
  103. *
  104. ******************************************************************************/
  105. void
  106. CAppServerView::OnUpdate( CView* pSender,
  107. LPARAM lHint,
  108. CObject* pHint )
  109. {
  110. /*
  111. * OnUpdate() is called whenever the document has changed and,
  112. * Therefore, the view needs to redisplay some or all of itself.
  113. */
  114. if ( (pHint != NULL) &&
  115. (pHint->IsKindOf(RUNTIME_CLASS(CWinStationListObjectHint))) ) {
  116. CWinStationListObjectHint *pWSLOHint =
  117. (CWinStationListObjectHint *)pHint;
  118. /*
  119. * If the hint's WinStation object pointer is not NULL, determine
  120. * if the view's fields need to expand, resetting the view if so.
  121. * Otherwise, just update the WinStation's row.
  122. */
  123. if ( pWSLOHint->m_pWSLObject &&
  124. CalculateFieldMaximums( pWSLOHint->m_pWSLObject,
  125. NULL, FALSE ) )
  126. ResetView(FALSE);
  127. else
  128. UpdateRow(pWSLOHint->m_WSLIndex);
  129. } else
  130. /*
  131. * Reset the entire view with new field calculations.
  132. */
  133. ResetView(TRUE);
  134. } // end CAppServerView::OnUpdate
  135. /*******************************************************************************
  136. *
  137. * GetRowWidthHeight -
  138. * CAppServerView member function: CRowView class override
  139. *
  140. * Get the view row width and height (based on current font).
  141. *
  142. * ENTRY:
  143. *
  144. * pDC (input)
  145. * Points to the current CDC device-context object for the view.
  146. *
  147. * nRowWidth (input)
  148. * (REFERENCE) the variable to set to the current row width, in
  149. * device units.
  150. *
  151. * nRowHeight (input)
  152. * (REFERENCE) the variable to set to the current row height, in
  153. * device units.
  154. *
  155. * EXIT:
  156. *
  157. ******************************************************************************/
  158. void
  159. CAppServerView::GetRowWidthHeight( CDC* pDC,
  160. int& nRowWidth,
  161. int& nRowHeight )
  162. {
  163. int nDeviceTechnology;
  164. /*
  165. * If the previous CalculateFieldMaximums() calculations were made for
  166. * a different device type than this CDC is associated with, we must call
  167. * it again (with the CDC given here).
  168. *
  169. * BUGBUG: What about print-preview? May need to compare mapping
  170. * modes (etc...) as well as device technology. This may not work as is...
  171. */
  172. if ( (nDeviceTechnology = pDC->GetDeviceCaps( TECHNOLOGY )) !=
  173. m_nLatestDeviceTechnology ) {
  174. CalculateFieldMaximums( NULL, pDC, TRUE );
  175. m_nLatestDeviceTechnology = nDeviceTechnology;
  176. }
  177. /*
  178. * Set the row width.
  179. */
  180. nRowWidth = m_tmTotalWidth;
  181. /*
  182. * Always allow enough room for the bitmap height (plus one pixel spacing
  183. * on top and bottom) regardless of the font height.
  184. */
  185. if ( m_tmFontHeight > (BITMAP_HEIGHT + 2) )
  186. nRowHeight = m_tmFontHeight;
  187. else
  188. nRowHeight = BITMAP_HEIGHT + 2;
  189. } // end CAppServerView::GetRowWidthHeight
  190. /*******************************************************************************
  191. *
  192. * GetActiveRow -
  193. * CAppServerView member function: CRowView class override
  194. *
  195. * Get the currently active (highlighted) row in this view.
  196. *
  197. * ENTRY:
  198. *
  199. * EXIT:
  200. * (int)
  201. * active row for the view (from m_nActiveRow member variable).
  202. *
  203. ******************************************************************************/
  204. int
  205. CAppServerView::GetActiveRow()
  206. {
  207. return (m_nActiveRow);
  208. } // end CAppServerView::GetActiveRow
  209. /*******************************************************************************
  210. *
  211. * GetRowCount -
  212. * CAppServerView member function: CRowView class override
  213. *
  214. * Get the total number of rows in the current view.
  215. *
  216. * ENTRY:
  217. *
  218. * EXIT:
  219. * (int)
  220. * number of rows (# of WinStationList items) in the document.
  221. *
  222. ******************************************************************************/
  223. int
  224. CAppServerView::GetRowCount()
  225. {
  226. return ( GetDocument()->GetWSLCount() );
  227. } // end CAppServerView::GetRowCount
  228. /*******************************************************************************
  229. *
  230. * ChangeSelectionNextRow -
  231. * CAppServerView member function: CRowView class override
  232. *
  233. * Get the total number of rows in the current view.
  234. *
  235. * ENTRY:
  236. *
  237. * bNext (input)
  238. * if TRUE, changes the view to select the next row;
  239. * otherwise (FALSE), changes view to select previous row.
  240. * This function won't do next or previous if boundry error would
  241. * occur (list overrun or underrun).
  242. *
  243. * EXIT:
  244. *
  245. ******************************************************************************/
  246. void
  247. CAppServerView::ChangeSelectionNextRow( BOOL bNext )
  248. {
  249. if ( bNext ) {
  250. if ( m_nActiveRow < (GetRowCount() - 1) )
  251. UpdateRow( ++m_nActiveRow );
  252. } else {
  253. if ( m_nActiveRow > 0 )
  254. UpdateRow( --m_nActiveRow );
  255. }
  256. } // end CAppServerView::ChangeSelectionNextRow
  257. /*******************************************************************************
  258. *
  259. * ChangeSelectionToRow -
  260. * CAppServerView member function: CRowView class override
  261. *
  262. * Cause the specified view row to be selected.
  263. *
  264. * ENTRY:
  265. *
  266. * nRow (input)
  267. * view row to select.
  268. *
  269. * EXIT:
  270. *
  271. ******************************************************************************/
  272. void
  273. CAppServerView::ChangeSelectionToRow( int nRow )
  274. {
  275. UpdateRow( m_nActiveRow = nRow );
  276. } // end CAppServerView::ChangeSelectionToRow
  277. /*******************************************************************************
  278. *
  279. * OnDrawRow -
  280. * CAppServerView member function: CRowView class override
  281. *
  282. * Draw the specified row on the view.
  283. *
  284. * ENTRY:
  285. *
  286. * pDC (input)
  287. * Points to the current CDC device-context object for the view
  288. * to draw with (containing DC to draw into).
  289. *
  290. * nRow (input)
  291. * view row to draw (for obtaining document information).
  292. *
  293. * y (input)
  294. * y-position (in device coordinates) to draw the row at.
  295. *
  296. * bSelected (input)
  297. * TRUE if the row is currently selected (for highlighting);
  298. * FALSE otherwise.
  299. *
  300. * EXIT:
  301. *
  302. ******************************************************************************/
  303. void
  304. CAppServerView::OnDrawRow( CDC* pDC,
  305. int nRow,
  306. int y,
  307. BOOL bSelected )
  308. {
  309. int x;
  310. CFont * pOldFont;
  311. CBrush BackgroundBrush;
  312. /*
  313. * Select the app's font into the DC.
  314. */
  315. pOldFont = pDC->SelectObject(&(pApp->m_font));
  316. /*
  317. * Get the data for the specific WinStation list item.
  318. */
  319. PWSLOBJECT pWSLObject = GetDocument()->GetWSLObject(nRow);
  320. if ( !pWSLObject )
  321. return;
  322. /*
  323. * Prepare for highlighting or un-highlighting the check, depending
  324. * on whether it is the currently selected check or not. And
  325. * paint the background (behind the text) accordingly.
  326. */
  327. /*
  328. * save colors for drawing selected item on the screen
  329. */
  330. COLORREF crOldText = 0;
  331. COLORREF crOldBackground = 0;
  332. if ( !pDC->IsPrinting() ) {
  333. /*
  334. * Create the proper background and text colors based on whether
  335. * WinStation selection state, operation state, and enabled/disabled.
  336. */
  337. if ( bSelected ) {
  338. BackgroundBrush.CreateSolidBrush( GetSysColor(COLOR_HIGHLIGHT) );
  339. crOldBackground = pDC->SetBkColor( GetSysColor(COLOR_HIGHLIGHT) );
  340. crOldText = pDC->SetTextColor( GetSysColor(COLOR_HIGHLIGHTTEXT) );
  341. } else {
  342. BackgroundBrush.CreateSolidBrush( GetSysColor(COLOR_WINDOW) );
  343. crOldBackground = pDC->SetBkColor( GetSysColor(COLOR_WINDOW) );
  344. crOldText = pDC->SetTextColor(
  345. GetSysColor( pWSLObject->m_Flags & WSL_ENABLED ?
  346. COLOR_WINDOWTEXT : COLOR_GRAYTEXT ) );
  347. }
  348. /*
  349. * Fill the row with background color.
  350. */
  351. CRect rectSelection;
  352. pDC->GetClipBox( &rectSelection );
  353. rectSelection.top = y;
  354. rectSelection.bottom = y + m_nRowHeight;
  355. pDC->FillRect( &rectSelection, &BackgroundBrush );
  356. }
  357. /*
  358. * Display the class bitmap.
  359. */
  360. {
  361. CDC BitmapDC;
  362. CBitmap Bitmap, *pOldBitmap;
  363. UINT BitmapID;
  364. TEXTMETRIC tm;
  365. switch ( pWSLObject->m_SdClass ) {
  366. case SdAsync:
  367. BitmapID = (pWSLObject->m_Flags & WSL_ENABLED) ?
  368. ((pWSLObject->m_Flags & WSL_DIRECT_ASYNC) ?
  369. IDB_ASYNCDE :
  370. ((pWSLObject->m_Flags & WSL_MUST_REBOOT) ?
  371. IDB_ASYNCMER : IDB_ASYNCME)) :
  372. ((pWSLObject->m_Flags & WSL_DIRECT_ASYNC) ?
  373. IDB_ASYNCDD : IDB_ASYNCMD);
  374. break;
  375. case SdNetwork:
  376. BitmapID = (pWSLObject->m_Flags & WSL_ENABLED) ?
  377. IDB_NETWORKE : IDB_NETWORKD;
  378. break;
  379. case SdNasi:
  380. BitmapID = (pWSLObject->m_Flags & WSL_ENABLED) ?
  381. IDB_NASIE : IDB_NASID;
  382. break;
  383. case SdConsole:
  384. BitmapID = (pWSLObject->m_Flags & WSL_ENABLED) ?
  385. IDB_CONSOLEE : IDB_CONSOLED;
  386. break;
  387. case SdOemTransport:
  388. BitmapID = (pWSLObject->m_Flags & WSL_ENABLED) ?
  389. IDB_OEMTDE : IDB_OEMTDD;
  390. break;
  391. }
  392. Bitmap.LoadBitmap( BitmapID );
  393. BitmapDC.CreateCompatibleDC( pDC );
  394. pOldBitmap = BitmapDC.SelectObject( &Bitmap );
  395. pDC->GetTextMetrics(&tm);
  396. pDC->BitBlt( BITMAP_X, (tm.tmHeight > (BITMAP_HEIGHT + 2)) ?
  397. (y + ((tm.tmHeight - BITMAP_HEIGHT) / 2)) : (y + 1),
  398. BITMAP_WIDTH, BITMAP_HEIGHT, &BitmapDC,
  399. 0, 0, (bSelected ? MERGEPAINT : SRCAND) );
  400. BitmapDC.SelectObject( pOldBitmap );
  401. }
  402. x = BITMAP_END + m_tmSpacerWidth;
  403. /*
  404. * Display the WinStation Name.
  405. */
  406. pDC->TextOut( x, y,
  407. pWSLObject->m_WinStationName,
  408. lstrlen(pWSLObject->m_WinStationName) );
  409. /*
  410. * Display the Transport Name (1st Pd).
  411. */
  412. pDC->TextOut( (x += m_tmMaxWSNameWidth + m_tmSpacerWidth),
  413. y, pWSLObject->m_PdName,
  414. lstrlen(pWSLObject->m_PdName) );
  415. /*
  416. * Display the Wd Name (Type).
  417. */
  418. pDC->TextOut( (x += m_tmMaxPdNameWidth + m_tmSpacerWidth),
  419. y, pWSLObject->m_WdName,
  420. lstrlen(pWSLObject->m_WdName) );
  421. /*
  422. * Display the WinStation Comment (including prefixed device name for
  423. * SdAsync and single-instance PdOemTransport display).
  424. */
  425. {
  426. TCHAR szBuffer[WINSTATIONCOMMENT_LENGTH + lengthof(pWSLObject->m_DeviceName) + 2];
  427. if ( (pWSLObject->m_SdClass == SdAsync) ||
  428. ((pWSLObject->m_SdClass == SdOemTransport) &&
  429. (pWSLObject->m_Flags & WSL_SINGLE_INST)) ) {
  430. lstrcpy( szBuffer, pWSLObject->m_DeviceName );
  431. lstrcat( szBuffer, TEXT(": ") );
  432. } else {
  433. szBuffer[0] = TEXT('\0');
  434. }
  435. lstrcat( szBuffer, pWSLObject->m_Comment );
  436. pDC->TextOut( (x += m_tmMaxWdNameWidth + m_tmSpacerWidth),
  437. y, szBuffer, lstrlen(szBuffer) );
  438. }
  439. /*
  440. * Restore the DC.
  441. */
  442. if ( !pDC->IsPrinting() ) {
  443. pDC->SetBkColor(crOldBackground);
  444. pDC->SetTextColor(crOldText);
  445. }
  446. /*
  447. * Restore the old font.
  448. */
  449. pDC->SelectObject(pOldFont);
  450. } // end CAppServerView::OnDrawRow
  451. /*******************************************************************************
  452. *
  453. * OnDrawHeaderBar -
  454. * CAppServerView member function: CRowView class override
  455. *
  456. * Draw the view's header bar.
  457. *
  458. * ENTRY:
  459. *
  460. * pDC (input)
  461. * Points to the current CDC device-context object for the header bar.
  462. *
  463. * y (input)
  464. * y-position (in device coordinates) to draw header bar text at.
  465. *
  466. * EXIT:
  467. *
  468. ******************************************************************************/
  469. void
  470. CAppServerView::OnDrawHeaderBar( CDC* pDC,
  471. int y )
  472. {
  473. /*
  474. * Select the header bar font, background drawing mode, text color, and
  475. * background color.
  476. */
  477. HGDIOBJ hOldFont = pDC->SelectObject( m_pHeaderBar->GetFont() );
  478. int nOldMode = pDC->SetBkMode( TRANSPARENT );
  479. COLORREF crTextColor = pDC->SetTextColor( GetSysColor( COLOR_BTNTEXT ) );
  480. COLORREF crBkColor = pDC->SetBkColor( GetSysColor( COLOR_BTNFACE ) );
  481. /*
  482. * Modify the window (DC) viewport origin to account for the current
  483. * horizontal scrolling state of the attached view.
  484. */
  485. CPoint ptVpOrg = -GetDeviceScrollPosition();
  486. ptVpOrg.y = 0;
  487. pDC->SetViewportOrg( ptVpOrg );
  488. /*
  489. * Display header text and dividing bars.
  490. */
  491. CString str;
  492. int x = BITMAP_END + m_tmSpacerWidth;
  493. /*
  494. * Display the WinStation Name header
  495. */
  496. str.LoadString( IDS_HEADER_WINSTATIONNAME );
  497. pDC->TextOut( x, y, str, lstrlen(str) );
  498. pDC->MoveTo( x-3, y );
  499. pDC->LineTo( x-3, y + m_tmFontHeight );
  500. /*
  501. * Display the Transport header.
  502. */
  503. str.LoadString( IDS_HEADER_TRANSPORTNAME );
  504. pDC->TextOut( (x += m_tmMaxWSNameWidth + m_tmSpacerWidth),
  505. y, str, lstrlen(str) );
  506. pDC->MoveTo( x-3, y );
  507. pDC->LineTo( x-3, y + m_tmFontHeight );
  508. /*
  509. * Display the Type header
  510. */
  511. str.LoadString( IDS_HEADER_TYPENAME );
  512. pDC->TextOut( (x += m_tmMaxPdNameWidth + m_tmSpacerWidth),
  513. y, str, lstrlen(str) );
  514. pDC->MoveTo( x-3, y );
  515. pDC->LineTo( x-3, y + m_tmFontHeight );
  516. /*
  517. * Display the WinStation Comment header
  518. */
  519. str.LoadString( IDS_HEADER_COMMENT );
  520. pDC->TextOut( (x += m_tmMaxWdNameWidth + m_tmSpacerWidth),
  521. y, str, lstrlen(str) );
  522. pDC->MoveTo( x-3, y );
  523. pDC->LineTo( x-3, y + m_tmFontHeight );
  524. /*
  525. * Select the original stuff back into the DC.
  526. */
  527. pDC->SelectObject( hOldFont );
  528. pDC->SetBkMode( nOldMode );
  529. pDC->SetTextColor( crTextColor );
  530. pDC->SetBkColor( crBkColor );
  531. } // end CAppServerView::OnDrawHeaderBar
  532. /*******************************************************************************
  533. *
  534. * ResetHeaderBar - CAppServerView member function: CRowView class override
  535. *
  536. * Set the font for the header bar and call the CRowView ResetHeaderBar()
  537. * member function.
  538. *
  539. ******************************************************************************/
  540. void
  541. CAppServerView::ResetHeaderBar()
  542. {
  543. /*
  544. * Set the header bar's font to the app's current font.
  545. *
  546. * BUGBUG: we may want to have the header font be different from the
  547. * view (app) font. It could be set here.
  548. */
  549. m_pHeaderBar->SetFont( &(((CWincfgApp *)AfxGetApp())->m_font) );
  550. /*
  551. * Call the CRowView ResetHeaderBar member function to finish up.
  552. */
  553. CRowView::ResetHeaderBar();
  554. } // end CAppServerView::ResetHeaderBar
  555. ////////////////////////////////////////////////////////////////////////////////
  556. // CAppServerView operations
  557. /*******************************************************************************
  558. *
  559. * ResetView - CAppServerView member function: public operation
  560. *
  561. * Reset the view for complete update, including the header bar.
  562. *
  563. * ENTRY:
  564. * bCalculateFieldMaximums (input)
  565. * TRUE if request to recalculate the maximum sizes of each field in
  566. * the view, based on the current WSL contents; FALSE otherwise.
  567. *
  568. * EXIT:
  569. *
  570. ******************************************************************************/
  571. void
  572. CAppServerView::ResetView( BOOL bCalculateFieldMaximums )
  573. {
  574. /*
  575. * Calculate field maximum values if requested (default to screen DC).
  576. * The bCalculateFieldMaximums flag will generally be set to TRUE when
  577. * ResetView is called after a font change or for complete view reset;
  578. * FALSE when called after a row update (change) has occurred that was
  579. * already handled by an explicit CalculateFieldMaximums() call.
  580. */
  581. if ( bCalculateFieldMaximums )
  582. CalculateFieldMaximums( NULL, NULL, TRUE );
  583. /*
  584. * Reset the header bar, which will cause the parent frame's layout to be
  585. * recalculated.
  586. */
  587. ResetHeaderBar();
  588. /*
  589. * Invalidate the entire view to cause full repaint and update the scroll
  590. * sizes for this view.
  591. */
  592. Invalidate();
  593. UpdateScrollSizes();
  594. } // end CAppServerView::ResetView
  595. /*******************************************************************************
  596. *
  597. * CalculateFieldMaximums - CAppServerView member function: private operation
  598. *
  599. * Recalculate the maximum width for each display field in the view.
  600. *
  601. * ENTRY:
  602. * pWSLObject (input)
  603. * Points to WSLObject to use for new maximum calculation; if this is
  604. * NULL, then will traverse the entire WSL to recalculate maximums.
  605. * pEntryDC (input)
  606. * Points to the CDC object to use for the GetTextExtent() calls; if
  607. * NULL then will open up a screen DC to use.
  608. * bResetDefaults (input)
  609. * TRUE to reset the minimum field sizes to the sizes of the header
  610. * bar text for each field; FALSE for no such reset.
  611. *
  612. * EXIT:
  613. * (BOOL) TRUE if new maximum(s) were set; FALSE otherwise.
  614. *
  615. ******************************************************************************/
  616. BOOL
  617. CAppServerView::CalculateFieldMaximums( PWSLOBJECT pWSLObject,
  618. CDC * pEntryDC,
  619. BOOL bResetDefaults )
  620. {
  621. BOOL bNewMaximums = FALSE;
  622. TEXTMETRIC tm;
  623. CDC *pDC, DC;
  624. CFont * pOldFont;
  625. /*
  626. * If the given CDC is NULL, open up a screen DC and point to it.
  627. * Otherwise, point to the one given.
  628. */
  629. if ( pEntryDC == NULL ) {
  630. DC.CreateCompatibleDC( NULL );
  631. pDC = &DC;
  632. } else
  633. pDC = pEntryDC;
  634. /*
  635. * Select the app's font into the DC and get the text metrics.
  636. */
  637. pOldFont = pDC->SelectObject( &(pApp->m_font) );
  638. pDC->GetTextMetrics( &tm );
  639. /*
  640. * If the bResetDefaults flag is TRUE, establish the default field
  641. * widths based on the width required for the field's header.
  642. */
  643. if ( bResetDefaults ) {
  644. CString str;
  645. str.LoadString( IDS_HEADER_TRANSPORTNAME );
  646. m_tmMaxPdNameWidth = (pDC->GetTextExtent( str, lstrlen(str) )).cx;
  647. str.LoadString( IDS_HEADER_WINSTATIONNAME );
  648. m_tmMaxWSNameWidth = (pDC->GetTextExtent( str, lstrlen(str) )).cx;
  649. str.LoadString( IDS_HEADER_TYPENAME );
  650. m_tmMaxWdNameWidth = (pDC->GetTextExtent( str, lstrlen(str) )).cx;
  651. str.LoadString( IDS_HEADER_COMMENT );
  652. m_tmMaxCommentWidth = (pDC->GetTextExtent( str, lstrlen(str) )).cx;
  653. }
  654. /*
  655. * Establish the inter-field spacer width and save the font height
  656. * to use in GetRowWidthHeight() calculations.
  657. */
  658. m_tmSpacerWidth = SPACER_COLUMNS * tm.tmAveCharWidth;
  659. m_tmFontHeight = tm.tmHeight;
  660. /*
  661. * Determine new field maximums based on GetTextExtent calls with actual
  662. * WSLObject strings.
  663. */
  664. if ( pWSLObject ) {
  665. /*
  666. * A WSLObject was specified. Determine if that one causes new
  667. * field maximums.
  668. */
  669. bNewMaximums = WSLObjectFieldMaximums( pWSLObject, pDC );
  670. } else {
  671. /*
  672. * No WSLObject was specified. Traverse the entire WinStation Object
  673. * List
  674. */
  675. int i, count = GetRowCount();
  676. for ( i = 0; i < count; i++ ) {
  677. if ( (pWSLObject = GetDocument()->GetWSLObject( i )) )
  678. bNewMaximums = WSLObjectFieldMaximums( pWSLObject, pDC );
  679. }
  680. }
  681. /*
  682. * Set the total line width variable.
  683. */
  684. m_tmTotalWidth = BITMAP_END + m_tmSpacerWidth +
  685. m_tmMaxWSNameWidth + m_tmSpacerWidth +
  686. m_tmMaxPdNameWidth + m_tmSpacerWidth +
  687. m_tmMaxWdNameWidth + m_tmSpacerWidth +
  688. m_tmMaxCommentWidth + m_tmSpacerWidth;
  689. /*
  690. * Select the original font back into the DC.
  691. */
  692. pDC->SelectObject( pOldFont );
  693. return ( bNewMaximums );
  694. } // end CAppServerView::CalculateFieldMaximums
  695. /*******************************************************************************
  696. *
  697. * WSLObjectFieldMaximums - CAppServerView member function: private operation
  698. *
  699. * Calculate display field sizes for the viewable items in a WSLObject,
  700. * resetting the maximum view field sizes if necessary.
  701. *
  702. * ENTRY:
  703. * pWSLObject (input)
  704. * Points to WSLObject to use for new maximum calculation.
  705. * pEntryDC (input)
  706. * Points to the CDC object to use for the GetTextExtent() calls.
  707. *
  708. * EXIT:
  709. * (BOOL) TRUE if new maximum(s) were set; FALSE otherwise.
  710. *
  711. ******************************************************************************/
  712. BOOL
  713. CAppServerView::WSLObjectFieldMaximums( PWSLOBJECT pWSLObject,
  714. CDC * pDC )
  715. {
  716. CSize strSize;
  717. BOOL bNewMaximums = FALSE;
  718. /*
  719. * WinStation name.
  720. */
  721. strSize = pDC->GetTextExtent( pWSLObject->m_WinStationName,
  722. lstrlen(pWSLObject->m_WinStationName) );
  723. if ( strSize.cx > m_tmMaxWSNameWidth ) {
  724. m_tmMaxWSNameWidth = strSize.cx;
  725. bNewMaximums = TRUE;
  726. }
  727. /*
  728. * Transport (1st Pd) Name.
  729. */
  730. strSize = pDC->GetTextExtent( pWSLObject->m_PdName,
  731. lstrlen(pWSLObject->m_PdName) );
  732. if ( strSize.cx > m_tmMaxPdNameWidth ) {
  733. m_tmMaxPdNameWidth = strSize.cx;
  734. bNewMaximums = TRUE;
  735. }
  736. /*
  737. * Wd Name.
  738. */
  739. strSize = pDC->GetTextExtent( pWSLObject->m_WdName,
  740. lstrlen(pWSLObject->m_WdName) );
  741. if ( strSize.cx > m_tmMaxWdNameWidth ) {
  742. m_tmMaxWdNameWidth = strSize.cx;
  743. bNewMaximums = TRUE;
  744. }
  745. /*
  746. * Comment (including prefixed device name for SdAsync and single-instance
  747. * PdOemTransport display).
  748. */
  749. strSize = pDC->GetTextExtent( pWSLObject->m_Comment,
  750. lstrlen(pWSLObject->m_Comment) );
  751. if ( (pWSLObject->m_SdClass == SdAsync) ||
  752. ((pWSLObject->m_SdClass == SdOemTransport) &&
  753. (pWSLObject->m_Flags & WSL_SINGLE_INST)) ) {
  754. CSize strSize2;
  755. strSize2 = pDC->GetTextExtent( pWSLObject->m_DeviceName,
  756. lstrlen(pWSLObject->m_DeviceName) );
  757. strSize.cx += strSize2.cx;
  758. strSize2 = pDC->GetTextExtent( TEXT(": "), 2 );
  759. strSize.cx += strSize2.cx;
  760. }
  761. if ( strSize.cx > m_tmMaxCommentWidth ) {
  762. m_tmMaxCommentWidth = strSize.cx;
  763. bNewMaximums = TRUE;
  764. }
  765. return ( bNewMaximums );
  766. } // end CAppServerView::WSLObjectFieldMaximums
  767. ////////////////////////////////////////////////////////////////////////////////
  768. // CAppServerView message map
  769. BEGIN_MESSAGE_MAP(CAppServerView, CRowView)
  770. //{{AFX_MSG_MAP(CAppServerView)
  771. ON_WM_CREATE()
  772. ON_COMMAND(ID_WINSTATION_ADD, OnWinStationAdd)
  773. ON_UPDATE_COMMAND_UI(ID_WINSTATION_ADD, OnUpdateWinStationAdd)
  774. ON_COMMAND(ID_WINSTATION_COPY, OnWinStationCopy)
  775. ON_UPDATE_COMMAND_UI(ID_WINSTATION_COPY, OnUpdateWinStationCopy)
  776. ON_COMMAND(ID_WINSTATION_DELETE, OnWinStationDelete)
  777. ON_UPDATE_COMMAND_UI(ID_WINSTATION_DELETE, OnUpdateWinStationDelete)
  778. ON_COMMAND(ID_WINSTATION_RENAME, OnWinStationRename)
  779. ON_UPDATE_COMMAND_UI(ID_WINSTATION_RENAME, OnUpdateWinStationRename)
  780. ON_COMMAND(ID_WINSTATION_EDIT, OnWinStationEdit)
  781. ON_UPDATE_COMMAND_UI(ID_WINSTATION_EDIT, OnUpdateWinStationEdit)
  782. ON_COMMAND(ID_WINSTATION_ENABLE, OnWinStationEnable)
  783. ON_UPDATE_COMMAND_UI(ID_WINSTATION_ENABLE, OnUpdateWinStationEnable)
  784. ON_COMMAND(ID_WINSTATION_DISABLE, OnWinStationDisable)
  785. ON_UPDATE_COMMAND_UI(ID_WINSTATION_DISABLE, OnUpdateWinStationDisable)
  786. ON_WM_LBUTTONDBLCLK()
  787. ON_COMMAND(ID_WINSTATION_NEXT, OnWinStationNext)
  788. ON_UPDATE_COMMAND_UI(ID_WINSTATION_NEXT, OnUpdateWinStationNext)
  789. ON_COMMAND(ID_WINSTATION_PREV, OnWinStationPrev)
  790. ON_UPDATE_COMMAND_UI(ID_WINSTATION_PREV, OnUpdateWinStationPrev)
  791. ON_COMMAND(ID_SECURITY_PERMISSIONS, OnSecurityPermissions)
  792. ON_WM_RBUTTONDOWN()
  793. ON_WM_RBUTTONUP()
  794. //}}AFX_MSG_MAP
  795. END_MESSAGE_MAP()
  796. ////////////////////////////////////////////////////////////////////////////////
  797. // CAppServerView commands
  798. /*******************************************************************************
  799. *
  800. * OnCreate - CAppServerView member function: command
  801. *
  802. * Perform initialization when view is created.
  803. *
  804. * ENTRY:
  805. * EXIT:
  806. * (refer to CWnd::OnCreate documentation)
  807. *
  808. ******************************************************************************/
  809. int
  810. CAppServerView::OnCreate( LPCREATESTRUCT lpCreateStruct )
  811. {
  812. /*
  813. * Construct a new instance of a CRowViewHeaderBar object and set the
  814. * m_bAutoDelete member variable (defined in CControlBar class) to TRUE
  815. * to cause the object to be deleted automatically when the windows control
  816. * bar is destroyed. The CRowView's OnCreate will see that the m_pHeaderBar
  817. * member variable is not NULL and will actually create the header bar via
  818. * its Create() member function.
  819. */
  820. m_pHeaderBar = new CRowViewHeaderBar;
  821. m_pHeaderBar->m_bAutoDelete = TRUE;
  822. /*
  823. * Call the CRowView parent class OnCreate.
  824. */
  825. if ( CRowView::OnCreate( lpCreateStruct ) == -1 )
  826. return(-1);
  827. /*
  828. * Reset the view (with calculating new field maximums).
  829. */
  830. ResetView(TRUE);
  831. return( 0 );
  832. } // end CAppServerView::OnCreate
  833. /*******************************************************************************
  834. *
  835. * OnWinStationAdd - CAppServerView member function: command
  836. *
  837. * Process the "add winstation" command.
  838. *
  839. * ENTRY:
  840. * EXIT:
  841. *
  842. ******************************************************************************/
  843. void
  844. CAppServerView::OnWinStationAdd()
  845. {
  846. int nRow;
  847. /*
  848. * Only process add if it is allowed.
  849. */
  850. if ( GetDocument()->IsAddAllowed(m_nActiveRow) ) {
  851. if ( (nRow = GetDocument()->AddWinStation(m_nActiveRow)) != -1 )
  852. m_nPrevSelectedRow = m_nActiveRow = nRow;
  853. }
  854. } // end CAppServerView::OnWinStationAdd
  855. /*******************************************************************************
  856. *
  857. * OnUpdateWinStationAdd - CAppServerView member function: command
  858. *
  859. * Enable or disable the "add winstation" command depending on whether
  860. * or not it is allowed on the active row's WinStation.
  861. *
  862. * ENTRY:
  863. * pCndUI (input)
  864. * Points to the CCmdUI object of the "add winstation"
  865. * command item.
  866. *
  867. * EXIT:
  868. *
  869. ******************************************************************************/
  870. void
  871. CAppServerView::OnUpdateWinStationAdd( CCmdUI* pCmdUI )
  872. {
  873. pCmdUI->Enable( GetDocument()->IsAddAllowed(m_nActiveRow) ?
  874. TRUE : FALSE );
  875. } // end CAppServerView::OnUpdateWinStationAdd
  876. /*******************************************************************************
  877. *
  878. * OnWinStationCopy - CAppServerView member function: command
  879. *
  880. * Process the "copy winstation" command.
  881. *
  882. * ENTRY:
  883. * EXIT:
  884. *
  885. ******************************************************************************/
  886. void
  887. CAppServerView::OnWinStationCopy()
  888. {
  889. int nRow;
  890. /*
  891. * Only process copy if it is allowed.
  892. */
  893. if ( GetDocument()->IsCopyAllowed(m_nActiveRow) ) {
  894. if ( (nRow = GetDocument()->CopyWinStation(m_nActiveRow)) != -1 )
  895. m_nPrevSelectedRow = m_nActiveRow = nRow;
  896. }
  897. } // end CAppServerView::OnWinStationCopy
  898. /*******************************************************************************
  899. *
  900. * OnUpdateWinStationCopy - CAppServerView member function: command
  901. *
  902. * Enable or disable the "copy winstation" command depending on whether
  903. * or not it is allowed on the active row's WinStation.
  904. *
  905. * ENTRY:
  906. * pCndUI (input)
  907. * Points to the CCmdUI object of the "copy winstation"
  908. * command item.
  909. *
  910. * EXIT:
  911. *
  912. ******************************************************************************/
  913. void
  914. CAppServerView::OnUpdateWinStationCopy( CCmdUI* pCmdUI )
  915. {
  916. pCmdUI->Enable( GetDocument()->IsCopyAllowed(m_nActiveRow) ?
  917. TRUE : FALSE );
  918. } // end CAppServerView::OnUpdateWinStationCopy
  919. /*******************************************************************************
  920. *
  921. * OnWinStationDelete - CAppServerView member function: command
  922. *
  923. * Process the "delete winstation" command.
  924. *
  925. * ENTRY:
  926. * EXIT:
  927. *
  928. ******************************************************************************/
  929. void
  930. CAppServerView::OnWinStationDelete()
  931. {
  932. /*
  933. * Only process delete if it is allowed.
  934. */
  935. if ( GetDocument()->IsDeleteAllowed(m_nActiveRow) ) {
  936. if ( GetDocument()->DeleteWinStation(m_nActiveRow) ) {
  937. if ( (m_nActiveRow >= GetRowCount()) && GetRowCount() )
  938. m_nPrevSelectedRow = m_nActiveRow = (GetRowCount() - 1);
  939. }
  940. }
  941. } // end CAppServerView::OnWinStationDelete
  942. /*******************************************************************************
  943. *
  944. * OnUpdateWinStationDelete - CAppServerView member function: command
  945. *
  946. * Enable or disable the "delete winstation" command depending on whether
  947. * or not it is allowed on the active row's WinStation.
  948. *
  949. * ENTRY:
  950. * pCndUI (input)
  951. * Points to the CCmdUI object of the "delete winstation"
  952. * command item.
  953. *
  954. * EXIT:
  955. *
  956. ******************************************************************************/
  957. void
  958. CAppServerView::OnUpdateWinStationDelete( CCmdUI* pCmdUI )
  959. {
  960. pCmdUI->Enable( GetDocument()->IsDeleteAllowed(m_nActiveRow) ?
  961. TRUE : FALSE );
  962. } // end CAppServerView::OnUpdateWinStationDelete
  963. /*******************************************************************************
  964. *
  965. * OnWinStationRename - CAppServerView member function: command
  966. *
  967. * Process the "rename winstation" command.
  968. *
  969. * ENTRY:
  970. * EXIT:
  971. *
  972. ******************************************************************************/
  973. void
  974. CAppServerView::OnWinStationRename()
  975. {
  976. int nRow;
  977. /*
  978. * Only process rename if it is allowed.
  979. */
  980. if ( GetDocument()->IsRenameAllowed(m_nActiveRow) ) {
  981. if ( (nRow = GetDocument()->RenameWinStation(m_nActiveRow)) != -1 )
  982. m_nPrevSelectedRow = m_nActiveRow = nRow;
  983. }
  984. } // end CAppServerView::OnWinStationRename
  985. /*******************************************************************************
  986. *
  987. * OnUpdateWinStationRename - CAppServerView member function: command
  988. *
  989. * Enable or disable the "rename winstation" command depending on whether
  990. * or not it is allowed on the active row's WinStation.
  991. *
  992. * ENTRY:
  993. * pCndUI (input)
  994. * Points to the CCmdUI object of the "rename winstation"
  995. * command item.
  996. *
  997. * EXIT:
  998. *
  999. ******************************************************************************/
  1000. void
  1001. CAppServerView::OnUpdateWinStationRename(CCmdUI* pCmdUI)
  1002. {
  1003. pCmdUI->Enable( GetDocument()->IsRenameAllowed(m_nActiveRow) ?
  1004. TRUE : FALSE );
  1005. } // end CAppServerView::OnUpdateWinStationRename
  1006. /*******************************************************************************
  1007. *
  1008. * OnWinStationEdit - CAppServerView member function: command
  1009. *
  1010. * Process the "edit winstation" command.
  1011. *
  1012. * ENTRY:
  1013. * EXIT:
  1014. *
  1015. ******************************************************************************/
  1016. void
  1017. CAppServerView::OnWinStationEdit()
  1018. {
  1019. int nRow;
  1020. /*
  1021. * Only process edit if it is allowed.
  1022. */
  1023. if ( GetDocument()->IsEditAllowed(m_nActiveRow) ) {
  1024. if ( (nRow = GetDocument()->EditWinStation(m_nActiveRow)) != -1 )
  1025. m_nPrevSelectedRow = m_nActiveRow = nRow;
  1026. }
  1027. } // end CAppServerView::OnWinStationEdit
  1028. /*******************************************************************************
  1029. *
  1030. * OnUpdateWinStationEdit - CAppServerView member function: command
  1031. *
  1032. * Enable or disable the "edit winstation" command depending on whether
  1033. * or not it is allowed on the active row's WinStation.
  1034. *
  1035. * ENTRY:
  1036. * pCndUI (input)
  1037. * Points to the CCmdUI object of the "edit winstation" command item.
  1038. *
  1039. * EXIT:
  1040. *
  1041. ******************************************************************************/
  1042. void
  1043. CAppServerView::OnUpdateWinStationEdit(CCmdUI* pCmdUI)
  1044. {
  1045. pCmdUI->Enable( GetDocument()->IsEditAllowed(m_nActiveRow) ?
  1046. TRUE : FALSE );
  1047. } // end CAppServerView::OnUpdateWinStationEdit
  1048. /*******************************************************************************
  1049. *
  1050. * OnWinStationEnable - CAppServerView member function: command
  1051. *
  1052. * Process the "enable winstation" command.
  1053. *
  1054. * ENTRY:
  1055. * EXIT:
  1056. *
  1057. ******************************************************************************/
  1058. void
  1059. CAppServerView::OnWinStationEnable()
  1060. {
  1061. /*
  1062. * Only process enable if it is allowed.
  1063. */
  1064. if ( GetDocument()->IsEnableAllowed(m_nActiveRow, TRUE ) )
  1065. GetDocument()->EnableWinStation( m_nActiveRow, TRUE );
  1066. } // end CAppServerView::OnWinStationEnable
  1067. /*******************************************************************************
  1068. *
  1069. * OnUpdateWinStationEnable - CAppServerView member function: command
  1070. *
  1071. * Enable or disable the "enable winstation" command depending on
  1072. * whether or not it is allowed on the active row's WinStation.
  1073. *
  1074. * ENTRY:
  1075. * pCndUI (input)
  1076. * Points to the CCmdUI object of the "enable winstation"
  1077. * command item.
  1078. *
  1079. * EXIT:
  1080. *
  1081. ******************************************************************************/
  1082. void
  1083. CAppServerView::OnUpdateWinStationEnable(CCmdUI* pCmdUI)
  1084. {
  1085. pCmdUI->Enable( GetDocument()->IsEnableAllowed( m_nActiveRow, TRUE ) ?
  1086. TRUE : FALSE );
  1087. } // end CAppServerView::OnUpdateWinStationEnable
  1088. /*******************************************************************************
  1089. *
  1090. * OnWinStationDisable - CAppServerView member function: command
  1091. *
  1092. * Process the "disable winstation" command.
  1093. *
  1094. * ENTRY:
  1095. * EXIT:
  1096. *
  1097. ******************************************************************************/
  1098. void
  1099. CAppServerView::OnWinStationDisable()
  1100. {
  1101. /*
  1102. * Only process disable if it is allowed.
  1103. */
  1104. if ( GetDocument()->IsEnableAllowed( m_nActiveRow, FALSE ) )
  1105. GetDocument()->EnableWinStation( m_nActiveRow, FALSE );
  1106. } // end CAppServerView::OnWinStationDisable
  1107. /*******************************************************************************
  1108. *
  1109. * OnUpdateWinStationDisable - CAppServerView member function: command
  1110. *
  1111. * Enable or disable the "disable winstation" command depending on
  1112. * whether or not it is allowed on the active row's WinStation.
  1113. *
  1114. * ENTRY:
  1115. * pCndUI (input)
  1116. * Points to the CCmdUI object of the "disable winstation"
  1117. * command item.
  1118. *
  1119. * EXIT:
  1120. *
  1121. ******************************************************************************/
  1122. void
  1123. CAppServerView::OnUpdateWinStationDisable(CCmdUI* pCmdUI)
  1124. {
  1125. pCmdUI->Enable( GetDocument()->IsEnableAllowed( m_nActiveRow, FALSE ) ?
  1126. TRUE : FALSE );
  1127. } // end CAppServerView::OnUpdateWinStationDisable
  1128. /*******************************************************************************
  1129. *
  1130. * OnLButtonDblClk - CAppServerView member function: command
  1131. *
  1132. * Process a left mouse button double-click as an "edit winstation"
  1133. * command.
  1134. *
  1135. * ENTRY:
  1136. * EXIT:
  1137. * (Refer to the CWnd::OnLButtonCblClk documentation)
  1138. *
  1139. ******************************************************************************/
  1140. void CAppServerView::OnLButtonDblClk(UINT nFlags, CPoint point)
  1141. {
  1142. /*
  1143. * Let the parent class process the message first.
  1144. */
  1145. CRowView::OnLButtonDblClk(nFlags, point);
  1146. /*
  1147. * Treat this as a 'Edit/View WinStation' request.
  1148. */
  1149. OnWinStationEdit();
  1150. } // end CAppServerView::OnLButtonDblClk
  1151. /*******************************************************************************
  1152. *
  1153. * OnWinStationNext - CAppServerView member function: command
  1154. *
  1155. * Processes the "next winstation" command by calling the
  1156. * ChangeSelectionNextRow function with argument TRUE.
  1157. *
  1158. * ENTRY:
  1159. * EXIT:
  1160. *
  1161. ******************************************************************************/
  1162. void
  1163. CAppServerView::OnWinStationNext()
  1164. {
  1165. ChangeSelectionNextRow(TRUE);
  1166. } // end CAppServerView::OnWinStationNext
  1167. /*******************************************************************************
  1168. *
  1169. * OnUpdateWinStationNext - CAppServerView member function: command
  1170. *
  1171. * Enables or disables the "next winstation" command item based on
  1172. * whether or not we're at the end of the view's list.
  1173. *
  1174. * ENTRY:
  1175. * pCndUI (input)
  1176. * Points to the CCmdUI object of the "next winstation"
  1177. * command item.
  1178. *
  1179. * EXIT:
  1180. *
  1181. ******************************************************************************/
  1182. void
  1183. CAppServerView::OnUpdateWinStationNext( CCmdUI* pCmdUI )
  1184. {
  1185. pCmdUI->Enable( (m_nActiveRow < (GetRowCount() - 1)) ? TRUE : FALSE );
  1186. } // end CAppServerView::OnUpdateWinStationNext
  1187. /*******************************************************************************
  1188. *
  1189. * OnWinStationPrev - CAppServerView member function: command
  1190. *
  1191. * Processes the "previous winstation" command by calling the
  1192. * ChangeSelectionNextRow function with argument FALSE.
  1193. *
  1194. * ENTRY:
  1195. * EXIT:
  1196. *
  1197. ******************************************************************************/
  1198. void
  1199. CAppServerView::OnWinStationPrev()
  1200. {
  1201. ChangeSelectionNextRow(FALSE);
  1202. } // end CAppServerView::OnWinStationPrev
  1203. /*******************************************************************************
  1204. *
  1205. * OnUpdateWinStationPrev - CAppServerView member function: command
  1206. *
  1207. * Enables or disables the "previous winstation" command item based on
  1208. * whether or not we're at the beginning of the view's list.
  1209. *
  1210. * ENTRY:
  1211. * pCndUI (input)
  1212. * Points to the CCmdUI object of the "next winstation"
  1213. * command item.
  1214. *
  1215. * EXIT:
  1216. *
  1217. ******************************************************************************/
  1218. void
  1219. CAppServerView::OnUpdateWinStationPrev( CCmdUI* pCmdUI )
  1220. {
  1221. pCmdUI->Enable( (m_nActiveRow > 0) ? TRUE : FALSE );
  1222. } // end CAppServerView::OnUpdateWinStationPrev
  1223. /*******************************************************************************
  1224. *
  1225. * OnSecurityPermissions - CAppServerView member function: command
  1226. *
  1227. * Process the "Permissions..." command.
  1228. *
  1229. * ENTRY:
  1230. * EXIT:
  1231. *
  1232. ******************************************************************************/
  1233. void
  1234. CAppServerView::OnSecurityPermissions()
  1235. {
  1236. GetDocument()->SecurityPermissions(m_nActiveRow);
  1237. } // end CAppServerView::OnSecurityPermissions
  1238. void CAppServerView::OnRButtonDown(UINT nFlags, CPoint point)
  1239. {
  1240. CRect rect(point, CSize(1,1));
  1241. int nFirstRow, nLastRow;
  1242. RectLPtoRowRange(rect, nFirstRow, nLastRow, TRUE);
  1243. if (nFirstRow <= (GetRowCount() - 1))
  1244. ChangeSelectionToRow(nFirstRow);
  1245. //CRowView::OnRButtonDown(nFlags, point);
  1246. }
  1247. void CAppServerView::OnRButtonUp(UINT nFlags, CPoint point)
  1248. {
  1249. CRect rect(point, CSize(1,1));
  1250. int nFirstRow, nLastRow;
  1251. RectLPtoRowRange(rect, nFirstRow, nLastRow, TRUE);
  1252. if(nFirstRow == GetActiveRow()) {
  1253. ::GetCursorPos(&point);
  1254. CMenu menu;
  1255. if(menu.LoadMenu(IDR_POPUP)) {
  1256. menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,
  1257. point.x, point.y, AfxGetMainWnd());
  1258. menu.DestroyMenu();
  1259. }
  1260. }
  1261. //CRowView::OnRButtonUp(nFlags, point);
  1262. }
  1263. ////////////////////////////////////////////////////////////////////////////////