Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

206 lines
6.8 KiB

  1. //
  2. // proprun.cpp: local resources property sheet dialog proc
  3. //
  4. // Tab D
  5. //
  6. // Copyright Microsoft Corporation 2000
  7. // nadima
  8. #include "stdafx.h"
  9. #define TRC_GROUP TRC_GROUP_UI
  10. #define TRC_FILE "proprun"
  11. #include <atrcapi.h>
  12. #include "sh.h"
  13. #include "commctrl.h"
  14. #include "proprun.h"
  15. CPropRun* CPropRun::_pPropRunInstance = NULL;
  16. //
  17. // Controls that need to be disabled/enabled
  18. // during connection (for progress animation)
  19. //
  20. CTL_ENABLE connectingDisableCtlsPRun[] = {
  21. {IDC_CHECK_START_PROGRAM, FALSE},
  22. {IDC_EDIT_STARTPROGRAM, FALSE},
  23. {IDC_EDIT_WORKDIR, FALSE},
  24. {IDC_STATIC_STARTPROGRAM, FALSE},
  25. {IDC_STATIC_WORKDIR, FALSE},
  26. };
  27. const UINT numConnectingDisableCtlsPRun =
  28. sizeof(connectingDisableCtlsPRun)/
  29. sizeof(connectingDisableCtlsPRun[0]);
  30. CPropRun::CPropRun(HINSTANCE hInstance, CTscSettings* pTscSet, CSH* pSh)
  31. {
  32. DC_BEGIN_FN("CPropRun");
  33. _hInstance = hInstance;
  34. CPropRun::_pPropRunInstance = this;
  35. _pTscSet = pTscSet;
  36. _pSh = pSh;
  37. TRC_ASSERT(_pTscSet,(TB,_T("_pTscSet is null")));
  38. TRC_ASSERT(_pSh,(TB,_T("pSh is null")));
  39. DC_END_FN();
  40. }
  41. CPropRun::~CPropRun()
  42. {
  43. CPropRun::_pPropRunInstance = NULL;
  44. }
  45. INT_PTR CALLBACK CPropRun::StaticPropPgRunDialogProc(HWND hwndDlg,
  46. UINT uMsg,
  47. WPARAM wParam,
  48. LPARAM lParam)
  49. {
  50. //
  51. // Delegate to appropriate instance (only works for single instance dialogs)
  52. //
  53. DC_BEGIN_FN("StaticDialogBoxProc");
  54. DCINT retVal = 0;
  55. TRC_ASSERT(_pPropRunInstance, (TB, _T("run dialog has NULL static instance ptr\n")));
  56. retVal = _pPropRunInstance->PropPgRunDialogProc( hwndDlg,
  57. uMsg,
  58. wParam,
  59. lParam);
  60. DC_END_FN();
  61. return retVal;
  62. }
  63. INT_PTR CALLBACK CPropRun::PropPgRunDialogProc (HWND hwndDlg,
  64. UINT uMsg,
  65. WPARAM wParam,
  66. LPARAM lParam)
  67. {
  68. DC_BEGIN_FN("PropPgRunDialogProc");
  69. switch(uMsg)
  70. {
  71. case WM_INITDIALOG:
  72. {
  73. #ifndef OS_WINCE
  74. int i;
  75. #endif
  76. //
  77. // Position the dialog within the tab
  78. //
  79. SetWindowPos( hwndDlg, HWND_TOP,
  80. _rcTabDispayArea.left, _rcTabDispayArea.top,
  81. _rcTabDispayArea.right - _rcTabDispayArea.left,
  82. _rcTabDispayArea.bottom - _rcTabDispayArea.top,
  83. 0);
  84. //
  85. // Get settings
  86. //
  87. SetDlgItemText(hwndDlg, IDC_EDIT_STARTPROGRAM,
  88. (LPCTSTR) _pTscSet->GetStartProgram());
  89. SetDlgItemText(hwndDlg, IDC_EDIT_WORKDIR,
  90. (LPCTSTR) _pTscSet->GetWorkDir());
  91. CheckDlgButton(hwndDlg, IDC_CHECK_START_PROGRAM,
  92. _pTscSet->GetEnableStartProgram() ?
  93. BST_CHECKED : BST_UNCHECKED);
  94. EnableWindow(GetDlgItem(hwndDlg,
  95. IDC_EDIT_STARTPROGRAM),
  96. _pTscSet->GetEnableStartProgram());
  97. EnableWindow(GetDlgItem(hwndDlg,
  98. IDC_EDIT_WORKDIR),
  99. _pTscSet->GetEnableStartProgram());
  100. EnableWindow(GetDlgItem(hwndDlg,
  101. IDC_STATIC_STARTPROGRAM),
  102. _pTscSet->GetEnableStartProgram());
  103. EnableWindow(GetDlgItem(hwndDlg,
  104. IDC_STATIC_WORKDIR),
  105. _pTscSet->GetEnableStartProgram());
  106. _pSh->SH_ThemeDialogWindow(hwndDlg, ETDT_ENABLETAB);
  107. return TRUE;
  108. }
  109. break; //WM_INITDIALOG
  110. case WM_TSC_ENABLECONTROLS:
  111. {
  112. //
  113. // wParam is TRUE to enable controls,
  114. // FALSE to disable them
  115. //
  116. CSH::EnableControls( hwndDlg,
  117. connectingDisableCtlsPRun,
  118. numConnectingDisableCtlsPRun,
  119. wParam ? TRUE : FALSE);
  120. }
  121. break;
  122. case WM_SAVEPROPSHEET: //Intentional fallthru
  123. case WM_DESTROY:
  124. {
  125. //
  126. // Save page settings
  127. //
  128. BOOL fStartProgEnabled = IsDlgButtonChecked(hwndDlg,
  129. IDC_CHECK_START_PROGRAM);
  130. _pTscSet->SetEnableStartProgram(fStartProgEnabled);
  131. TCHAR szStartProg[MAX_PATH];
  132. TCHAR szWorkDir[MAX_PATH];
  133. GetDlgItemText(hwndDlg,
  134. IDC_EDIT_STARTPROGRAM,
  135. szStartProg,
  136. SIZECHAR(szStartProg));
  137. GetDlgItemText(hwndDlg,
  138. IDC_EDIT_WORKDIR,
  139. szWorkDir,
  140. SIZECHAR(szWorkDir));
  141. _pTscSet->SetStartProgram(szStartProg);
  142. _pTscSet->SetWorkDir(szWorkDir);
  143. }
  144. break; //WM_DESTROY
  145. case WM_COMMAND:
  146. {
  147. if(BN_CLICKED == HIWORD(wParam) &&
  148. IDC_CHECK_START_PROGRAM == (int)LOWORD(wParam))
  149. {
  150. BOOL fStartProgEnabled = IsDlgButtonChecked(hwndDlg,
  151. IDC_CHECK_START_PROGRAM);
  152. EnableWindow(GetDlgItem(hwndDlg,
  153. IDC_EDIT_STARTPROGRAM),
  154. fStartProgEnabled);
  155. EnableWindow(GetDlgItem(hwndDlg,
  156. IDC_EDIT_WORKDIR),
  157. fStartProgEnabled);
  158. EnableWindow(GetDlgItem(hwndDlg,
  159. IDC_STATIC_STARTPROGRAM),
  160. fStartProgEnabled);
  161. EnableWindow(GetDlgItem(hwndDlg,
  162. IDC_STATIC_WORKDIR),
  163. fStartProgEnabled);
  164. _pTscSet->SetEnableStartProgram(fStartProgEnabled);
  165. }
  166. }
  167. break;
  168. }
  169. DC_END_FN();
  170. return 0;
  171. }