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.

288 lines
8.3 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. dcomputer.cpp
  5. Abstract:
  6. This file contains implementation of
  7. the computer selection dialog.
  8. Environment:
  9. WIN32 User Mode
  10. Author:
  11. Darwin Ouyang (t-darouy) 30-Sept-1997
  12. --*/
  13. #include "stdafx.h"
  14. #include "dcomputer.h"
  15. #include "iroot.h"
  16. #pragma hdrstop
  17. ////////////////////////////////////////////////////////////////////////////////////////////////////
  18. ////////////////////////////////////////////////////////////////////////////////////////////////////
  19. ////////////////////////////////////////////////////////////////////////////////////////////////////
  20. ////////////////////////////////////////////////////////////////////////////////////////////////////
  21. //
  22. //
  23. // Constructor and destructor
  24. //
  25. //
  26. CFaxSelectComputerPropSheet::CFaxSelectComputerPropSheet(
  27. IN HINSTANCE hInstance,
  28. IN LONG_PTR hMmcNotify,
  29. IN CInternalRoot * glob )
  30. : _fFirstActive( TRUE ),
  31. _hMmcNotify( hMmcNotify ),
  32. _globalRoot( glob )
  33. /*++
  34. Routine Description:
  35. Constructor
  36. Arguments:
  37. hInstance - the instance pointer
  38. hMmcNotify - the MMC notify handle
  39. glob - a pointer to the owning node
  40. Return Value:
  41. None.
  42. --*/
  43. {
  44. DebugPrint(( TEXT("CFaxSelectComputerPropSheet Created") ));
  45. _PropSheet.dwSize = sizeof( *this );
  46. _PropSheet.dwFlags = PSP_USETITLE;
  47. _PropSheet.hInstance = hInstance;
  48. _PropSheet.pszTemplate = MAKEINTRESOURCE(IDP_IS_PAGE0);
  49. _PropSheet.pszTitle = MAKEINTRESOURCE(IDP_IS_PAGE0_TITLE);
  50. _PropSheet.pfnDlgProc = CFaxSelectComputerPropSheet::DlgProc;
  51. _PropSheet.lParam = (LONG_PTR)this;
  52. _hPropSheet = NULL;
  53. _hPropSheet = CreatePropertySheetPage( &_PropSheet );
  54. assert(_hPropSheet != NULL );
  55. }
  56. CFaxSelectComputerPropSheet::~CFaxSelectComputerPropSheet()
  57. /*++
  58. Routine Description:
  59. Destructor
  60. Arguments:
  61. None.
  62. Return Value:
  63. None.
  64. --*/
  65. {
  66. DebugPrint(( TEXT("CFaxSelectComputerPropSheet Destroyed") ));
  67. }
  68. ////////////////////////////////////////////////////////////////////////////////////////////////////
  69. ////////////////////////////////////////////////////////////////////////////////////////////////////
  70. ////////////////////////////////////////////////////////////////////////////////////////////////////
  71. ////////////////////////////////////////////////////////////////////////////////////////////////////
  72. //
  73. //
  74. // Dialog Proc
  75. //
  76. //
  77. INT_PTR
  78. APIENTRY
  79. CFaxSelectComputerPropSheet::DlgProc( IN HWND hwndDlg,
  80. IN UINT message,
  81. IN WPARAM wParam,
  82. IN LPARAM lParam )
  83. /*++
  84. Routine Description:
  85. Dialog Procedure
  86. Arguments:
  87. hwndDlg - the hwnd of the dialog
  88. message - the message
  89. wParam, lParam - the window message parameters
  90. Return Value:
  91. BOOL
  92. --*/
  93. {
  94. // DebugPrint(( TEXT("Trace: CFaxSelectComputerPropSheet::DlgProc") ));
  95. BOOL fRet = FALSE;
  96. switch( message ) {
  97. case WM_INITDIALOG:
  98. {
  99. DebugPrint(( TEXT("CFaxSelectComputerPropSheet::DlgProc -- WM_INITDIALOG\n") ));
  100. LPARAM lthis = ((CFaxSelectComputerPropSheet *)lParam)->_PropSheet.lParam;
  101. CFaxSelectComputerPropSheet * pthis = (CFaxSelectComputerPropSheet *)lthis;
  102. SetWindowLongPtr( hwndDlg, DWLP_USER, lthis );
  103. //
  104. // Default to local machine.
  105. //
  106. CheckRadioButton( hwndDlg,
  107. IDDI_LOCAL_COMPUTER,
  108. IDDI_REMOTE_COMPUTER,
  109. IDDI_LOCAL_COMPUTER );
  110. EnableWindow( GetDlgItem( hwndDlg, IDDI_COMPNAME ), FALSE );
  111. fRet = TRUE;
  112. break;
  113. }
  114. case WM_COMMAND:
  115. {
  116. DebugPrint(( TEXT("CFaxSelectComputerPropSheet::DlgProc -- WM_COMMAND\n") ));
  117. switch( LOWORD( wParam ) ) {
  118. case IDDI_LOCAL_COMPUTER:
  119. {
  120. if( BN_CLICKED == HIWORD(wParam) ) {
  121. EnableWindow( GetDlgItem( hwndDlg, IDDI_COMPNAME ), FALSE );
  122. fRet = TRUE;
  123. }
  124. break;
  125. }
  126. case IDDI_REMOTE_COMPUTER:
  127. {
  128. if( BN_CLICKED == HIWORD(wParam) ) {
  129. EnableWindow( GetDlgItem( hwndDlg, IDDI_COMPNAME ), TRUE );
  130. fRet = TRUE;
  131. }
  132. break;
  133. }
  134. } // switch
  135. break;
  136. }
  137. case WM_NOTIFY:
  138. {
  139. DebugPrint(( TEXT("CFaxSelectComputerPropSheet::DlgProc -- WM_NOTIFY\n") ));
  140. CFaxSelectComputerPropSheet * pthis =
  141. (CFaxSelectComputerPropSheet *)GetWindowLongPtr( hwndDlg,
  142. DWLP_USER );
  143. switch( ((LPNMHDR) lParam)->code ) {
  144. case PSN_KILLACTIVE:
  145. {
  146. // Allow loss of activation
  147. SetWindowLongPtr( hwndDlg, DWLP_MSGRESULT, FALSE );
  148. fRet = TRUE;
  149. break;
  150. }
  151. case PSN_SETACTIVE:
  152. {
  153. if( pthis->_fFirstActive ) {
  154. PropSheet_SetWizButtons( GetParent(hwndDlg), PSWIZB_FINISH );
  155. pthis->_fFirstActive = FALSE;
  156. } else {
  157. // Go to next page
  158. SetWindowLongPtr( hwndDlg, DWLP_MSGRESULT, -1 );
  159. }
  160. fRet = TRUE;
  161. break;
  162. }
  163. case PSN_WIZBACK:
  164. {
  165. // Allow previous page
  166. SetWindowLongPtr( hwndDlg,
  167. DWLP_MSGRESULT,
  168. PSNRET_NOERROR );
  169. fRet = TRUE;
  170. break;
  171. }
  172. case PSN_WIZNEXT:
  173. {
  174. // Allow next page
  175. SetWindowLongPtr( hwndDlg,
  176. DWLP_MSGRESULT,
  177. PSNRET_NOERROR );
  178. fRet = TRUE;
  179. break;
  180. }
  181. case PSN_WIZFINISH:
  182. {
  183. TCHAR wcCompName[MAX_COMPUTERNAME_LENGTH+1];
  184. if( IsDlgButtonChecked( hwndDlg, IDDI_LOCAL_COMPUTER ) ) {
  185. pthis->_globalRoot->SetMachine( NULL );
  186. } else {
  187. if( GetDlgItemText( hwndDlg, IDDI_COMPNAME, wcCompName, MAX_COMPUTERNAME_LENGTH ) ) {
  188. pthis->_globalRoot->SetMachine( (TCHAR *)&wcCompName );
  189. }
  190. }
  191. MMCPropertyChangeNotify( pthis->_hMmcNotify, 0 );
  192. fRet = TRUE;
  193. break;
  194. }
  195. } // switch
  196. break;
  197. }
  198. case WM_DESTROY:
  199. {
  200. DebugPrint(( TEXT("CFaxSelectComputerPropSheet::DlgProc -- WM_DESTROY\n") ));
  201. CFaxSelectComputerPropSheet * pthis =
  202. (CFaxSelectComputerPropSheet *)GetWindowLongPtr( hwndDlg,
  203. DWLP_USER );
  204. MMCFreeNotifyHandle( pthis->_hMmcNotify );
  205. delete pthis;
  206. fRet = TRUE;
  207. break;
  208. }
  209. } // switch
  210. return fRet;
  211. }