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.

2230 lines
68 KiB

  1. /*******************************************************************************
  2. *
  3. * dialogs.cpp
  4. *
  5. * implementation of all dialog classes
  6. *
  7. * copyright notice: Copyright 1997, Citrix Systems Inc.
  8. * Copyright (c) 1998 - 1999 Microsoft Corporation
  9. *
  10. * $Author: donm $ Don Messerli
  11. *
  12. * $Log: N:\nt\private\utils\citrix\winutils\tsadmin\VCS\dialogs.cpp $
  13. *
  14. * Rev 1.7 25 Apr 1998 13:43:16 donm
  15. * MS 2167: try to use proper Wd from registry
  16. *
  17. * Rev 1.6 19 Jan 1998 16:46:08 donm
  18. * new ui behavior for domains and servers
  19. *
  20. * Rev 1.5 03 Nov 1997 19:16:10 donm
  21. * removed redundant message to add server to views
  22. *
  23. * Rev 1.4 03 Nov 1997 15:24:16 donm
  24. * fixed AV in CServerFilterDialog
  25. *
  26. * Rev 1.3 22 Oct 1997 21:07:10 donm
  27. * update
  28. *
  29. * Rev 1.2 18 Oct 1997 18:50:10 donm
  30. * update
  31. *
  32. * Rev 1.1 13 Oct 1997 18:40:16 donm
  33. * update
  34. *
  35. * Rev 1.0 30 Jul 1997 17:11:28 butchd
  36. * Initial revision.
  37. *
  38. *******************************************************************************/
  39. #include "stdafx.h"
  40. #include "afxpriv.h"
  41. #include "winadmin.h"
  42. #include "admindoc.h"
  43. #include "dialogs.h"
  44. #include "..\..\inc\ansiuni.h"
  45. #ifdef _DEBUG
  46. #define new DEBUG_NEW
  47. #undef THIS_FILE
  48. static char THIS_FILE[] = __FILE__;
  49. #endif
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CSendMessageDlg dialog
  52. CSendMessageDlg::CSendMessageDlg(CWnd* pParent /*=NULL*/)
  53. : CDialog(CSendMessageDlg::IDD, pParent)
  54. {
  55. //{{AFX_DATA_INIT(CSendMessageDlg)
  56. // NOTE: the ClassWizard will add member initialization here
  57. //}}AFX_DATA_INIT
  58. }
  59. void CSendMessageDlg::DoDataExchange(CDataExchange* pDX)
  60. {
  61. CDialog::DoDataExchange(pDX);
  62. //{{AFX_DATA_MAP(CSendMessageDlg)
  63. // NOTE: the ClassWizard will add DDX and DDV calls here
  64. //}}AFX_DATA_MAP
  65. }
  66. BEGIN_MESSAGE_MAP(CSendMessageDlg, CDialog)
  67. //{{AFX_MSG_MAP(CSendMessageDlg)
  68. ON_WM_HELPINFO()
  69. ON_COMMAND(ID_HELP,OnCommandHelp)
  70. //}}AFX_MSG_MAP
  71. END_MESSAGE_MAP()
  72. /////////////////////////////////////////////////////////////////////////////
  73. // CSendMessageDlg message handlers
  74. void CSendMessageDlg::OnCommandHelp(void)
  75. {
  76. AfxGetApp()->WinHelp(CSendMessageDlg::IDD + HID_BASE_RESOURCE);
  77. return;
  78. }
  79. BOOL CSendMessageDlg::OnInitDialog()
  80. {
  81. CDialog::OnInitDialog();
  82. // TODO: Add extra initialization here
  83. // Form the default the message title.
  84. CString DefTitleString;
  85. TCHAR szTime[MAX_DATE_TIME_LENGTH];
  86. CurrentDateTimeString(szTime);
  87. DefTitleString.LoadString(IDS_DEFAULT_MESSAGE_TITLE);
  88. wsprintf(m_szTitle, DefTitleString, ((CWinAdminApp*)AfxGetApp())->GetCurrentUserName(), szTime);
  89. // Initialize the title edit control and set maximum length for title
  90. // and message.
  91. SetDlgItemText(IDC_MESSAGE_TITLE, m_szTitle);
  92. ((CEdit *)GetDlgItem(IDC_MESSAGE_TITLE))->LimitText(MSG_TITLE_LENGTH);
  93. ((CEdit *)GetDlgItem(IDC_MESSAGE_MESSAGE))->LimitText(MSG_MESSAGE_LENGTH);
  94. return TRUE; // return TRUE unless you set the focus to a control
  95. // EXCEPTION: OCX Property Pages should return FALSE
  96. }
  97. void CSendMessageDlg::OnOK()
  98. {
  99. // TODO: Add extra validation here
  100. // Get the message title and message text.
  101. GetDlgItemText(IDC_MESSAGE_TITLE, m_szTitle, MSG_TITLE_LENGTH+1);
  102. GetDlgItemText(IDC_MESSAGE_MESSAGE, m_szMessage, MSG_MESSAGE_LENGTH+1);
  103. CDialog::OnOK();
  104. }
  105. BOOL CSendMessageDlg::OnHelpInfo(HELPINFO* pHelpInfo)
  106. {
  107. // TODO: Add your message handler code here and/or call default
  108. //((CWinAdminApp*)AfxGetApp())->WinHelp(HID_BASE_CONTROL + pHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
  109. if(pHelpInfo->iContextType == HELPINFO_WINDOW)
  110. {
  111. if(pHelpInfo->iCtrlId != IDC_STATIC)
  112. {
  113. ::WinHelp((HWND)pHelpInfo->hItemHandle,ID_HELP_FILE,HELP_WM_HELP,(ULONG_PTR)(LPVOID)aMenuHelpIDs);
  114. }
  115. }
  116. return (TRUE);
  117. }
  118. /////////////////////////////////////////////////////////////////////////////
  119. // CShadowStartDlg dialog
  120. CShadowStartDlg::CShadowStartDlg(CWnd* pParent /*=NULL*/)
  121. : CDialog(CShadowStartDlg::IDD, pParent)
  122. {
  123. //{{AFX_DATA_INIT(CShadowStartDlg)
  124. // NOTE: the ClassWizard will add member initialization here
  125. //}}AFX_DATA_INIT
  126. }
  127. ////////////////////////////////////////////////////////////////////////////////
  128. // CShadowStartDlg static tables
  129. struct {
  130. LPCTSTR String;
  131. DWORD VKCode;
  132. } HotkeyLookupTable[] =
  133. {
  134. TEXT("0"), '0',
  135. TEXT("1"), '1',
  136. TEXT("2"), '2',
  137. TEXT("3"), '3',
  138. TEXT("4"), '4',
  139. TEXT("5"), '5',
  140. TEXT("6"), '6',
  141. TEXT("7"), '7',
  142. TEXT("8"), '8',
  143. TEXT("9"), '9',
  144. TEXT("A"), 'A',
  145. TEXT("B"), 'B',
  146. TEXT("C"), 'C',
  147. TEXT("D"), 'D',
  148. TEXT("E"), 'E',
  149. TEXT("F"), 'F',
  150. TEXT("G"), 'G',
  151. TEXT("H"), 'H',
  152. TEXT("I"), 'I',
  153. TEXT("J"), 'J',
  154. TEXT("K"), 'K',
  155. TEXT("L"), 'L',
  156. TEXT("M"), 'M',
  157. TEXT("N"), 'N',
  158. TEXT("O"), 'O',
  159. TEXT("P"), 'P',
  160. TEXT("Q"), 'Q',
  161. TEXT("R"), 'R',
  162. TEXT("S"), 'S',
  163. TEXT("T"), 'T',
  164. TEXT("U"), 'U',
  165. TEXT("V"), 'V',
  166. TEXT("W"), 'W',
  167. TEXT("X"), 'X',
  168. TEXT("Y"), 'Y',
  169. TEXT("Z"), 'Z',
  170. TEXT("{backspace}"), VK_BACK,
  171. TEXT("{delete}"), VK_DELETE,
  172. TEXT("{down}"), VK_DOWN,
  173. TEXT("{end}"), VK_END,
  174. TEXT("{enter}"), VK_RETURN,
  175. /// TEXT("{esc}"), VK_ESCAPE, // KLB 07-16-95
  176. /// TEXT("{F1}"), VK_F1,
  177. TEXT("{F2}"), VK_F2,
  178. TEXT("{F3}"), VK_F3,
  179. TEXT("{F4}"), VK_F4,
  180. TEXT("{F5}"), VK_F5,
  181. TEXT("{F6}"), VK_F6,
  182. TEXT("{F7}"), VK_F7,
  183. TEXT("{F8}"), VK_F8,
  184. TEXT("{F9}"), VK_F9,
  185. TEXT("{F10}"), VK_F10,
  186. TEXT("{F11}"), VK_F11,
  187. TEXT("{F12}"), VK_F12,
  188. TEXT("{home}"), VK_HOME,
  189. TEXT("{insert}"), VK_INSERT,
  190. TEXT("{left}"), VK_LEFT,
  191. TEXT("{-}"), VK_SUBTRACT,
  192. TEXT("{pagedown}"), VK_NEXT,
  193. TEXT("{pageup}"), VK_PRIOR,
  194. TEXT("{+}"), VK_ADD,
  195. TEXT("{prtscrn}"), VK_SNAPSHOT,
  196. TEXT("{right}"), VK_RIGHT,
  197. TEXT("{spacebar}"), VK_SPACE,
  198. TEXT("{*}"), VK_MULTIPLY,
  199. TEXT("{tab}"), VK_TAB,
  200. TEXT("{up}"), VK_UP,
  201. NULL, NULL
  202. };
  203. void CShadowStartDlg::OnSelChange( )
  204. {/*
  205. */
  206. CComboBox *pComboBox = ((CComboBox *)GetDlgItem(IDC_SHADOWSTART_HOTKEY));
  207. // Get the current hotkey selection.
  208. DWORD dwKey = ( DWORD )pComboBox->GetItemData(pComboBox->GetCurSel());
  209. switch (dwKey )
  210. {
  211. case VK_ADD :
  212. case VK_MULTIPLY:
  213. case VK_SUBTRACT:
  214. // change the text
  215. GetDlgItem(IDC_PRESS_KEY)->ShowWindow(SW_HIDE);
  216. GetDlgItem(IDC_PRESS_NUMKEYPAD)->ShowWindow(SW_SHOW);
  217. break;
  218. default :
  219. // change the text
  220. GetDlgItem(IDC_PRESS_NUMKEYPAD)->ShowWindow(SW_HIDE);
  221. GetDlgItem(IDC_PRESS_KEY)->ShowWindow(SW_SHOW);
  222. break;
  223. }
  224. }
  225. void CShadowStartDlg::DoDataExchange(CDataExchange* pDX)
  226. {
  227. CDialog::DoDataExchange(pDX);
  228. //{{AFX_DATA_MAP(CShadowStartDlg)
  229. // NOTE: the ClassWizard will add DDX and DDV calls here
  230. //}}AFX_DATA_MAP
  231. }
  232. BEGIN_MESSAGE_MAP(CShadowStartDlg, CDialog)
  233. //{{AFX_MSG_MAP(CShadowStartDlg)
  234. ON_WM_HELPINFO()
  235. ON_CBN_SELCHANGE( IDC_SHADOWSTART_HOTKEY , OnSelChange )
  236. ON_COMMAND(ID_HELP,OnCommandHelp)
  237. //}}AFX_MSG_MAP
  238. END_MESSAGE_MAP()
  239. /////////////////////////////////////////////////////////////////////////////
  240. // CShadowStartDlg message handlers
  241. void CShadowStartDlg::OnCommandHelp(void)
  242. {
  243. AfxGetApp()->WinHelp(CShadowStartDlg::IDD + HID_BASE_RESOURCE);
  244. return;
  245. }
  246. BOOL CShadowStartDlg::OnInitDialog()
  247. {
  248. CDialog::OnInitDialog();
  249. GetDlgItem(IDC_PRESS_NUMKEYPAD)->ShowWindow(SW_HIDE);
  250. GetDlgItem(IDC_PRESS_KEY)->ShowWindow(SW_SHOW);
  251. // TODO: Add extra initialization here
  252. int index, match = -1;
  253. CComboBox *pComboBox = ((CComboBox *)GetDlgItem(IDC_SHADOWSTART_HOTKEY));
  254. // Initialize the hotkey combo box.
  255. for(int i=0; HotkeyLookupTable[i].String; i++ ) {
  256. if((index = pComboBox->AddString(HotkeyLookupTable[i].String)) < 0) {
  257. // ErrorMessage(IDP_ERROR_STARTSHADOWHOTKEYBOX);
  258. break;
  259. }
  260. if(pComboBox->SetItemData(index, HotkeyLookupTable[i].VKCode) < 0) {
  261. pComboBox->DeleteString(index);
  262. // ErrorMessage(IDP_ERROR_STARTSHADOWHOTKEYBOX);
  263. break;
  264. }
  265. // If this is our current hotkey key, save it's index.
  266. if(m_ShadowHotkeyKey == (int)HotkeyLookupTable[i].VKCode) {
  267. match = index;
  268. switch ( HotkeyLookupTable[i].VKCode)
  269. {
  270. case VK_ADD :
  271. case VK_MULTIPLY:
  272. case VK_SUBTRACT:
  273. // change the text
  274. GetDlgItem(IDC_PRESS_KEY)->ShowWindow(SW_HIDE);
  275. GetDlgItem(IDC_PRESS_NUMKEYPAD)->ShowWindow(SW_SHOW);
  276. break;
  277. }
  278. }
  279. }
  280. // Select the current hotkey string in the combo box.
  281. if(match)
  282. pComboBox->SetCurSel(match);
  283. // Initialize shift state checkboxes.
  284. CheckDlgButton( IDC_SHADOWSTART_SHIFT,
  285. (m_ShadowHotkeyShift & KBDSHIFT) ?
  286. TRUE : FALSE );
  287. CheckDlgButton( IDC_SHADOWSTART_CTRL,
  288. (m_ShadowHotkeyShift & KBDCTRL) ?
  289. TRUE : FALSE );
  290. CheckDlgButton( IDC_SHADOWSTART_ALT,
  291. (m_ShadowHotkeyShift & KBDALT) ?
  292. TRUE : FALSE );
  293. return TRUE; // return TRUE unless you set the focus to a control
  294. // EXCEPTION: OCX Property Pages should return FALSE
  295. }
  296. void CShadowStartDlg::OnOK()
  297. {
  298. // TODO: Add extra validation here
  299. CComboBox *pComboBox = ((CComboBox *)GetDlgItem(IDC_SHADOWSTART_HOTKEY));
  300. // Get the current hotkey selection.
  301. m_ShadowHotkeyKey = (int)pComboBox->GetItemData(pComboBox->GetCurSel());
  302. // Get shift state checkbox states and form hotkey shift state.
  303. m_ShadowHotkeyShift = 0;
  304. m_ShadowHotkeyShift |=
  305. ((CButton *)GetDlgItem(IDC_SHADOWSTART_SHIFT))->GetCheck() ?
  306. KBDSHIFT : 0;
  307. m_ShadowHotkeyShift |=
  308. ((CButton *)GetDlgItem(IDC_SHADOWSTART_CTRL))->GetCheck() ?
  309. KBDCTRL : 0;
  310. m_ShadowHotkeyShift |=
  311. ((CButton *)GetDlgItem(IDC_SHADOWSTART_ALT))->GetCheck() ?
  312. KBDALT : 0;
  313. CDialog::OnOK();
  314. }
  315. BOOL CShadowStartDlg::OnHelpInfo(HELPINFO* pHelpInfo)
  316. {
  317. // TODO: Add your message handler code here and/or call default
  318. //((CWinAdminApp*)AfxGetApp())->WinHelp(HID_BASE_CONTROL + pHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
  319. if(pHelpInfo->iContextType == HELPINFO_WINDOW)
  320. {
  321. if(pHelpInfo->iCtrlId != IDC_STATIC)
  322. {
  323. ::WinHelp((HWND)pHelpInfo->hItemHandle,ID_HELP_FILE,HELP_WM_HELP,(ULONG_PTR)(LPVOID)aMenuHelpIDs);
  324. }
  325. }
  326. return (TRUE);
  327. }
  328. /////////////////////////////////////////////////////////////////////////////
  329. // CPasswordDlg dialog
  330. CPasswordDlg::CPasswordDlg(CWnd* pParent /*=NULL*/)
  331. : CDialog(CPasswordDlg::IDD, pParent)
  332. {
  333. //{{AFX_DATA_INIT(CPasswordDlg)
  334. // NOTE: the ClassWizard will add member initialization here
  335. //}}AFX_DATA_INIT
  336. }
  337. void CPasswordDlg::DoDataExchange(CDataExchange* pDX)
  338. {
  339. CDialog::DoDataExchange(pDX);
  340. //{{AFX_DATA_MAP(CPasswordDlg)
  341. // NOTE: the ClassWizard will add DDX and DDV calls here
  342. //}}AFX_DATA_MAP
  343. }
  344. BEGIN_MESSAGE_MAP(CPasswordDlg, CDialog)
  345. //{{AFX_MSG_MAP(CPasswordDlg)
  346. //}}AFX_MSG_MAP
  347. END_MESSAGE_MAP()
  348. /////////////////////////////////////////////////////////////////////////////
  349. // CPasswordDlg message handlers
  350. BOOL CPasswordDlg::OnInitDialog()
  351. {
  352. CDialog::OnInitDialog();
  353. // TODO: Add extra initialization here
  354. CString Prompt;
  355. Prompt.LoadString((m_DlgMode == PwdDlg_UserMode) ?
  356. IDS_PWDDLG_USER : IDS_PWDDLG_WINSTATION );
  357. SetDlgItemText(IDL_CPDLG_PROMPT, Prompt);
  358. ((CEdit *)GetDlgItem(IDC_CPDLG_PASSWORD))->LimitText(PASSWORD_LENGTH);
  359. return TRUE; // return TRUE unless you set the focus to a control
  360. // EXCEPTION: OCX Property Pages should return FALSE
  361. }
  362. void CPasswordDlg::OnOK()
  363. {
  364. // TODO: Add extra validation here
  365. // Read password.
  366. GetDlgItemText(IDC_CPDLG_PASSWORD, m_szPassword, PASSWORD_LENGTH+1);
  367. CDialog::OnOK();
  368. }
  369. /////////////////////////////////////////////////////////////////////////////
  370. // CPreferencesDlg dialog
  371. CPreferencesDlg::CPreferencesDlg(CWnd* pParent /*=NULL*/)
  372. : CDialog(CPreferencesDlg::IDD, pParent)
  373. {
  374. //{{AFX_DATA_INIT(CPreferencesDlg)
  375. // NOTE: the ClassWizard will add member initialization here
  376. //}}AFX_DATA_INIT
  377. }
  378. void CPreferencesDlg::DoDataExchange(CDataExchange* pDX)
  379. {
  380. CDialog::DoDataExchange(pDX);
  381. //{{AFX_DATA_MAP(CPreferencesDlg)
  382. // NOTE: the ClassWizard will add DDX and DDV calls here
  383. //}}AFX_DATA_MAP
  384. }
  385. BEGIN_MESSAGE_MAP(CPreferencesDlg, CDialog)
  386. //{{AFX_MSG_MAP(CPreferencesDlg)
  387. ON_BN_CLICKED(IDC_PREFERENCES_PROC_MANUAL, OnPreferencesProcManual)
  388. ON_BN_CLICKED(IDC_PREFERENCES_PROC_EVERY, OnPreferencesProcEvery)
  389. ON_BN_CLICKED(IDC_PREFERENCES_STATUS_EVERY, OnPreferencesStatusEvery)
  390. ON_BN_CLICKED(IDC_PREFERENCES_STATUS_MANUAL, OnPreferencesStatusManual)
  391. ON_WM_CLOSE()
  392. ON_WM_HELPINFO()
  393. //}}AFX_MSG_MAP
  394. END_MESSAGE_MAP()
  395. /////////////////////////////////////////////////////////////////////////////
  396. // CPreferencesDlg message handlers
  397. BOOL CPreferencesDlg::OnInitDialog()
  398. {
  399. CDialog::OnInitDialog();
  400. // TODO: Add extra initialization here
  401. CWinAdminApp *App = (CWinAdminApp*)AfxGetApp();
  402. CWinAdminDoc *pDoc = (CWinAdminDoc*)App->GetDocument();
  403. if(App->GetProcessListRefreshTime() == INFINITE) {
  404. CheckRadioButton(IDC_PREFERENCES_PROC_MANUAL, IDC_PREFERENCES_PROC_EVERY,
  405. IDC_PREFERENCES_PROC_MANUAL);
  406. SetDlgItemInt(IDC_PREFERENCES_PROC_SECONDS, 5);
  407. } else {
  408. CheckRadioButton(IDC_PREFERENCES_PROC_MANUAL, IDC_PREFERENCES_PROC_EVERY,
  409. IDC_PREFERENCES_PROC_EVERY);
  410. SetDlgItemInt(IDC_PREFERENCES_PROC_SECONDS, App->GetProcessListRefreshTime()/1000);
  411. }
  412. GetDlgItem(IDC_PREFERENCES_PROC_SECONDS)->EnableWindow((App->GetProcessListRefreshTime() == INFINITE) ? FALSE : TRUE);
  413. ((CEdit *)GetDlgItem(IDC_PREFERENCES_PROC_SECONDS))->LimitText(MAX_AUTOREFRESH_DIGITS-1);
  414. ((CSpinButtonCtrl*)GetDlgItem(IDC_PREFERENCES_PROC_SPIN))->SetRange(MIN_AUTOREFRESH_VALUE, MAX_AUTOREFRESH_VALUE);
  415. if(App->GetStatusRefreshTime() == INFINITE) {
  416. CheckRadioButton(IDC_PREFERENCES_STATUS_MANUAL, IDC_PREFERENCES_STATUS_EVERY,
  417. IDC_PREFERENCES_STATUS_MANUAL);
  418. SetDlgItemInt(IDC_PREFERENCES_STATUS_SECONDS, 1);
  419. } else {
  420. CheckRadioButton(IDC_PREFERENCES_STATUS_MANUAL, IDC_PREFERENCES_STATUS_EVERY,
  421. IDC_PREFERENCES_STATUS_EVERY);
  422. SetDlgItemInt(IDC_PREFERENCES_STATUS_SECONDS, App->GetStatusRefreshTime()/1000);
  423. }
  424. GetDlgItem(IDC_PREFERENCES_STATUS_SECONDS)->EnableWindow((App->GetStatusRefreshTime() == INFINITE) ? FALSE : TRUE);
  425. ((CEdit *)GetDlgItem(IDC_PREFERENCES_STATUS_SECONDS))->LimitText(MAX_AUTOREFRESH_DIGITS-1);
  426. ((CSpinButtonCtrl*)GetDlgItem(IDC_PREFERENCES_STATUS_SPIN))->SetRange(MIN_AUTOREFRESH_VALUE, MAX_AUTOREFRESH_VALUE);
  427. CheckDlgButton(IDC_PREFERENCES_CONFIRM, App->AskConfirmation() ? TRUE : FALSE);
  428. CheckDlgButton(IDC_PREFERENCES_SAVE, App->SavePreferences() ? TRUE : FALSE);
  429. CheckDlgButton(IDC_PREFERENCES_PERSISTENT, pDoc->AreConnectionsPersistent() ? TRUE : FALSE);
  430. return TRUE; // return TRUE unless you set the focus to a control
  431. // EXCEPTION: OCX Property Pages should return FALSE
  432. }
  433. void CPreferencesDlg::OnOK()
  434. {
  435. // TODO: Add extra validation here
  436. CWinAdminApp *App = (CWinAdminApp*)AfxGetApp();
  437. CWinAdminDoc *pDoc = (CWinAdminDoc*)App->GetDocument();
  438. ULONG value;
  439. if(((CButton*)GetDlgItem(IDC_PREFERENCES_PROC_MANUAL))->GetCheck()) {
  440. App->SetProcessListRefreshTime(INFINITE);
  441. // Tell the document that it has changed so
  442. // that he can wakeup the process thread
  443. ((CWinAdminDoc*)App->GetDocument())->ProcessListRefreshChanged(INFINITE);
  444. } else {
  445. value = GetDlgItemInt(IDC_PREFERENCES_PROC_SECONDS);
  446. if((value < MIN_AUTOREFRESH_VALUE) || (value > MAX_AUTOREFRESH_VALUE)) {
  447. // Invalid automatic refresh value
  448. CString MessageString;
  449. CString TitleString;
  450. CString FormatString;
  451. TitleString.LoadString(AFX_IDS_APP_TITLE);
  452. FormatString.LoadString(IDS_REFRESH_RANGE);
  453. MessageString.Format(FormatString, MIN_AUTOREFRESH_VALUE,
  454. MAX_AUTOREFRESH_VALUE);
  455. MessageBox(MessageString, TitleString, MB_ICONEXCLAMATION | MB_OK);
  456. GetDlgItem(IDC_PREFERENCES_PROC_SECONDS)->SetFocus();
  457. return;
  458. } else {
  459. // Has the value changed
  460. BOOL bChanged = FALSE;
  461. if(value*1000 != App->GetProcessListRefreshTime())
  462. bChanged = TRUE;
  463. //Save value in member variable as msec.
  464. App->SetProcessListRefreshTime(value * 1000);
  465. // Tell the document that it has changed so
  466. // that he can wakeup the process thread
  467. if(bChanged) {
  468. ((CWinAdminDoc*)App->GetDocument())->ProcessListRefreshChanged(value * 1000);
  469. }
  470. }
  471. }
  472. if(((CButton*)GetDlgItem(IDC_PREFERENCES_STATUS_MANUAL))->GetCheck()) {
  473. App->SetStatusRefreshTime(INFINITE);
  474. } else {
  475. value = GetDlgItemInt(IDC_PREFERENCES_STATUS_SECONDS);
  476. if((value < MIN_AUTOREFRESH_VALUE) || (value > MAX_AUTOREFRESH_VALUE)) {
  477. // Invalid automatic refresh value
  478. CString MessageString;
  479. CString TitleString;
  480. CString FormatString;
  481. TitleString.LoadString(AFX_IDS_APP_TITLE);
  482. FormatString.LoadString(IDS_REFRESH_RANGE);
  483. MessageString.Format(FormatString, MIN_AUTOREFRESH_VALUE,
  484. MAX_AUTOREFRESH_VALUE);
  485. MessageBox(MessageString, TitleString, MB_ICONEXCLAMATION | MB_OK);
  486. GetDlgItem(IDC_PREFERENCES_STATUS_SECONDS)->SetFocus();
  487. return;
  488. } else {
  489. //Save value in member variable as msec.
  490. App->SetStatusRefreshTime(value * 1000);
  491. }
  492. }
  493. App->SetConfirmation(((CButton *)GetDlgItem(IDC_PREFERENCES_CONFIRM))->GetCheck());
  494. App->SetSavePreferences(((CButton *)GetDlgItem(IDC_PREFERENCES_SAVE))->GetCheck());
  495. pDoc->SetConnectionsPersistent(((CButton *)GetDlgItem(IDC_PREFERENCES_PERSISTENT))->GetCheck());
  496. CDialog::OnOK();
  497. }
  498. void CPreferencesDlg::OnClose()
  499. {
  500. // TODO: Add your message handler code here and/or call default
  501. CDialog::OnClose();
  502. }
  503. void CPreferencesDlg::OnPreferencesProcManual()
  504. {
  505. // TODO: Add your control notification handler code here
  506. GetDlgItem(IDC_PREFERENCES_PROC_SECONDS)->EnableWindow(FALSE);
  507. }
  508. void CPreferencesDlg::OnPreferencesProcEvery()
  509. {
  510. // TODO: Add your control notification handler code here
  511. GetDlgItem(IDC_PREFERENCES_PROC_SECONDS)->EnableWindow(TRUE);
  512. }
  513. void CPreferencesDlg::OnPreferencesStatusEvery()
  514. {
  515. // TODO: Add your control notification handler code here
  516. GetDlgItem(IDC_PREFERENCES_STATUS_SECONDS)->EnableWindow(TRUE);
  517. }
  518. void CPreferencesDlg::OnPreferencesStatusManual()
  519. {
  520. // TODO: Add your control notification handler code here
  521. GetDlgItem(IDC_PREFERENCES_STATUS_SECONDS)->EnableWindow(FALSE);
  522. }
  523. BOOL CPreferencesDlg::OnHelpInfo(HELPINFO* pHelpInfo)
  524. {
  525. // TODO: Add your message handler code here and/or call default
  526. //((CWinAdminApp*)AfxGetApp())->WinHelp(HID_BASE_CONTROL + pHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
  527. if(pHelpInfo->iContextType == HELPINFO_WINDOW)
  528. {
  529. if(pHelpInfo->iCtrlId != IDC_STATIC)
  530. {
  531. ::WinHelp((HWND)pHelpInfo->hItemHandle,ID_HELP_FILE,HELP_WM_HELP,(ULONG_PTR)(LPVOID)aMenuHelpIDs);
  532. }
  533. }
  534. return (TRUE);
  535. }
  536. /////////////////////////////////////////////////////////////////////////////
  537. // CStatusDlg dialog
  538. CStatusDlg::CStatusDlg(CWinStation *pWinStation, UINT Id, CWnd* pParent /*=NULL*/)
  539. : CDialog(Id, pParent)
  540. {
  541. m_pWinStation = pWinStation;
  542. //{{AFX_DATA_INIT(CStatusDlg)
  543. // NOTE: the ClassWizard will add member initialization here
  544. //}}AFX_DATA_INIT
  545. }
  546. BEGIN_MESSAGE_MAP(CStatusDlg, CDialog)
  547. //{{AFX_MSG_MAP(CStatusDlg)
  548. ON_MESSAGE(WM_STATUSSTART, OnStatusStart)
  549. ON_MESSAGE(WM_STATUSREADY, OnStatusReady)
  550. ON_MESSAGE(WM_STATUSABORT, OnStatusAbort)
  551. ON_MESSAGE(WM_STATUSREFRESHNOW, OnRefreshNow)
  552. ON_BN_CLICKED(IDC_RESETCOUNTERS, OnResetcounters)
  553. ON_BN_CLICKED(IDC_REFRESHNOW, OnClickedRefreshnow)
  554. //}}AFX_MSG_MAP
  555. END_MESSAGE_MAP()
  556. /////////////////////////////////////////////////////////////////////////////
  557. // CStatusDlg message handlers
  558. BOOL CStatusDlg::OnInitDialog()
  559. {
  560. CDialog::OnInitDialog();
  561. // TODO: Add extra initialization here
  562. /*
  563. * Fetch current (big) size of dialog, then calculate the window size
  564. * needed to show the 'little' version of the dialog. Then, size the
  565. * window to the little version size and set the size flag to indicate
  566. * that we're 'little'.
  567. */
  568. RECT rectBigSize, rectLittleSize;
  569. GetWindowRect(&rectBigSize);
  570. m_BigSize.cx = (rectBigSize.right - rectBigSize.left) + 1;
  571. m_BigSize.cy = (rectBigSize.bottom - rectBigSize.top) + 1;
  572. // Some status dialogs don't have "More Info"
  573. CWnd *pWnd = GetDlgItem(IDC_MOREINFO);
  574. if(pWnd) {
  575. pWnd->GetWindowRect(&rectLittleSize);
  576. m_LittleSize.cx = m_BigSize.cx;
  577. m_LittleSize.cy = (rectLittleSize.bottom - rectBigSize.top) + 10;
  578. SetWindowPos( NULL, 0, 0, m_LittleSize.cx, m_LittleSize.cy,
  579. SWP_NOMOVE | SWP_NOZORDER );
  580. m_bWeAreLittle = TRUE;
  581. }
  582. #if 0
  583. /*
  584. * Disable the 'reset counters' button if we're read-only, and set the
  585. * 'reset counters' flag to FALSE;
  586. */
  587. if ( m_bReadOnly )
  588. GetDlgItem(IDC_RESETCOUNTERS)->EnableWindow(FALSE);
  589. #endif
  590. /*
  591. * Create CWSStatusThread, intialize its member variables, and start it up.
  592. */
  593. m_pWSStatusThread = new CWSStatusThread;
  594. if(m_pWSStatusThread) {
  595. m_pWSStatusThread->m_LogonId = m_pWinStation->GetLogonId();
  596. m_pWSStatusThread->m_hServer = m_pWinStation->GetServer()->GetHandle();
  597. m_pWSStatusThread->m_hDlg = m_hWnd;
  598. VERIFY(m_pWSStatusThread->CreateThread());
  599. }
  600. m_bResetCounters = FALSE;
  601. GetDlgItem(IDC_COMMON_ICOMPRESSIONRATIO2)->ShowWindow(SW_HIDE);
  602. GetDlgItem(IDC_COMMON_OCOMPRESSIONRATIO2)->ShowWindow(SW_HIDE);
  603. GetDlgItem(IDC_COMMON_IPERCENTFRAMEERRORS2)->ShowWindow(SW_HIDE);
  604. GetDlgItem(IDC_COMMON_OPERCENTFRAMEERRORS2)->ShowWindow(SW_HIDE);
  605. // If we don't have Reliable Pd loaded, default error fields to 'N/A'
  606. // (m_szICompressionRatio got initialized to the 'n/a' string)...
  607. if(!m_bReliable) {
  608. SetDlgItemText(IDC_COMMON_IFRAMEERRORS, m_szICompressionRatio);
  609. SetDlgItemText(IDC_COMMON_OFRAMEERRORS, m_szICompressionRatio);
  610. SetDlgItemText(IDC_COMMON_IPERCENTFRAMEERRORS, m_szICompressionRatio);
  611. SetDlgItemText(IDC_COMMON_OPERCENTFRAMEERRORS, m_szICompressionRatio);
  612. SetDlgItemText(IDC_COMMON_ITIMEOUTERRORS, m_szICompressionRatio);
  613. SetDlgItemText(IDC_COMMON_OTIMEOUTERRORS, m_szICompressionRatio);
  614. }
  615. // Default the Compression Ratio fields to 'N/A'.
  616. SetDlgItemText(IDC_COMMON_ICOMPRESSIONRATIO, m_szICompressionRatio);
  617. SetDlgItemText(IDC_COMMON_OCOMPRESSIONRATIO, m_szICompressionRatio);
  618. return TRUE; // return TRUE unless you set the focus to a control
  619. // EXCEPTION: OCX Property Pages should return FALSE
  620. }
  621. void CStatusDlg::SetInfoFields( PWINSTATIONINFORMATION pCurrent,
  622. PWINSTATIONINFORMATION pNew )
  623. {
  624. /*
  625. * If the 'reset counters' flag is set, 1-fill the current Input and Output
  626. * PROTOCOLCOUNTERS structures (to force all fields to update), copy the
  627. * pNew PROTOCOLSTATUS information into the global m_BaseStatus structure,
  628. * and reset the flag.
  629. */
  630. if(m_bResetCounters) {
  631. memset(&pCurrent->Status.Input, 0xff, sizeof(pCurrent->Status.Input));
  632. memset(&pCurrent->Status.Output, 0xff, sizeof(pCurrent->Status.Output));
  633. m_BaseStatus = pNew->Status;
  634. m_bResetCounters = FALSE;
  635. }
  636. /*
  637. * Set title and determine Pds loaded if change in connect state.
  638. */
  639. if(pCurrent->ConnectState != pNew->ConnectState) {
  640. TCHAR szTitle[128];
  641. CString TitleFormat;
  642. LPCTSTR pState = NULL;
  643. TitleFormat.LoadString(IDS_STATUS_FORMAT);
  644. pState = StrConnectState( pNew->ConnectState, FALSE );
  645. if(pState)
  646. {
  647. wsprintf( szTitle, TitleFormat, pNew->LogonId,pState);
  648. SetWindowText(szTitle);
  649. }
  650. /*
  651. * TODO when WinStationGetInformation can return all PDs loaded:
  652. * Determine Pds that are loaded and set the state of
  653. * associated flags and field defaults.
  654. */
  655. }
  656. /*
  657. * Set UserName and WinStationName if change. We will also
  658. * set the WinStationName if there was a change in the connect state,
  659. * even if the WinStationName itself may not have changed, since we
  660. * represent connected and disconnect WinStationName fields differently.
  661. */
  662. if(lstrcmp(pCurrent->UserName, pNew->UserName))
  663. SetDlgItemText(IDC_COMMON_USERNAME, pNew->UserName);
  664. if(lstrcmp(pCurrent->WinStationName, pNew->WinStationName) ||
  665. (pCurrent->ConnectState != pNew->ConnectState)) {
  666. TCHAR szWSName[WINSTATIONNAME_LENGTH+3];
  667. if(pNew->ConnectState == State_Disconnected) {
  668. lstrcpy( szWSName, TEXT("(") );
  669. lstrcat( szWSName, pNew->WinStationName );
  670. lstrcat( szWSName, TEXT(")") );
  671. } else
  672. lstrcpy( szWSName, pNew->WinStationName );
  673. SetDlgItemText(IDC_COMMON_WINSTATIONNAME, szWSName);
  674. }
  675. /*
  676. * Set the common Input and Output numeric fields.
  677. */
  678. if(pCurrent->Status.Input.Bytes != pNew->Status.Input.Bytes)
  679. SetDlgItemInt(IDC_COMMON_IBYTES,
  680. pNew->Status.Input.Bytes -
  681. m_BaseStatus.Input.Bytes,
  682. FALSE);
  683. if(pCurrent->Status.Output.Bytes != pNew->Status.Output.Bytes)
  684. SetDlgItemInt(IDC_COMMON_OBYTES,
  685. pNew->Status.Output.Bytes -
  686. m_BaseStatus.Output.Bytes,
  687. FALSE);
  688. if(pCurrent->Status.Input.Frames != pNew->Status.Input.Frames)
  689. SetDlgItemInt(IDC_COMMON_IFRAMES,
  690. pNew->Status.Input.Frames -
  691. m_BaseStatus.Input.Frames,
  692. FALSE);
  693. if(pCurrent->Status.Output.Frames != pNew->Status.Output.Frames)
  694. SetDlgItemInt(IDC_COMMON_OFRAMES,
  695. pNew->Status.Output.Frames -
  696. m_BaseStatus.Output.Frames,
  697. FALSE);
  698. if((pCurrent->Status.Input.Bytes != pNew->Status.Input.Bytes) ||
  699. (pCurrent->Status.Input.Frames != pNew->Status.Input.Frames)) {
  700. UINT temp;
  701. temp = (pNew->Status.Input.Frames - m_BaseStatus.Input.Frames) ?
  702. ((pNew->Status.Input.Bytes - m_BaseStatus.Input.Bytes) /
  703. (pNew->Status.Input.Frames - m_BaseStatus.Input.Frames)) : 0;
  704. if(temp != m_IBytesPerFrame)
  705. SetDlgItemInt(IDC_COMMON_IBYTESPERFRAME,
  706. m_IBytesPerFrame = temp, FALSE);
  707. }
  708. if((pCurrent->Status.Output.Bytes != pNew->Status.Output.Bytes) ||
  709. (pCurrent->Status.Output.Frames != pNew->Status.Output.Frames)) {
  710. UINT temp;
  711. temp = (pNew->Status.Output.Frames - m_BaseStatus.Output.Frames) ?
  712. ((pNew->Status.Output.Bytes - m_BaseStatus.Output.Bytes) /
  713. (pNew->Status.Output.Frames - m_BaseStatus.Output.Frames)) : 0;
  714. if(temp != m_OBytesPerFrame)
  715. SetDlgItemInt( IDC_COMMON_OBYTESPERFRAME,
  716. m_OBytesPerFrame = temp, FALSE);
  717. }
  718. if(m_bReliable) {
  719. if(pCurrent->Status.Input.Errors != pNew->Status.Input.Errors)
  720. SetDlgItemInt(IDC_COMMON_IFRAMEERRORS,
  721. pNew->Status.Input.Errors -
  722. m_BaseStatus.Input.Errors,
  723. FALSE);
  724. if(pCurrent->Status.Output.Errors != pNew->Status.Output.Errors)
  725. SetDlgItemInt(IDC_COMMON_OFRAMEERRORS,
  726. pNew->Status.Output.Errors -
  727. m_BaseStatus.Output.Errors,
  728. FALSE);
  729. if((pCurrent->Status.Input.Frames != pNew->Status.Input.Frames) ||
  730. (pCurrent->Status.Input.Errors != pNew->Status.Input.Errors)) {
  731. TCHAR szTemp[10];
  732. int q, r;
  733. if((pNew->Status.Input.Errors - m_BaseStatus.Input.Errors) &&
  734. (pNew->Status.Input.Frames - m_BaseStatus.Input.Frames)) {
  735. double temp;
  736. temp = ((double)(pNew->Status.Input.Errors - m_BaseStatus.Input.Errors) * 100.0)
  737. / (double)(pNew->Status.Input.Frames - m_BaseStatus.Input.Frames);
  738. q = (int)temp;
  739. if ( (r = (int)((temp - (double)q) * 100.0)) == 0 )
  740. r = 1;
  741. } else {
  742. /*
  743. * Special case for 0 frames or 0 errors.
  744. */
  745. q = 0;
  746. r = 0;
  747. }
  748. lstrnprintf(szTemp, 10, TEXT("%d.%02d%%"), q, r);
  749. /*
  750. * Only output if changed from previous.
  751. */
  752. if(lstrcmp(szTemp, m_szIPercentFrameErrors)) {
  753. lstrcpy(m_szIPercentFrameErrors, szTemp);
  754. GetDlgItem(IDC_COMMON_IPERCENTFRAMEERRORS)->ShowWindow(SW_HIDE);
  755. GetDlgItem(IDC_COMMON_IPERCENTFRAMEERRORS2)->ShowWindow(SW_SHOW);
  756. SetDlgItemText(IDC_COMMON_IPERCENTFRAMEERRORS2, szTemp);
  757. }
  758. }
  759. if((pCurrent->Status.Output.Frames != pNew->Status.Output.Frames) ||
  760. (pCurrent->Status.Output.Errors != pNew->Status.Output.Errors)) {
  761. TCHAR szTemp[10];
  762. int q, r;
  763. if((pNew->Status.Output.Errors - m_BaseStatus.Output.Errors) &&
  764. (pNew->Status.Output.Frames - m_BaseStatus.Output.Frames)) {
  765. double temp;
  766. temp = ((double)(pNew->Status.Output.Errors - m_BaseStatus.Output.Errors) * 100.0)
  767. / (double)(pNew->Status.Output.Frames - m_BaseStatus.Output.Frames);
  768. q = (int)temp;
  769. if ( (r = (int)((temp - (double)q) * 100.0)) == 0 )
  770. r = 1;
  771. } else {
  772. /*
  773. * Special case for 0 frames or 0 errors.
  774. */
  775. q = 0;
  776. r = 0;
  777. }
  778. lstrnprintf(szTemp, 10, TEXT("%d.%02d%%"), q, r);
  779. /*
  780. * Only output if changed from previous.
  781. */
  782. if(lstrcmp(szTemp, m_szOPercentFrameErrors)) {
  783. lstrcpy(m_szOPercentFrameErrors, szTemp);
  784. GetDlgItem(IDC_COMMON_OPERCENTFRAMEERRORS)->ShowWindow(SW_HIDE);
  785. GetDlgItem(IDC_COMMON_OPERCENTFRAMEERRORS2)->ShowWindow(SW_SHOW);
  786. SetDlgItemText(IDC_COMMON_OPERCENTFRAMEERRORS2, szTemp);
  787. }
  788. }
  789. if(pCurrent->Status.Input.Timeouts != pNew->Status.Input.Timeouts)
  790. SetDlgItemInt(IDC_COMMON_ITIMEOUTERRORS,
  791. pNew->Status.Input.Timeouts -
  792. m_BaseStatus.Input.Timeouts,
  793. FALSE);
  794. if(pCurrent->Status.Output.Timeouts != pNew->Status.Output.Timeouts)
  795. SetDlgItemInt(IDC_COMMON_OTIMEOUTERRORS,
  796. pNew->Status.Output.Timeouts -
  797. m_BaseStatus.Output.Timeouts,
  798. FALSE);
  799. }
  800. /*
  801. * NOTE: for these compression ratio calculations, the "CompressedBytes" field is
  802. * actually 'Bytes before compression', that is, it is the byte count in the middle
  803. * of the WD/PD stack. "WdBytes" are the bytes input/output at the app level (and is
  804. * not displayed in any WinAdmin counters). "CompressedBytes" include any overhead
  805. * bytes added by the stack. "Bytes" represent the actual number of bytes input/output
  806. * over the 'wire'; hence, we use Bytes for all counter display and "CompressedBytes" to
  807. * calculate compression ratios.
  808. */
  809. if((pNew->Status.Input.CompressedBytes || m_BaseStatus.Input.CompressedBytes) &&
  810. ((pCurrent->Status.Input.Bytes != pNew->Status.Input.Bytes) ||
  811. (pCurrent->Status.Input.CompressedBytes != pNew->Status.Input.CompressedBytes)) ) {
  812. TCHAR szTemp[10];
  813. int q, r;
  814. if((pNew->Status.Input.CompressedBytes - m_BaseStatus.Input.CompressedBytes)) {
  815. double temp;
  816. temp = (double)(pNew->Status.Input.CompressedBytes -
  817. m_BaseStatus.Input.CompressedBytes) /
  818. (double)(pNew->Status.Input.Bytes - m_BaseStatus.Input.Bytes);
  819. q = (int)temp;
  820. r = (int)((temp - (double)q) * 100.0);
  821. } else {
  822. /*
  823. * Special case for 0 compressed bytes (compression turned off or counters reset).
  824. */
  825. q = 0;
  826. r = 0;
  827. }
  828. lstrnprintf(szTemp, 10, TEXT("%d.%02d"), q, r);
  829. /*
  830. * Only output if changed from previous.
  831. */
  832. if(lstrcmp(szTemp, m_szICompressionRatio)) {
  833. lstrcpy(m_szICompressionRatio, szTemp);
  834. GetDlgItem(IDC_COMMON_ICOMPRESSIONRATIO)->ShowWindow(SW_HIDE);
  835. GetDlgItem(IDC_COMMON_ICOMPRESSIONRATIO2)->ShowWindow(SW_SHOW);
  836. SetDlgItemText(IDC_COMMON_ICOMPRESSIONRATIO2, szTemp);
  837. }
  838. }
  839. if((pNew->Status.Output.CompressedBytes || m_BaseStatus.Output.CompressedBytes) &&
  840. ((pCurrent->Status.Output.Bytes != pNew->Status.Output.Bytes) ||
  841. (pCurrent->Status.Output.CompressedBytes != pNew->Status.Output.CompressedBytes))) {
  842. TCHAR szTemp[10];
  843. int q, r;
  844. if((pNew->Status.Output.CompressedBytes - m_BaseStatus.Output.CompressedBytes)) {
  845. double temp;
  846. temp = (double)(pNew->Status.Output.CompressedBytes -
  847. m_BaseStatus.Output.CompressedBytes) /
  848. (double)(pNew->Status.Output.Bytes - m_BaseStatus.Output.Bytes);
  849. q = (int)temp;
  850. r = (int)((temp - (double)q) * 100.0);
  851. } else {
  852. /*
  853. * Special case for 0 compressed bytes (compression turned off or counters reset).
  854. */
  855. q = 0;
  856. r = 0;
  857. }
  858. lstrnprintf(szTemp, 10, TEXT("%d.%02d"), q, r);
  859. /*
  860. * Only output if changed from previous.
  861. */
  862. if(lstrcmp(szTemp, m_szOCompressionRatio)) {
  863. lstrcpy(m_szOCompressionRatio, szTemp);
  864. GetDlgItem(IDC_COMMON_OCOMPRESSIONRATIO)->ShowWindow(SW_HIDE);
  865. GetDlgItem(IDC_COMMON_OCOMPRESSIONRATIO2)->ShowWindow(SW_SHOW);
  866. SetDlgItemText(IDC_COMMON_OCOMPRESSIONRATIO2, szTemp);
  867. }
  868. }
  869. } // end CStatusDlg::SetInfoFields
  870. void CStatusDlg::InitializeStatus()
  871. {
  872. // Initialize structures and variables.
  873. memset( &m_WSInfo, 0xff, sizeof(m_WSInfo) );
  874. memset( &m_BaseStatus, 0, sizeof(m_BaseStatus) );
  875. m_IBytesPerFrame = m_OBytesPerFrame = INFINITE;
  876. lstrcpy(m_szICompressionRatio, TEXT("n/a"));
  877. lstrcpy(m_szOCompressionRatio, m_szICompressionRatio);
  878. // If this WinStation does not have a Reliable PD loaded,
  879. // set flag to skip those counters.
  880. PDPARAMS PdParams;
  881. ULONG ReturnLength;
  882. PdParams.SdClass = SdReliable;
  883. if (!WinStationQueryInformation(m_pWinStation->GetServer()->GetHandle(),
  884. m_pWinStation->GetLogonId(),
  885. WinStationPdParams,
  886. &PdParams, sizeof(PdParams),
  887. &ReturnLength ) ||
  888. (PdParams.SdClass != SdReliable) ) {
  889. m_bReliable = FALSE;
  890. } else {
  891. m_bReliable = TRUE;
  892. }
  893. } // end CStatusDlg::InitializeStatus
  894. void CStatusDlg::OnCancel()
  895. {
  896. // TODO: Add extra cleanup here
  897. m_pWSStatusThread->ExitThread();
  898. CDialog::OnCancel();
  899. }
  900. void CStatusDlg::OnResetcounters()
  901. {
  902. // TODO: Add your control notification handler code here
  903. m_bResetCounters = TRUE;
  904. OnClickedRefreshnow();
  905. }
  906. void CStatusDlg::OnClickedRefreshnow()
  907. {
  908. // TODO: Add your control notification handler code here
  909. /*
  910. * Tell the status thread to wake up now.
  911. */
  912. m_pWSStatusThread->SignalWakeUp();
  913. // return(0);
  914. }
  915. void CStatusDlg::PostNcDestroy()
  916. {
  917. CDialog::PostNcDestroy();
  918. delete this;
  919. }
  920. BOOL CStatusDlg::PreTranslateMessage(MSG *pMsg)
  921. {
  922. if ( IsDialogMessage(pMsg) )
  923. return(TRUE);
  924. else
  925. return( CDialog::PreTranslateMessage(pMsg) );
  926. } // end CStatusDlg::PreTranslateMessage
  927. /*******************************************************************************
  928. *
  929. * OnRefreshNow - CWSStatusDlg member function: command
  930. *
  931. * Processes in response to main frame's WM_STATUSREFRESHNOW notification
  932. * that the user has changed the status refresh options.
  933. *
  934. * ENTRY:
  935. *
  936. * EXIT:
  937. * (LRESULT) always returns 0 to indicate operation complete.
  938. *
  939. ******************************************************************************/
  940. LRESULT
  941. CStatusDlg::OnRefreshNow( WPARAM wParam,
  942. LPARAM lParam )
  943. {
  944. /*
  945. * Tell the status thread to wake up now.
  946. */
  947. m_pWSStatusThread->SignalWakeUp();
  948. return(0);
  949. } // end CWSStatusDlg::OnRefreshNow
  950. /*******************************************************************************
  951. *
  952. * OnStatusStart - CWSStatusDlg member function: command
  953. *
  954. * Process the WM_STATUSSTART message to initialize the 'static'
  955. * PD-related fields.
  956. *
  957. * NOTE: the derived class must override this function to process any
  958. * PD-related fields as necessary, then call / return this function.
  959. *
  960. * ENTRY:
  961. *
  962. * EXIT:
  963. * (LRESULT) returns the result of the OnStatusReady member function,
  964. * which is always 0, indicating operation complete.
  965. *
  966. ******************************************************************************/
  967. LRESULT
  968. CStatusDlg::OnStatusStart( WPARAM wParam,
  969. LPARAM lParam )
  970. {
  971. /*
  972. * Call / return the OnStatusReady function to update the standard dialog
  973. * info fields.
  974. */
  975. return ( OnStatusReady( wParam, lParam ) );
  976. } // end CWSStatusDlg::OnStatusStart
  977. /*******************************************************************************
  978. *
  979. * OnStatusReady - CWSStatusDlg member function: command
  980. *
  981. * Process the WM_STATUSREADY message to update the dialog Info fields.
  982. *
  983. * NOTE: the derived class must override this function to call it's
  984. * override of the SetInfoFields function, which could then call / return
  985. * this function or completely override all functionality contained here.
  986. *
  987. * ENTRY:
  988. *
  989. * EXIT:
  990. * (LRESULT) always returns 0 to indicate operation complete.
  991. *
  992. ******************************************************************************/
  993. LRESULT
  994. CStatusDlg::OnStatusReady( WPARAM wParam,
  995. LPARAM lParam )
  996. {
  997. /*
  998. * Update dialog fields with information from the CWStatusThread's
  999. * WINSTATIONINFORMATION structure.
  1000. */
  1001. SetInfoFields( &m_WSInfo, &(m_pWSStatusThread->m_WSInfo) );
  1002. /*
  1003. * Set our working WSInfo structure to the new one and signal the thread
  1004. * that we're done.
  1005. */
  1006. m_WSInfo = m_pWSStatusThread->m_WSInfo;
  1007. m_pWSStatusThread->SignalConsumed();
  1008. return(0);
  1009. } // end CWSStatusDlg::OnStatusReady
  1010. /*******************************************************************************
  1011. *
  1012. * OnStatusAbort - CWSStatusDlg member function: command
  1013. *
  1014. * Process the WM_STATUSABORT message to exit the thread and dialog.
  1015. *
  1016. * ENTRY:
  1017. *
  1018. * EXIT:
  1019. * (LRESULT) always returns 0 to indicate operation complete.
  1020. *
  1021. ******************************************************************************/
  1022. LRESULT
  1023. CStatusDlg::OnStatusAbort( WPARAM wParam,
  1024. LPARAM lParam )
  1025. {
  1026. /*
  1027. * Call the OnCancel() member function to exit dialog and thread and
  1028. * perform proper cleanup.
  1029. */
  1030. OnCancel();
  1031. return(0);
  1032. } // end CWSStatusDlg::OnStatusAbort
  1033. /////////////////////////////////////////////////////////////////////////////
  1034. // CAsyncStatusDlg dialog
  1035. CAsyncStatusDlg::CAsyncStatusDlg(CWinStation *pWinStation, CWnd* pParent /*=NULL*/)
  1036. : CStatusDlg(pWinStation, CAsyncStatusDlg::IDD, pParent),
  1037. m_hRedBrush(NULL),
  1038. m_LEDToggleTimer(0)
  1039. {
  1040. //{{AFX_DATA_INIT(CAsyncStatusDlg)
  1041. // NOTE: the ClassWizard will add member initialization here
  1042. //}}AFX_DATA_INIT
  1043. int i;
  1044. /*
  1045. * Initialize member variables, our local status storage,
  1046. * and create a modeless dialog.
  1047. */
  1048. // m_LogonId = LogonId;
  1049. // m_bReadOnly = bReadOnly;
  1050. InitializeStatus();
  1051. /*
  1052. * Create a solid RED brush for painting the 'LED's when 'on'.
  1053. */
  1054. VERIFY( m_hRedBrush = CreateSolidBrush(RGB(255,0,0)) );
  1055. /*
  1056. * Create the led objects (must do BEFORE dialog create).
  1057. */
  1058. for ( i = 0; i < NUM_LEDS; i++ )
  1059. m_pLeds[i] = new CLed(m_hRedBrush);
  1060. /*
  1061. * Finally, create the modeless dialog.
  1062. */
  1063. VERIFY(CStatusDlg::Create(IDD_ASYNC_STATUS));
  1064. }
  1065. /*******************************************************************************
  1066. *
  1067. * ~CAsyncStatusDlg - CAsyncStatusDlg destructor
  1068. *
  1069. * ENTRY:
  1070. * EXIT:
  1071. * (Refer to MFC CDialog::~CDialog documentation)
  1072. *
  1073. ******************************************************************************/
  1074. CAsyncStatusDlg::~CAsyncStatusDlg()
  1075. {
  1076. int i;
  1077. /*
  1078. * Zap our led objects.
  1079. */
  1080. for ( i = 0; i < NUM_LEDS; i++ )
  1081. if ( m_pLeds[i] )
  1082. delete m_pLeds[i];
  1083. } // end CAsyncStatusDlg::~CAsyncStatusDlg
  1084. /*******************************************************************************
  1085. *
  1086. * InitializeStatus - CAsyncStatusDlg member function: override
  1087. *
  1088. * Special case reset of the LED states in the WINSTATIONINFORMATION
  1089. * status structure.
  1090. *
  1091. * ENTRY:
  1092. * EXIT:
  1093. *
  1094. ******************************************************************************/
  1095. void
  1096. CAsyncStatusDlg::InitializeStatus()
  1097. {
  1098. /*
  1099. * Call the parent classes' InitializeStatus(), then reset the 'LED'
  1100. * states to all 'off' & 'not toggled'.
  1101. */
  1102. CStatusDlg::InitializeStatus();
  1103. m_WSInfo.Status.AsyncSignal = m_WSInfo.Status.AsyncSignalMask = 0;
  1104. } // end CAsyncStatusDlg::InitializeStatus
  1105. /*******************************************************************************
  1106. *
  1107. * SetInfoFields - CAsyncStatusDlg member function: override
  1108. *
  1109. * Update the fields in the dialog with new data, if necessary.
  1110. *
  1111. * ENTRY:
  1112. * pCurrent (input)
  1113. * points to WINSTATIONINFORMATION structure containing the current
  1114. * dialog data.
  1115. * pNew (input)
  1116. * points to WINSTATIONINFORMATION structure containing the new
  1117. * dialog data.
  1118. *
  1119. * EXIT:
  1120. *
  1121. ******************************************************************************/
  1122. void
  1123. CAsyncStatusDlg::SetInfoFields( PWINSTATIONINFORMATION pCurrent,
  1124. PWINSTATIONINFORMATION pNew )
  1125. {
  1126. BOOL bSetTimer = FALSE;
  1127. /*
  1128. * Call the parent's SetInfoFields().
  1129. */
  1130. CStatusDlg::SetInfoFields( pCurrent, pNew );
  1131. /*
  1132. * Set new LED states if state change, or set up for quick toggle if
  1133. * no state changed, but change(s) were detected since last query.
  1134. */
  1135. if ( (pCurrent->Status.AsyncSignal & MS_DTR_ON) !=
  1136. (pNew->Status.AsyncSignal & MS_DTR_ON) ) {
  1137. pNew->Status.AsyncSignalMask &= ~EV_DTR;
  1138. ((CLed *)GetDlgItem(IDC_ASYNC_DTR))->
  1139. Update(pNew->Status.AsyncSignal & MS_DTR_ON);
  1140. } else if ( pNew->Status.AsyncSignalMask & EV_DTR ) {
  1141. pCurrent->Status.AsyncSignal ^= MS_DTR_ON;
  1142. ((CLed *)GetDlgItem(IDC_ASYNC_DTR))->Toggle();
  1143. bSetTimer = TRUE;
  1144. }
  1145. if ( (pCurrent->Status.AsyncSignal & MS_RTS_ON) !=
  1146. (pNew->Status.AsyncSignal & MS_RTS_ON) ) {
  1147. pNew->Status.AsyncSignalMask &= ~EV_RTS;
  1148. ((CLed *)GetDlgItem(IDC_ASYNC_RTS))->
  1149. Update(pNew->Status.AsyncSignal & MS_RTS_ON);
  1150. } else if ( pNew->Status.AsyncSignalMask & EV_RTS ) {
  1151. pCurrent->Status.AsyncSignal ^= MS_RTS_ON;
  1152. ((CLed *)GetDlgItem(IDC_ASYNC_RTS))->Toggle();
  1153. bSetTimer = TRUE;
  1154. }
  1155. if ( (pCurrent->Status.AsyncSignal & MS_CTS_ON) !=
  1156. (pNew->Status.AsyncSignal & MS_CTS_ON) ) {
  1157. pNew->Status.AsyncSignalMask &= ~EV_CTS;
  1158. ((CLed *)GetDlgItem(IDC_ASYNC_CTS))->
  1159. Update(pNew->Status.AsyncSignal & MS_CTS_ON);
  1160. } else if ( pNew->Status.AsyncSignalMask & EV_CTS ) {
  1161. pCurrent->Status.AsyncSignal ^= MS_CTS_ON;
  1162. ((CLed *)GetDlgItem(IDC_ASYNC_CTS))->Toggle();
  1163. bSetTimer = TRUE;
  1164. }
  1165. if ( (pCurrent->Status.AsyncSignal & MS_RLSD_ON) !=
  1166. (pNew->Status.AsyncSignal & MS_RLSD_ON) ) {
  1167. pNew->Status.AsyncSignalMask &= ~EV_RLSD;
  1168. ((CLed *)GetDlgItem(IDC_ASYNC_DCD))->
  1169. Update(pNew->Status.AsyncSignal & MS_RLSD_ON);
  1170. } else if ( pNew->Status.AsyncSignalMask & EV_RLSD ) {
  1171. pCurrent->Status.AsyncSignal ^= MS_RLSD_ON;
  1172. ((CLed *)GetDlgItem(IDC_ASYNC_DCD))->Toggle();
  1173. bSetTimer = TRUE;
  1174. }
  1175. if ( (pCurrent->Status.AsyncSignal & MS_DSR_ON) !=
  1176. (pNew->Status.AsyncSignal & MS_DSR_ON) ) {
  1177. pNew->Status.AsyncSignalMask &= ~EV_DSR;
  1178. ((CLed *)GetDlgItem(IDC_ASYNC_DSR))->
  1179. Update(pNew->Status.AsyncSignal & MS_DSR_ON);
  1180. } else if ( pNew->Status.AsyncSignalMask & EV_DSR ) {
  1181. pCurrent->Status.AsyncSignal ^= MS_DSR_ON;
  1182. ((CLed *)GetDlgItem(IDC_ASYNC_DSR))->Toggle();
  1183. bSetTimer = TRUE;
  1184. }
  1185. if ( (pCurrent->Status.AsyncSignal & MS_RING_ON) !=
  1186. (pNew->Status.AsyncSignal & MS_RING_ON) ) {
  1187. pNew->Status.AsyncSignalMask &= ~EV_RING;
  1188. ((CLed *)GetDlgItem(IDC_ASYNC_RI))->
  1189. Update(pNew->Status.AsyncSignal & MS_RING_ON);
  1190. } else if ( pNew->Status.AsyncSignalMask & EV_RING ) {
  1191. pCurrent->Status.AsyncSignal ^= MS_RING_ON;
  1192. ((CLed *)GetDlgItem(IDC_ASYNC_RI))->Toggle();
  1193. bSetTimer = TRUE;
  1194. }
  1195. /*
  1196. * Create our led toggle timer if needed.
  1197. */
  1198. if ( bSetTimer && !m_LEDToggleTimer )
  1199. m_LEDToggleTimer = SetTimer( IDD_ASYNC_STATUS,
  1200. ASYNC_LED_TOGGLE_MSEC, NULL );
  1201. /*
  1202. * Set ASYNC-specific numeric fields if change.
  1203. */
  1204. if ( pCurrent->Status.Input.AsyncFramingError != pNew->Status.Input.AsyncFramingError )
  1205. SetDlgItemInt( IDC_ASYNC_IFRAMING,
  1206. pNew->Status.Input.AsyncFramingError - m_BaseStatus.Input.AsyncFramingError,
  1207. FALSE );
  1208. if ( pCurrent->Status.Output.AsyncFramingError != pNew->Status.Output.AsyncFramingError )
  1209. SetDlgItemInt( IDC_ASYNC_OFRAMING,
  1210. pNew->Status.Output.AsyncFramingError - m_BaseStatus.Output.AsyncFramingError,
  1211. FALSE );
  1212. if ( pCurrent->Status.Input.AsyncOverrunError != pNew->Status.Input.AsyncOverrunError )
  1213. SetDlgItemInt( IDC_ASYNC_IOVERRUN,
  1214. pNew->Status.Input.AsyncOverrunError - m_BaseStatus.Input.AsyncOverrunError,
  1215. FALSE );
  1216. if ( pCurrent->Status.Output.AsyncOverrunError != pNew->Status.Output.AsyncOverrunError )
  1217. SetDlgItemInt( IDC_ASYNC_OOVERRUN,
  1218. pNew->Status.Output.AsyncOverrunError - m_BaseStatus.Output.AsyncOverrunError,
  1219. FALSE );
  1220. if ( pCurrent->Status.Input.AsyncOverflowError != pNew->Status.Input.AsyncOverflowError )
  1221. SetDlgItemInt( IDC_ASYNC_IOVERFLOW,
  1222. pNew->Status.Input.AsyncOverflowError - m_BaseStatus.Input.AsyncOverflowError,
  1223. FALSE );
  1224. if ( pCurrent->Status.Output.AsyncOverflowError != pNew->Status.Output.AsyncOverflowError )
  1225. SetDlgItemInt( IDC_ASYNC_OOVERFLOW,
  1226. pNew->Status.Output.AsyncOverflowError - m_BaseStatus.Output.AsyncOverflowError,
  1227. FALSE );
  1228. if ( pCurrent->Status.Input.AsyncParityError != pNew->Status.Input.AsyncParityError )
  1229. SetDlgItemInt( IDC_ASYNC_IPARITY,
  1230. pNew->Status.Input.AsyncParityError - m_BaseStatus.Input.AsyncParityError,
  1231. FALSE );
  1232. if ( pCurrent->Status.Output.AsyncParityError != pNew->Status.Output.AsyncParityError )
  1233. SetDlgItemInt( IDC_ASYNC_OPARITY,
  1234. pNew->Status.Output.AsyncParityError - m_BaseStatus.Output.AsyncParityError,
  1235. FALSE );
  1236. } // end CAsyncStatusDlg::SetInfoFields
  1237. void CAsyncStatusDlg::DoDataExchange(CDataExchange* pDX)
  1238. {
  1239. CDialog::DoDataExchange(pDX);
  1240. //{{AFX_DATA_MAP(CAsyncStatusDlg)
  1241. // NOTE: the ClassWizard will add DDX and DDV calls here
  1242. //}}AFX_DATA_MAP
  1243. }
  1244. BEGIN_MESSAGE_MAP(CAsyncStatusDlg, CDialog)
  1245. //{{AFX_MSG_MAP(CAsyncStatusDlg)
  1246. ON_MESSAGE(WM_STATUSSTART, OnStatusStart)
  1247. ON_MESSAGE(WM_STATUSREADY, OnStatusReady)
  1248. ON_MESSAGE(WM_STATUSABORT, OnStatusAbort)
  1249. ON_MESSAGE(WM_STATUSREFRESHNOW, OnRefreshNow)
  1250. ON_BN_CLICKED(IDC_RESETCOUNTERS, OnResetcounters)
  1251. ON_BN_CLICKED(IDC_REFRESHNOW, OnClickedRefreshnow)
  1252. ON_BN_CLICKED(IDC_MOREINFO, OnMoreinfo)
  1253. ON_WM_TIMER()
  1254. ON_WM_NCDESTROY()
  1255. ON_WM_HELPINFO()
  1256. ON_COMMAND(ID_HELP,OnCommandHelp)
  1257. //}}AFX_MSG_MAP
  1258. END_MESSAGE_MAP()
  1259. /////////////////////////////////////////////////////////////////////////////
  1260. // CAsyncStatusDlg message handlers
  1261. /*******************************************************************************
  1262. *
  1263. * OnInitDialog - CAsyncStatusDlg member function: command (override)
  1264. *
  1265. * Performs async-specific dialog intialization.
  1266. *
  1267. * ENTRY:
  1268. * EXIT:
  1269. * (Refer to CDialog::OnInitDialog documentation)
  1270. *
  1271. ******************************************************************************/
  1272. static int LedIds[NUM_LEDS] = {
  1273. IDC_ASYNC_DTR,
  1274. IDC_ASYNC_RTS,
  1275. IDC_ASYNC_CTS,
  1276. IDC_ASYNC_DSR,
  1277. IDC_ASYNC_DCD,
  1278. IDC_ASYNC_RI };
  1279. BOOL CAsyncStatusDlg::OnInitDialog()
  1280. {
  1281. int i;
  1282. /*
  1283. * Perform parent's OnInitDialog() first.
  1284. */
  1285. CStatusDlg::OnInitDialog();
  1286. /*
  1287. * Subclass the led controls and default to 'off'.
  1288. */
  1289. for ( i = 0; i < NUM_LEDS; i++ ) {
  1290. m_pLeds[i]->Subclass( (CStatic *)GetDlgItem(LedIds[i]) );
  1291. m_pLeds[i]->Update(0);
  1292. }
  1293. return(TRUE);
  1294. } // end CAsyncStatusDlg::OnInitDialog
  1295. void CAsyncStatusDlg::OnCommandHelp(void)
  1296. {
  1297. AfxGetApp()->WinHelp(CAsyncStatusDlg::IDD + HID_BASE_RESOURCE);
  1298. return;
  1299. }
  1300. /*******************************************************************************
  1301. *
  1302. * OnStatusStart - CAsyncStatusDlg member function: command
  1303. *
  1304. * Process the WM_STATUSSTART message to initialize the 'static'
  1305. * PD-related fields.
  1306. *
  1307. * ENTRY:
  1308. *
  1309. * EXIT:
  1310. * (LRESULT) always returns 0 to indicate operation complete.
  1311. *
  1312. ******************************************************************************/
  1313. LRESULT
  1314. CAsyncStatusDlg::OnStatusStart( WPARAM wParam,
  1315. LPARAM lParam )
  1316. {
  1317. /*
  1318. * Fetch the PD-specific information from the CWStatusThread's PDCONFIG
  1319. * structure and initialize dialog fields.
  1320. */
  1321. SetDlgItemText( IDC_ASYNC_DEVICE,
  1322. m_pWSStatusThread->m_PdConfig.Params.Async.DeviceName );
  1323. SetDlgItemInt( IDC_ASYNC_BAUD,
  1324. m_pWSStatusThread->m_PdConfig.Params.Async.BaudRate,
  1325. FALSE );
  1326. /*
  1327. * Call / return our OnStatusReady() function.
  1328. */
  1329. return ( OnStatusReady( wParam, lParam ) );
  1330. } // end CAsyncStatusDlg::OnStatusStart
  1331. /*******************************************************************************
  1332. *
  1333. * OnStatusReady - CAsyncStatusDlg member function: command
  1334. *
  1335. * Process the WM_STATUSREADY message to update the dialog Info fields.
  1336. *
  1337. * ENTRY:
  1338. *
  1339. * EXIT:
  1340. * (LRESULT) always returns 0 to indicate operation complete.
  1341. *
  1342. ******************************************************************************/
  1343. LRESULT
  1344. CAsyncStatusDlg::OnStatusReady( WPARAM wParam,
  1345. LPARAM lParam )
  1346. {
  1347. /*
  1348. * If the LED toggle timer is still active now, kill it and flag so.
  1349. */
  1350. if ( m_LEDToggleTimer ) {
  1351. KillTimer(m_LEDToggleTimer);
  1352. m_LEDToggleTimer = 0;
  1353. }
  1354. /*
  1355. * Call / return the parent classes' OnStatusReady() function.
  1356. */
  1357. return (CStatusDlg::OnStatusReady( wParam, lParam ));
  1358. } // end CAsyncStatusDlg::OnStatusReady
  1359. /*******************************************************************************
  1360. *
  1361. * OnTimer - CAsyncStatusDlg member function: command (override)
  1362. *
  1363. * Used for quick 'LED toggle'.
  1364. *
  1365. * ENTRY:
  1366. * EXIT:
  1367. * (Refer to CWnd::OnTimer documentation)
  1368. *
  1369. ******************************************************************************/
  1370. void
  1371. CAsyncStatusDlg::OnTimer(UINT nIDEvent)
  1372. {
  1373. /*
  1374. * Process this timer event if it it our 'LED toggle' event.
  1375. */
  1376. if ( nIDEvent == m_LEDToggleTimer ) {
  1377. /*
  1378. * Toggle each led that is flagged as 'changed'.
  1379. */
  1380. if ( m_WSInfo.Status.AsyncSignalMask & EV_DTR )
  1381. ((CLed *)GetDlgItem(IDC_ASYNC_DTR))->Toggle();
  1382. if ( m_WSInfo.Status.AsyncSignalMask & EV_RTS )
  1383. ((CLed *)GetDlgItem(IDC_ASYNC_RTS))->Toggle();
  1384. if ( m_WSInfo.Status.AsyncSignalMask & EV_CTS )
  1385. ((CLed *)GetDlgItem(IDC_ASYNC_CTS))->Toggle();
  1386. if ( m_WSInfo.Status.AsyncSignalMask & EV_RLSD )
  1387. ((CLed *)GetDlgItem(IDC_ASYNC_DCD))->Toggle();
  1388. if ( m_WSInfo.Status.AsyncSignalMask & EV_DSR )
  1389. ((CLed *)GetDlgItem(IDC_ASYNC_DSR))->Toggle();
  1390. if ( m_WSInfo.Status.AsyncSignalMask & EV_RING )
  1391. ((CLed *)GetDlgItem(IDC_ASYNC_RI))->Toggle();
  1392. /*
  1393. * Kill this timer event and indicate so.
  1394. */
  1395. KillTimer(m_LEDToggleTimer);
  1396. m_LEDToggleTimer = 0;
  1397. } else
  1398. CDialog::OnTimer(nIDEvent);
  1399. } // end CAsyncStatusDlg::OnTimer
  1400. /*******************************************************************************
  1401. *
  1402. * OnNcDestroy - CAsyncStatusDlg member function: command
  1403. *
  1404. * Clean up before deleting dialog object.
  1405. *
  1406. * ENTRY:
  1407. * EXIT:
  1408. * (Refer to CWnd::OnNcDestroy documentation)
  1409. *
  1410. ******************************************************************************/
  1411. void
  1412. CAsyncStatusDlg::OnNcDestroy()
  1413. {
  1414. /*
  1415. * Delete the red brush we made.
  1416. */
  1417. DeleteObject(m_hRedBrush);
  1418. /*
  1419. * If the LED toggle timer is still active, kill it.
  1420. */
  1421. if ( m_LEDToggleTimer )
  1422. KillTimer(m_LEDToggleTimer);
  1423. /*
  1424. * Call parent after we've cleaned up.
  1425. */
  1426. CStatusDlg::OnNcDestroy();
  1427. } // end CAsyncStatusDlg::OnNcDestroy
  1428. /*******************************************************************************
  1429. *
  1430. * OnStatusAbort - CWSStatusDlg member function: command
  1431. *
  1432. * Process the WM_STATUSABORT message to exit the thread and dialog.
  1433. *
  1434. * ENTRY:
  1435. *
  1436. * EXIT:
  1437. * (LRESULT) always returns 0 to indicate operation complete.
  1438. *
  1439. ******************************************************************************/
  1440. LRESULT
  1441. CAsyncStatusDlg::OnStatusAbort( WPARAM wParam,
  1442. LPARAM lParam )
  1443. {
  1444. /*
  1445. * Call the OnCancel() member function to exit dialog and thread and
  1446. * perform proper cleanup.
  1447. */
  1448. OnCancel();
  1449. return(0);
  1450. } // end CWSStatusDlg::OnStatusAbort
  1451. void CAsyncStatusDlg::OnResetcounters()
  1452. {
  1453. // TODO: Add your control notification handler code here
  1454. m_bResetCounters = TRUE;
  1455. OnClickedRefreshnow();
  1456. }
  1457. void CAsyncStatusDlg::OnClickedRefreshnow()
  1458. {
  1459. // TODO: Add your control notification handler code here
  1460. /*
  1461. * Tell the status thread to wake up now.
  1462. */
  1463. m_pWSStatusThread->SignalWakeUp();
  1464. // return(0);
  1465. }
  1466. void CAsyncStatusDlg::OnMoreinfo()
  1467. {
  1468. // TODO: Add your control notification handler code here
  1469. CString ButtonText;
  1470. if(m_bWeAreLittle) {
  1471. // We are now little size: go to big size.
  1472. SetWindowPos(NULL, 0, 0, m_BigSize.cx, m_BigSize.cy,
  1473. SWP_NOMOVE | SWP_NOZORDER);
  1474. ButtonText.LoadString(IDS_LESSINFO);
  1475. SetDlgItemText(IDC_MOREINFO, ButtonText);
  1476. m_bWeAreLittle = FALSE;
  1477. } else {
  1478. // We are now big size: go to little size.
  1479. SetWindowPos( NULL, 0, 0, m_LittleSize.cx, m_LittleSize.cy,
  1480. SWP_NOMOVE | SWP_NOZORDER);
  1481. ButtonText.LoadString(IDS_MOREINFO);
  1482. SetDlgItemText(IDC_MOREINFO, ButtonText);
  1483. m_bWeAreLittle = TRUE;
  1484. }
  1485. }
  1486. /*******************************************************************************
  1487. *
  1488. * OnRefreshNow - CWSStatusDlg member function: command
  1489. *
  1490. * Processes in response to main frame's WM_STATUSREFRESHNOW notification
  1491. * that the user has changed the status refresh options.
  1492. *
  1493. * ENTRY:
  1494. *
  1495. * EXIT:
  1496. * (LRESULT) always returns 0 to indicate operation complete.
  1497. *
  1498. ******************************************************************************/
  1499. LRESULT
  1500. CAsyncStatusDlg::OnRefreshNow( WPARAM wParam,
  1501. LPARAM lParam )
  1502. {
  1503. /*
  1504. * Tell the status thread to wake up now.
  1505. */
  1506. m_pWSStatusThread->SignalWakeUp();
  1507. return(0);
  1508. } // end CWSStatusDlg::OnRefreshNow
  1509. BOOL CAsyncStatusDlg::OnHelpInfo(HELPINFO* pHelpInfo)
  1510. {
  1511. // TODO: Add your message handler code here and/or call default
  1512. //((CWinAdminApp*)AfxGetApp())->WinHelp(HID_BASE_CONTROL + pHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
  1513. if(pHelpInfo->iContextType == HELPINFO_WINDOW)
  1514. {
  1515. if(pHelpInfo->iCtrlId != IDC_STATIC)
  1516. {
  1517. ::WinHelp((HWND)pHelpInfo->hItemHandle,ID_HELP_FILE,HELP_WM_HELP,(ULONG_PTR)(LPVOID)aMenuHelpIDs);
  1518. }
  1519. }
  1520. return (TRUE);
  1521. }
  1522. /////////////////////////////////////////////////////////////////////////////
  1523. // CNetworkStatusDlg dialog
  1524. CNetworkStatusDlg::CNetworkStatusDlg(CWinStation *pWinStation, CWnd* pParent /*=NULL*/)
  1525. : CStatusDlg(pWinStation, CNetworkStatusDlg::IDD, pParent)
  1526. {
  1527. //{{AFX_DATA_INIT(CNetworkStatusDlg)
  1528. // NOTE: the ClassWizard will add member initialization here
  1529. //}}AFX_DATA_INIT
  1530. InitializeStatus();
  1531. VERIFY( CStatusDlg::Create(IDD_NETWORK_STATUS) );
  1532. }
  1533. void CNetworkStatusDlg::DoDataExchange(CDataExchange* pDX)
  1534. {
  1535. CDialog::DoDataExchange(pDX);
  1536. //{{AFX_DATA_MAP(CNetworkStatusDlg)
  1537. // NOTE: the ClassWizard will add DDX and DDV calls here
  1538. //}}AFX_DATA_MAP
  1539. }
  1540. BEGIN_MESSAGE_MAP(CNetworkStatusDlg, CDialog)
  1541. //{{AFX_MSG_MAP(CNetworkStatusDlg)
  1542. ON_MESSAGE(WM_STATUSSTART, OnStatusStart)
  1543. ON_MESSAGE(WM_STATUSREADY, OnStatusReady)
  1544. ON_MESSAGE(WM_STATUSABORT, OnStatusAbort)
  1545. ON_MESSAGE(WM_STATUSREFRESHNOW, OnRefreshNow)
  1546. ON_BN_CLICKED(IDC_RESETCOUNTERS, OnResetcounters)
  1547. ON_BN_CLICKED(IDC_REFRESHNOW, OnClickedRefreshnow)
  1548. ON_BN_CLICKED(IDC_MOREINFO, OnMoreinfo)
  1549. ON_WM_HELPINFO()
  1550. ON_COMMAND(ID_HELP,OnCommandHelp)
  1551. //}}AFX_MSG_MAP
  1552. END_MESSAGE_MAP()
  1553. /////////////////////////////////////////////////////////////////////////////
  1554. // CNetworkStatusDlg message handlers
  1555. /*******************************************************************************
  1556. *
  1557. * OnStatusStart - CNetworkStatusDlg member function: command
  1558. *
  1559. * Process the WM_STATUSSTART message to initialize the 'static'
  1560. * PD-related fields.
  1561. *
  1562. * ENTRY:
  1563. *
  1564. * EXIT:
  1565. * (LRESULT) always returns 0 to indicate operation complete.
  1566. *
  1567. ******************************************************************************/
  1568. LRESULT
  1569. CNetworkStatusDlg::OnStatusStart( WPARAM wParam,
  1570. LPARAM lParam )
  1571. {
  1572. DEVICENAME DeviceName;
  1573. PDCONFIG3 PdConfig3;
  1574. LONG Status;
  1575. ULONG ByteCount;
  1576. HANDLE hServer;
  1577. CWinAdminDoc *pDoc = (CWinAdminDoc*)((CWinAdminApp*)AfxGetApp())->GetDocument();
  1578. if(pDoc->IsInShutdown()) return 0;
  1579. if(m_pWinStation->GetSdClass() == SdOemTransport) {
  1580. CString LabelString;
  1581. LabelString.LoadString(IDS_DEVICE);
  1582. SetDlgItemText(IDC_LABEL, LabelString);
  1583. ULONG Length;
  1584. PDCONFIG PdConfig;
  1585. if(Status = WinStationQueryInformation(m_pWinStation->GetServer()->GetHandle(),
  1586. m_pWinStation->GetLogonId(),
  1587. WinStationPd,
  1588. &PdConfig,
  1589. sizeof(PDCONFIG),
  1590. &Length)) {
  1591. wcscpy(DeviceName, PdConfig.Params.OemTd.DeviceName);
  1592. }
  1593. } else {
  1594. /*
  1595. * Fetch the registry configuration for the PD specified in the
  1596. * CWStatusThread's PDCONFIG structure and initialize dialog fields.
  1597. */
  1598. hServer = RegOpenServer(m_pWinStation->GetServer()->IsCurrentServer() ? NULL : m_pWinStation->GetServer()->GetName());
  1599. PWDNAME pWdRegistryName = m_pWinStation->GetWdRegistryName();
  1600. if (!pWdRegistryName || (Status = RegPdQuery(hServer,
  1601. pWdRegistryName,
  1602. TRUE,
  1603. m_pWSStatusThread->m_PdConfig.Create.PdName,
  1604. &PdConfig3, sizeof(PDCONFIG3), &ByteCount)) ) {
  1605. // We don't currently look at the registry names on remote servers.
  1606. // If ICA is in use on the remote server and not on this server,
  1607. // we won't have a registry name - try "wdica" and "icawd"
  1608. if(m_pWinStation->IsICA()) {
  1609. if(Status = RegPdQuery(hServer,
  1610. TEXT("icawd"),
  1611. TRUE,
  1612. m_pWSStatusThread->m_PdConfig.Create.PdName,
  1613. &PdConfig3, sizeof(PDCONFIG3), &ByteCount) ) {
  1614. Status = RegPdQuery(hServer,
  1615. TEXT("wdica"),
  1616. TRUE,
  1617. m_pWSStatusThread->m_PdConfig.Create.PdName,
  1618. &PdConfig3, sizeof(PDCONFIG3), &ByteCount);
  1619. }
  1620. }
  1621. if(Status) memset(&PdConfig3, 0, sizeof(PDCONFIG3));
  1622. }
  1623. ULONG Length = 0;
  1624. PWSTR pLanAdapter = NULL;
  1625. //
  1626. // Try the new interface first (NT5 server ?)
  1627. //
  1628. if (WinStationGetLanAdapterName(m_pWinStation->GetServer()->GetHandle(),
  1629. m_pWSStatusThread->m_PdConfig.Params.Network.LanAdapter,
  1630. (lstrlen(m_pWSStatusThread->m_PdConfig.Create.PdName) + 1) * sizeof(WCHAR),
  1631. m_pWSStatusThread->m_PdConfig.Create.PdName,
  1632. &Length,
  1633. &pLanAdapter))
  1634. {
  1635. //NT5 Server
  1636. SetDlgItemText( IDC_NETWORK_LANADAPTER, pLanAdapter );
  1637. if(pLanAdapter)
  1638. {
  1639. WinStationFreeMemory(pLanAdapter);
  1640. }
  1641. }
  1642. else
  1643. {
  1644. //
  1645. // Check the return code indicating that the interface is not available.
  1646. //
  1647. DWORD dwError = GetLastError();
  1648. if (dwError != RPC_S_PROCNUM_OUT_OF_RANGE)
  1649. {
  1650. //Error getting Name.
  1651. SetDlgItemText( IDC_NETWORK_LANADAPTER, GetUnknownString());
  1652. }
  1653. else // maybe a Hydra 4 server ?
  1654. {
  1655. if (RegGetNetworkDeviceName(hServer, &PdConfig3, &(m_pWSStatusThread->m_PdConfig.Params),
  1656. DeviceName, DEVICENAME_LENGTH +1 ) == ERROR_SUCCESS)
  1657. {
  1658. SetDlgItemText( IDC_NETWORK_LANADAPTER, DeviceName );
  1659. }
  1660. else
  1661. {
  1662. //Error
  1663. SetDlgItemText( IDC_NETWORK_LANADAPTER, GetUnknownString());
  1664. }
  1665. }
  1666. }
  1667. RegCloseServer(hServer);
  1668. }
  1669. /*
  1670. * Call / return parent classes' OnStatusStart().
  1671. */
  1672. return ( CStatusDlg::OnStatusStart( wParam, lParam ) );
  1673. } // end CNetworkStatusDlg::OnStatusStart
  1674. void CNetworkStatusDlg::OnResetcounters()
  1675. {
  1676. // TODO: Add your control notification handler code here
  1677. m_bResetCounters = TRUE;
  1678. OnClickedRefreshnow();
  1679. }
  1680. void CNetworkStatusDlg::OnClickedRefreshnow()
  1681. {
  1682. // TODO: Add your control notification handler code here
  1683. /*
  1684. * Tell the status thread to wake up now.
  1685. */
  1686. m_pWSStatusThread->SignalWakeUp();
  1687. // return(0);
  1688. }
  1689. void CNetworkStatusDlg::OnMoreinfo()
  1690. {
  1691. // TODO: Add your control notification handler code here
  1692. }
  1693. void CNetworkStatusDlg::OnCommandHelp(void)
  1694. {
  1695. AfxGetApp()->WinHelp(CNetworkStatusDlg::IDD + HID_BASE_RESOURCE);
  1696. return;
  1697. }
  1698. /*******************************************************************************
  1699. *
  1700. * OnRefreshNow - CWSStatusDlg member function: command
  1701. *
  1702. * Processes in response to main frame's WM_STATUSREFRESHNOW notification
  1703. * that the user has changed the status refresh options.
  1704. *
  1705. * ENTRY:
  1706. *
  1707. * EXIT:
  1708. * (LRESULT) always returns 0 to indicate operation complete.
  1709. *
  1710. ******************************************************************************/
  1711. LRESULT
  1712. CNetworkStatusDlg::OnRefreshNow( WPARAM wParam,
  1713. LPARAM lParam )
  1714. {
  1715. /*
  1716. * Tell the status thread to wake up now.
  1717. */
  1718. m_pWSStatusThread->SignalWakeUp();
  1719. return(0);
  1720. } // end CWSStatusDlg::OnRefreshNow
  1721. /*******************************************************************************
  1722. *
  1723. * OnStatusReady - CWSStatusDlg member function: command
  1724. *
  1725. * Process the WM_STATUSREADY message to update the dialog Info fields.
  1726. *
  1727. * NOTE: the derived class must override this function to call it's
  1728. * override of the SetInfoFields function, which could then call / return
  1729. * this function or completely override all functionality contained here.
  1730. *
  1731. * ENTRY:
  1732. *
  1733. * EXIT:
  1734. * (LRESULT) always returns 0 to indicate operation complete.
  1735. *
  1736. ******************************************************************************/
  1737. LRESULT
  1738. CNetworkStatusDlg::OnStatusReady( WPARAM wParam,
  1739. LPARAM lParam )
  1740. {
  1741. /*
  1742. * Update dialog fields with information from the CWStatusThread's
  1743. * WINSTATIONINFORMATION structure.
  1744. */
  1745. SetInfoFields( &m_WSInfo, &(m_pWSStatusThread->m_WSInfo) );
  1746. /*
  1747. * Set our working WSInfo structure to the new one and signal the thread
  1748. * that we're done.
  1749. */
  1750. m_WSInfo = m_pWSStatusThread->m_WSInfo;
  1751. m_pWSStatusThread->SignalConsumed();
  1752. return(0);
  1753. } // end CWSStatusDlg::OnStatusReady
  1754. /*******************************************************************************
  1755. *
  1756. * OnStatusAbort - CWSStatusDlg member function: command
  1757. *
  1758. * Process the WM_STATUSABORT message to exit the thread and dialog.
  1759. *
  1760. * ENTRY:
  1761. *
  1762. * EXIT:
  1763. * (LRESULT) always returns 0 to indicate operation complete.
  1764. *
  1765. ******************************************************************************/
  1766. LRESULT
  1767. CNetworkStatusDlg::OnStatusAbort( WPARAM wParam,
  1768. LPARAM lParam )
  1769. {
  1770. /*
  1771. * Call the OnCancel() member function to exit dialog and thread and
  1772. * perform proper cleanup.
  1773. */
  1774. OnCancel();
  1775. return(0);
  1776. } // end CWSStatusDlg::OnStatusAbort
  1777. BOOL CNetworkStatusDlg::OnHelpInfo(HELPINFO* pHelpInfo)
  1778. {
  1779. // TODO: Add your message handler code here and/or call default
  1780. //((CWinAdminApp*)AfxGetApp())->WinHelp(HID_BASE_CONTROL + pHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
  1781. if(pHelpInfo->iContextType == HELPINFO_WINDOW)
  1782. {
  1783. if(pHelpInfo->iCtrlId != IDC_STATIC)
  1784. {
  1785. ::WinHelp((HWND)pHelpInfo->hItemHandle,ID_HELP_FILE,HELP_WM_HELP,(ULONG_PTR)(LPVOID)aMenuHelpIDs);
  1786. }
  1787. }
  1788. return (TRUE);
  1789. }
  1790. ////////////////////////////////////////////////////////////////////////////////
  1791. CMyDialog::CMyDialog(CWnd* pParent /*=NULL*/)
  1792. : CDialog(CMyDialog::IDD, pParent)
  1793. {
  1794. //{{AFX_DATA_INIT(CMyDialog)
  1795. m_cstrServerName = _T("");
  1796. //}}AFX_DATA_INIT
  1797. }
  1798. void CMyDialog::DoDataExchange(CDataExchange* pDX)
  1799. {
  1800. CDialog::DoDataExchange(pDX);
  1801. //{{AFX_DATA_MAP(CMyDialog)
  1802. DDX_Text(pDX, IDC_EDIT_FINDSERVER, m_cstrServerName);
  1803. DDV_MaxChars(pDX, m_cstrServerName, 256);
  1804. //}}AFX_DATA_MAP
  1805. }
  1806. BEGIN_MESSAGE_MAP(CMyDialog, CDialog)
  1807. //{{AFX_MSG_MAP(CMyDialog)
  1808. // NOTE: the ClassWizard will add message map macros here
  1809. //}}AFX_MSG_MAP
  1810. END_MESSAGE_MAP()