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.

2987 lines
80 KiB

  1. //Copyright (c) 1998 - 1999 Microsoft Corporation
  2. #include "stdafx.h"
  3. #include "tscc.h"
  4. #include "tscfgex.h"
  5. #include "compdata.h"
  6. #include "resource.h"
  7. #include "winsta.h"
  8. #include "commctrl.h"
  9. //#include "asyncdlg.h"
  10. static USERCONFIG g_uc;
  11. static ASYNCCONFIG g_ac;
  12. static WS g_ws;
  13. static TCHAR tchThirdPartyPath[] = TEXT("Software\\Microsoft\\Tscc\\");
  14. void EnableGroup( HWND hParent , LPINT rgID , BOOL bEnable );
  15. static int g_nAsyncOrNetwork;
  16. extern void ErrMessage( HWND hwndOwner , INT_PTR iResourceID );
  17. extern void TscAccessDeniedMsg( HWND hwnd );
  18. extern void TscGeneralErrMsg( HWND hwnd );
  19. extern BOOL IsValidConnectionName( LPTSTR szConName , PDWORD );
  20. static BOOL g_bConnectionTypeChanged_forEncryption = FALSE;
  21. static BOOL g_bConnectionTypeChanged_forConProps = FALSE;
  22. LPEXTENDTSWIZARD g_pObj;
  23. //-----------------------------------------------------------------------------
  24. BOOL CDialogWizBase::OnNotify( int idCtrl , LPNMHDR pnmh , HWND hDlg )
  25. {
  26. UNREFERENCED_PARAMETER( idCtrl );
  27. if( pnmh->code == PSN_SETACTIVE )
  28. {
  29. PropSheet_SetWizButtons( GetParent( hDlg ) , PSWIZB_NEXT | PSWIZB_BACK );
  30. }
  31. return TRUE;
  32. }
  33. //***********************************************************************************
  34. // Welcome Dialog
  35. //-----------------------------------------------------------------------------
  36. BOOL CWelcome::OnInitDialog( HWND hwnd , WPARAM wp , LPARAM lp )
  37. {
  38. UNREFERENCED_PARAMETER( wp );
  39. UNREFERENCED_PARAMETER( lp );
  40. ODS( L"TSCC-WIZ welcome\n" );
  41. LOGFONT lgfn;
  42. int iFontSize;
  43. TCHAR szFontSize[16];
  44. ZeroMemory( &lgfn , sizeof( LOGFONT ) );
  45. LoadString( _Module.GetResourceInstance( ) , IDS_VERDANABLDFONTSIZE , szFontSize , SIZE_OF_BUFFER(szFontSize) );
  46. iFontSize = _ttoi( szFontSize );
  47. HDC hdc = ::GetDC( NULL );
  48. if( hdc != NULL )
  49. {
  50. lgfn.lfHeight = MulDiv( -iFontSize , GetDeviceCaps(hdc , LOGPIXELSY), 72);
  51. LoadString( _Module.GetResourceInstance( ) , IDS_VERDANABLDFONTNAME , lgfn.lfFaceName , SIZE_OF_BUFFER(lgfn.lfFaceName) );
  52. m_hFont = CreateFontIndirect( &lgfn );
  53. ASSERT( m_hFont != NULL ); // let me know if we got it or not
  54. SendMessage( GetDlgItem( hwnd , IDC_STATIC_WELCOME ) , WM_SETFONT , ( WPARAM )m_hFont , MAKELPARAM( TRUE , 0 ) );
  55. g_nAsyncOrNetwork = 0;
  56. ReleaseDC( NULL , hdc );
  57. }
  58. return FALSE;
  59. }
  60. //-----------------------------------------------------------------------------
  61. INT_PTR CALLBACK CWelcome::DlgProc( HWND hwnd , UINT msg , WPARAM wp , LPARAM lp )
  62. {
  63. CWelcome *pDlg;
  64. if( msg == WM_INITDIALOG )
  65. {
  66. CWelcome *pDlg = ( CWelcome * )( ( PROPSHEETPAGE *)lp )->lParam ;
  67. //
  68. // Don't use a static pointer here
  69. // There will be concurrency issues
  70. //
  71. SetWindowLongPtr( hwnd , DWLP_USER , ( LONG_PTR )pDlg );
  72. if( !IsBadReadPtr( pDlg , sizeof( CWelcome ) ) )
  73. {
  74. pDlg->OnInitDialog( hwnd , wp , lp );
  75. }
  76. return 0;
  77. }
  78. else
  79. {
  80. pDlg = ( CWelcome * )GetWindowLongPtr( hwnd , DWLP_USER );
  81. if( IsBadReadPtr( pDlg , sizeof( CWelcome ) ) )
  82. {
  83. return FALSE;
  84. }
  85. }
  86. switch( msg )
  87. {
  88. case WM_DESTROY:
  89. pDlg->OnDestroy( );
  90. break;
  91. case WM_NOTIFY:
  92. pDlg->OnNotify( ( int )wp , ( LPNMHDR )lp , hwnd );
  93. break;
  94. }
  95. return FALSE;
  96. }
  97. //-----------------------------------------------------------------------------
  98. BOOL CWelcome::OnDestroy( )
  99. {
  100. DeleteObject( m_hFont );
  101. return CDialogWizBase::OnDestroy( );
  102. }
  103. //-----------------------------------------------------------------------------
  104. BOOL CWelcome::GetPropertySheetPage( PROPSHEETPAGE& psp)
  105. {
  106. ZeroMemory( &psp , sizeof( PROPSHEETPAGE ) );
  107. psp.dwSize = sizeof( PROPSHEETPAGE );
  108. psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER | PSP_USETITLE ;
  109. psp.pszTitle = MAKEINTRESOURCE( IDS_WIZARDTITLE );
  110. psp.hInstance = _Module.GetResourceInstance( );
  111. psp.pszTemplate = MAKEINTRESOURCE( IDD_WELCOME );
  112. psp.lParam = ( LPARAM )this;
  113. psp.pfnDlgProc = CWelcome::DlgProc;
  114. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_WELCOMEHEADER );
  115. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_WELCOMESUBHEADER );
  116. return TRUE;
  117. }
  118. //-----------------------------------------------------------------------------
  119. BOOL CWelcome::OnNotify( int idCtrl , LPNMHDR pnmh , HWND hDlg )
  120. {
  121. UNREFERENCED_PARAMETER( idCtrl );
  122. if( pnmh->code == PSN_SETACTIVE )
  123. {
  124. PropSheet_SetWizButtons( GetParent( hDlg ) , PSWIZB_NEXT );
  125. }
  126. return TRUE;
  127. }
  128. //***********************************************************************************
  129. // Connection Type Dialog
  130. // Determines the path the wizard will take in configuring the connection
  131. //-----------------------------------------------------------------------------
  132. CConType::CConType( CCompdata *pCompdata )
  133. {
  134. m_pCompdata = pCompdata;
  135. m_iOldSelection = -1;
  136. }
  137. //-----------------------------------------------------------------------------
  138. INT_PTR CALLBACK CConType::DlgProc( HWND hwnd , UINT msg , WPARAM wp , LPARAM lp )
  139. {
  140. CConType *pDlg;
  141. if( msg == WM_INITDIALOG )
  142. {
  143. CConType *pDlg = ( CConType * )( ( PROPSHEETPAGE *)lp )->lParam ;
  144. //
  145. // Don't use a static pointer here
  146. // There will be concurrency issues
  147. //
  148. SetWindowLongPtr( hwnd , DWLP_USER , ( LONG_PTR )pDlg );
  149. if( !IsBadReadPtr( pDlg , sizeof( CConType ) ) )
  150. {
  151. pDlg->OnInitDialog( hwnd , wp , lp );
  152. }
  153. return 0;
  154. }
  155. else
  156. {
  157. pDlg = ( CConType * )GetWindowLongPtr( hwnd , DWLP_USER );
  158. if( IsBadReadPtr( pDlg , sizeof( CConType ) ) )
  159. {
  160. return FALSE;
  161. }
  162. }
  163. switch( msg )
  164. {
  165. case WM_DESTROY:
  166. pDlg->OnDestroy( );
  167. break;
  168. case WM_NOTIFY:
  169. pDlg->OnNotify( ( int )wp , ( LPNMHDR )lp , hwnd );
  170. break;
  171. }
  172. return FALSE;
  173. }
  174. //-----------------------------------------------------------------------------
  175. BOOL CConType::OnInitDialog( HWND hwnd , WPARAM wp , LPARAM lp )
  176. {
  177. UNREFERENCED_PARAMETER( wp );
  178. UNREFERENCED_PARAMETER( lp );
  179. //
  180. // Obtain a list of entries for the contype
  181. // if not RDP remove the last two entries on the list
  182. AddEntriesToConType( hwnd );
  183. return FALSE;
  184. }
  185. //-----------------------------------------------------------------------------
  186. BOOL CConType::OnNotify( int idCtrl, LPNMHDR pnmh , HWND hDlg )
  187. {
  188. if( pnmh->code == PSN_WIZNEXT )
  189. {
  190. SetConType( hDlg );
  191. }
  192. return CDialogWizBase::OnNotify( idCtrl , pnmh , hDlg );
  193. }
  194. //-----------------------------------------------------------------------------
  195. // Place entries in connection type combx
  196. //-----------------------------------------------------------------------------
  197. BOOL CConType::AddEntriesToConType( HWND hDlg )
  198. {
  199. HWND hCtrl = GetDlgItem( hDlg , IDC_COMBO_WIZ_CONTYPE );
  200. ICfgComp *pCfgcomp = NULL;
  201. ULONG cbSize = 0;
  202. ULONG ulItems = 0;
  203. WDNAMEW *wszWdname = NULL;
  204. BOOL ret = FALSE;
  205. if( !IsWindow( hCtrl ) )
  206. {
  207. return ret;
  208. }
  209. if( m_pCompdata->GetServer( &pCfgcomp ) == 0 )
  210. {
  211. return ret;
  212. }
  213. if( SUCCEEDED( pCfgcomp->GetWdTypeList( &ulItems , &cbSize , ( WCHAR ** )&wszWdname ) ) )
  214. {
  215. for( ULONG i = 0; i < ulItems ; i++ )
  216. {
  217. SendMessage( hCtrl , CB_ADDSTRING , 0 , ( LPARAM )&wszWdname[ i ] );
  218. }
  219. CoTaskMemFree( wszWdname );
  220. SendMessage( hCtrl , CB_SETCURSEL , 0 , 0 );
  221. ret = TRUE;
  222. }
  223. else
  224. {
  225. ODS( L"GetWdTypeList -- failed\n" );
  226. ret = FALSE;
  227. }
  228. pCfgcomp->Release( );
  229. return ret;
  230. }
  231. //-----------------------------------------------------------------------------
  232. BOOL CConType::SetConType( HWND hwnd )
  233. {
  234. // PROPSHEETPAGE psp;
  235. TCHAR tchWdName[ WDNAME_LENGTH + 1 ];
  236. INT_PTR idx = SendMessage( GetDlgItem( hwnd , IDC_COMBO_WIZ_CONTYPE ) , CB_GETCURSEL , 0 , 0 );
  237. if( idx == CB_ERR )
  238. {
  239. return FALSE;
  240. }
  241. if( idx != m_iOldSelection )
  242. {
  243. g_bConnectionTypeChanged_forEncryption = TRUE;
  244. g_bConnectionTypeChanged_forConProps = TRUE;
  245. m_iOldSelection = (INT)idx;
  246. }
  247. SendMessage( GetDlgItem( hwnd , IDC_COMBO_WIZ_CONTYPE ) , CB_GETLBTEXT , idx , ( LPARAM )tchWdName );
  248. lstrcpy( g_ws.wdName , tchWdName );
  249. return TRUE;
  250. }
  251. //-----------------------------------------------------------------------------
  252. BOOL CConType::GetPropertySheetPage( PROPSHEETPAGE& psp)
  253. {
  254. ZeroMemory( &psp , sizeof( PROPSHEETPAGE ) );
  255. psp.dwSize = sizeof( PROPSHEETPAGE );
  256. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  257. psp.hInstance = _Module.GetResourceInstance( );
  258. psp.pszTemplate = MAKEINTRESOURCE( IDD_CONNECTION_TYPE );
  259. psp.lParam = ( LPARAM )this;
  260. psp.pfnDlgProc = CConType::DlgProc;
  261. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_HDR_CONTYPE );
  262. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBHDR_CONTYPE );
  263. return TRUE;
  264. }
  265. //-----------------------------------------------------------------------------
  266. BOOL CConType::OnDestroy( )
  267. {
  268. // m_hOtherPages.DeleteArray( );
  269. return CDialogWizBase::OnDestroy( );
  270. }
  271. //***********************************************************************************
  272. // Network Lan adapters
  273. //-----------------------------------------------------------------------------
  274. INT_PTR CALLBACK CLan::DlgProc( HWND hwnd , UINT msg , WPARAM wp , LPARAM lp )
  275. {
  276. CLan *pDlg;
  277. if( msg == WM_INITDIALOG )
  278. {
  279. CLan *pDlg = ( CLan * )( ( PROPSHEETPAGE *)lp )->lParam ;
  280. //
  281. // Don't use a static pointer here
  282. // There will be concurrency issues
  283. //
  284. SetWindowLongPtr( hwnd , DWLP_USER , ( LONG_PTR )pDlg );
  285. if( !IsBadReadPtr( pDlg , sizeof( CLan ) ) )
  286. {
  287. pDlg->OnInitDialog( hwnd , wp , lp );
  288. }
  289. return 0;
  290. }
  291. else
  292. {
  293. pDlg = ( CLan * )GetWindowLongPtr( hwnd , DWLP_USER );
  294. if( IsBadReadPtr( pDlg , sizeof( CLan ) ) )
  295. {
  296. return FALSE;
  297. }
  298. }
  299. switch( msg )
  300. {
  301. case WM_DESTROY:
  302. pDlg->OnDestroy( );
  303. break;
  304. case WM_NOTIFY:
  305. return pDlg->OnNotify( ( int )wp , ( LPNMHDR )lp , hwnd );
  306. case WM_COMMAND:
  307. pDlg->OnCommand( HIWORD( wp ) , LOWORD( wp ) , ( HWND )lp );
  308. break;
  309. }
  310. return FALSE;
  311. }
  312. //-----------------------------------------------------------------------------
  313. CLan::CLan( CCompdata *pCompdata )
  314. {
  315. m_pCompdata = pCompdata;
  316. }
  317. //-----------------------------------------------------------------------------
  318. BOOL CLan::OnInitDialog( HWND hDlg , WPARAM wp , LPARAM lp )
  319. {
  320. UNREFERENCED_PARAMETER( wp );
  321. UNREFERENCED_PARAMETER( lp );
  322. // DEVICENAMEW *pdnw = NULL;
  323. PGUIDTBL pGuidtbl = NULL;
  324. ICfgComp *pCfgcomp = NULL;
  325. // ULONG cbSize = 0;
  326. ULONG ulItems = 0;
  327. SendMessage( GetDlgItem( hDlg , IDC_SPIN_WZ ) , UDM_SETRANGE32 , 0 , ( LPARAM )999999 );
  328. if( m_pCompdata->GetServer( &pCfgcomp ) == 0 )
  329. {
  330. ODS( L"CLan::OnInitDialog GetServer failed\n" );
  331. return FALSE;
  332. }
  333. if( SUCCEEDED( pCfgcomp->GetLanAdapterList2( g_ws.pdName , &ulItems , &pGuidtbl ) ) )
  334. {
  335. for( ULONG i = 0 ; i < ulItems ; i++ )
  336. {
  337. SendMessage( GetDlgItem( hDlg , IDC_COMBO_LAN_ADAPTERS ) , CB_ADDSTRING , 0 , ( LPARAM )pGuidtbl[ i ].DispName );
  338. SendMessage( GetDlgItem( hDlg , IDC_COMBO_LAN_ADAPTERS ) , CB_SETITEMDATA , ( WPARAM )i , ( LPARAM )pGuidtbl[ i ].dwLana );
  339. }
  340. SendMessage( GetDlgItem( hDlg , IDC_COMBO_LAN_ADAPTERS ) , CB_SETCURSEL , 0 , 0 );
  341. pCfgcomp->BuildGuidTable( &pGuidtbl , ulItems , g_ws.pdName );
  342. CoTaskMemFree( pGuidtbl );
  343. }
  344. // LanAdapter list requires protocol type
  345. /*
  346. if( SUCCEEDED( pCfgcomp->GetLanAdapterList( g_ws.pdName , &ulItems , &cbSize , ( WCHAR ** )&pdnw ) ) )
  347. {
  348. for( ULONG i = 0 ; i < ulItems ; i++ )
  349. {
  350. if( pdnw[ i ] != NULL )
  351. {
  352. SendMessage( GetDlgItem( hDlg , IDC_COMBO_LAN_ADAPTERS ) , CB_ADDSTRING , 0 , ( LPARAM )pdnw[ i ] );
  353. }
  354. }
  355. SendMessage( GetDlgItem( hDlg , IDC_COMBO_LAN_ADAPTERS ) , CB_SETCURSEL , 0 , 0 );
  356. CoTaskMemFree( pdnw );
  357. }
  358. */
  359. pCfgcomp->Release( );
  360. SendMessage( GetDlgItem( hDlg , IDC_CHECK_LAN_UNLIMITEDCON ) , BM_CLICK , 0 , 0 );
  361. SendMessage( GetDlgItem( hDlg , IDC_EDIT_LAN_MAXCONS ) , EM_SETLIMITTEXT , ( WPARAM )6 , 0 );
  362. return FALSE;
  363. }
  364. //-----------------------------------------------------------------------------
  365. BOOL CLan::OnCommand( WORD wNotifyCode , WORD wID , HWND hwndCtrl )
  366. {
  367. if( wNotifyCode == BN_CLICKED)
  368. {
  369. if(wID == IDC_CHECK_LAN_UNLIMITEDCON )
  370. {
  371. EnableWindow( GetDlgItem( GetParent( hwndCtrl ) , IDC_EDIT_LAN_MAXCONS ) , SendMessage( hwndCtrl , BM_GETCHECK , 0 , 0 ) == BST_UNCHECKED );
  372. EnableWindow( GetDlgItem( GetParent( hwndCtrl ) , IDC_SPIN_WZ ) , SendMessage( hwndCtrl , BM_GETCHECK , 0 , 0 ) == BST_UNCHECKED );
  373. SendMessage(GetDlgItem(GetParent(hwndCtrl), IDC_RADIO_MAXCON),BM_SETCHECK,(WPARAM)BST_UNCHECKED,0);
  374. }
  375. else if(wID == IDC_RADIO_MAXCON)
  376. {
  377. EnableWindow( GetDlgItem( GetParent( hwndCtrl ) , IDC_EDIT_LAN_MAXCONS ) , SendMessage( hwndCtrl , BM_GETCHECK , 0 , 0 ) == BST_CHECKED );
  378. EnableWindow( GetDlgItem( GetParent( hwndCtrl ) , IDC_SPIN_WZ ) , SendMessage( hwndCtrl , BM_GETCHECK , 0 , 0 ) == BST_CHECKED );
  379. SendMessage(GetDlgItem(GetParent(hwndCtrl), IDC_CHECK_LAN_UNLIMITEDCON),BM_SETCHECK,(WPARAM)BST_UNCHECKED,0);
  380. SetFocus( GetDlgItem( GetParent( hwndCtrl ) , IDC_EDIT_LAN_MAXCONS ) );
  381. SendMessage( GetDlgItem( GetParent( hwndCtrl ) , IDC_EDIT_LAN_MAXCONS ) , EM_SETSEL , ( WPARAM )0 , ( LPARAM )-1 );
  382. }
  383. }
  384. return FALSE;
  385. }
  386. //-----------------------------------------------------------------------------
  387. BOOL CLan::OnNotify( int idCtrl , LPNMHDR pnmh , HWND hDlg )
  388. {
  389. if( pnmh->code == PSN_WIZNEXT )
  390. {
  391. if( SendMessage( GetDlgItem( hDlg , IDC_CHECK_LAN_UNLIMITEDCON ), BM_GETCHECK , 0 , 0 ) == BST_UNCHECKED )
  392. {
  393. UINT uMax;
  394. BOOL bOK = FALSE;
  395. uMax = GetDlgItemInt( hDlg , IDC_EDIT_LAN_MAXCONS , &bOK , FALSE );
  396. if( !bOK || uMax > 999999UL )
  397. {
  398. ErrMessage( hDlg , IDS_ERR_CONREADFAIL );
  399. //MessageBox( hDlg , L"Maximum number of connections allowed is 999,999" , L"Error" , MB_OK|MB_ICONERROR );
  400. SetWindowLongPtr( hDlg , DWLP_MSGRESULT , -1 );
  401. return TRUE;
  402. }
  403. }
  404. // check for unique lanadapter
  405. ICfgComp *pCfgcomp;
  406. if( m_pCompdata->GetServer( &pCfgcomp ) == 0 )
  407. {
  408. return FALSE;
  409. }
  410. INT_PTR iSel = SendMessage( GetDlgItem( hDlg , IDC_COMBO_LAN_ADAPTERS ) , CB_GETCURSEL , 0 , 0 );
  411. BOOL bUnique = FALSE;
  412. if( iSel != CB_ERR )
  413. {
  414. g_ws.LanAdapter = ( DWORD )SendMessage( GetDlgItem( hDlg , IDC_COMBO_LAN_ADAPTERS ) , CB_GETITEMDATA , ( WPARAM )iSel , 0 );
  415. if( SUCCEEDED( pCfgcomp->IsNetWorkConnectionUnique( g_ws.wdName , g_ws.pdName , ( ULONG )g_ws.LanAdapter , &bUnique ) ) )
  416. {
  417. if( !bUnique )
  418. {
  419. TCHAR tchMessage[256];
  420. TCHAR tchWarn[40];
  421. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_ERR_UNIQUECON , tchMessage , SIZE_OF_BUFFER( tchMessage ) ) );
  422. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_WARN_TITLE , tchWarn , SIZE_OF_BUFFER( tchWarn ) ) );
  423. MessageBox( hDlg , tchMessage , tchWarn , MB_ICONINFORMATION | MB_OK );
  424. SetWindowLongPtr( hDlg , DWLP_MSGRESULT , -1 );
  425. pCfgcomp->Release( );
  426. return TRUE;
  427. }
  428. }
  429. }
  430. g_ws.PdClass = SdNetwork;
  431. pCfgcomp->Release( );
  432. //g_ws.LanAdapter = ( ULONG )iSel;
  433. if( SendMessage( GetDlgItem( hDlg , IDC_CHECK_LAN_UNLIMITEDCON ) , BM_GETCHECK , 0 , 0 ) == BST_CHECKED )
  434. {
  435. g_ws.uMaxInstanceCount = ( ULONG )-1;
  436. }
  437. else
  438. {
  439. g_ws.uMaxInstanceCount = GetDlgItemInt( hDlg , IDC_EDIT_LAN_MAXCONS , &bUnique , FALSE );
  440. }
  441. }
  442. return CDialogWizBase::OnNotify( idCtrl , pnmh , hDlg );
  443. }
  444. //-----------------------------------------------------------------------------
  445. BOOL CLan::GetPropertySheetPage( PROPSHEETPAGE& psp)
  446. {
  447. ZeroMemory( &psp , sizeof( PROPSHEETPAGE ) );
  448. psp.dwSize = sizeof( PROPSHEETPAGE );
  449. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  450. psp.hInstance = _Module.GetResourceInstance( );
  451. psp.pszTemplate = MAKEINTRESOURCE( IDD_LAN );
  452. psp.lParam = ( LPARAM )this;
  453. psp.pfnDlgProc = CLan::DlgProc;
  454. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_HDR_LAN );
  455. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBHDR_LAN );
  456. return TRUE;
  457. }
  458. //***********************************************************************************
  459. // Security dialog -- MSGina or your gina
  460. //-----------------------------------------------------------------------------
  461. CSecurity::CSecurity( CCompdata *pCompdata )
  462. {
  463. m_pCompdata = pCompdata;
  464. m_pEncrypt = NULL;
  465. m_DefaultEncryptionLevelIndex = 0;
  466. }
  467. //-----------------------------------------------------------------------------
  468. INT_PTR CALLBACK CSecurity::DlgProc( HWND hwnd , UINT msg , WPARAM wp , LPARAM lp )
  469. {
  470. CSecurity *pDlg;
  471. if( msg == WM_INITDIALOG )
  472. {
  473. CSecurity *pDlg = ( CSecurity * )( ( PROPSHEETPAGE *)lp )->lParam ;
  474. //
  475. // Don't use a static pointer here
  476. // There will be concurrency issues
  477. //
  478. SetWindowLongPtr( hwnd , DWLP_USER , ( LONG_PTR )pDlg );
  479. if( !IsBadReadPtr( pDlg , sizeof( CSecurity ) ) )
  480. {
  481. pDlg->OnInitDialog( hwnd , wp , lp );
  482. }
  483. return 0;
  484. }
  485. else
  486. {
  487. pDlg = ( CSecurity * )GetWindowLongPtr( hwnd , DWLP_USER );
  488. if( IsBadReadPtr( pDlg , sizeof( CSecurity ) ) )
  489. {
  490. return FALSE;
  491. }
  492. }
  493. switch( msg )
  494. {
  495. case WM_DESTROY:
  496. pDlg->OnDestroy( );
  497. break;
  498. case WM_COMMAND:
  499. pDlg->OnCommand( HIWORD( wp ) , LOWORD( wp ) , ( HWND )lp );
  500. break;
  501. case WM_NOTIFY:
  502. pDlg->OnNotify( ( int )wp , ( LPNMHDR )lp , hwnd );
  503. break;
  504. }
  505. return FALSE;
  506. }
  507. //-----------------------------------------------------------------------------
  508. BOOL CSecurity::OnDestroy( )
  509. {
  510. if( m_pEncrypt != NULL )
  511. {
  512. CoTaskMemFree( m_pEncrypt );
  513. }
  514. return CDialogWizBase::OnDestroy( );
  515. }
  516. //-----------------------------------------------------------------------------
  517. BOOL CSecurity::OnCommand( WORD wNotifyCode , WORD wID , HWND hwndCtrl )
  518. {
  519. if( wNotifyCode == CBN_SELCHANGE && wID == IDC_COMBO_ENCRYPT_LVL )
  520. {
  521. if( SendMessage( hwndCtrl , CB_GETDROPPEDSTATE , 0 , 0 ) == FALSE )
  522. {
  523. INT_PTR nSel = SendMessage( hwndCtrl , CB_GETCURSEL , 0 , 0 );
  524. if( nSel != CB_ERR && m_pEncrypt != NULL )
  525. {
  526. if( m_pEncrypt[ nSel ].szDescr[ 0 ] == 0 )
  527. {
  528. EnableWindow( GetDlgItem( GetParent( hwndCtrl ) , IDC_STATIC_DESCRIPTION ) , FALSE );
  529. ShowWindow( GetDlgItem( GetParent( hwndCtrl ) , IDC_STATIC_DESCRIPTION ) , SW_HIDE );
  530. }
  531. else
  532. {
  533. ShowWindow( GetDlgItem( GetParent( hwndCtrl ) , IDC_STATIC_DESCRIPTION ) , SW_SHOW );
  534. EnableWindow( GetDlgItem( GetParent( hwndCtrl ) , IDC_STATIC_DESCRIPTION ) , TRUE );
  535. SetWindowText( GetDlgItem( GetParent( hwndCtrl ) , IDC_STATIC_DESCRIPTION ) , m_pEncrypt[ nSel ].szDescr );
  536. }
  537. if( !IsWindowEnabled( GetDlgItem( GetParent( hwndCtrl ) , IDC_STATIC_DESCRIPTION ) ) )
  538. {
  539. RECT rc;
  540. RECT rc2;
  541. GetWindowRect( GetDlgItem( GetParent( hwndCtrl ) , IDC_STATIC_ENCGRP ) , &rc );
  542. GetWindowRect( GetDlgItem( GetParent( hwndCtrl ), IDC_STATIC_DESCRIPTION ) , &rc2 );
  543. rc.bottom = rc2.top;
  544. MapWindowPoints( NULL , GetParent( hwndCtrl ) , ( LPPOINT )&rc , 2 );
  545. SetWindowPos( GetDlgItem( GetParent( hwndCtrl ), IDC_STATIC_ENCGRP ) , 0 , 0 , 0 , rc.right - rc.left , rc.bottom - rc.top , SWP_NOMOVE | SWP_SHOWWINDOW );
  546. //resize window
  547. }
  548. }
  549. }
  550. }
  551. return FALSE;
  552. }
  553. //-----------------------------------------------------------------------------
  554. BOOL CSecurity::OnInitDialog( HWND hwnd , WPARAM wp , LPARAM lp )
  555. {
  556. UNREFERENCED_PARAMETER( wp );
  557. UNREFERENCED_PARAMETER( lp );
  558. // Obtain USERCONFIG struct to determine if msgina is enabled or not
  559. // otherwise load thirdparty level's of encryption
  560. /*
  561. ICfgComp *pCfgcomp;
  562. if( m_pCompdata->GetServer( &pCfgcomp ) != 0 )
  563. {
  564. ULONG ulItems;
  565. // WdName is an enumtype
  566. if( SUCCEEDED( pCfgcomp->GetEncryptionLevels( g_ws.wdName , WdName , &ulItems , &m_pEncrypt ) ) )
  567. {
  568. for( ULONG i = 0; i < ulItems; ++i )
  569. {
  570. SendMessage( GetDlgItem( hwnd , IDC_COMBO_ENCRYPT_LVL ) , CB_ADDSTRING , 0 , ( LPARAM )m_pEncrypt[ i ].szLevel );
  571. if(m_pEncrypt[ i ].Flags & ELF_DEFAULT)
  572. {
  573. m_DefaultEncryptionLevelIndex = i;
  574. }
  575. }
  576. SendMessage( GetDlgItem( hwnd , IDC_COMBO_ENCRYPT_LVL ) , CB_SETCURSEL , (WPARAM)m_DefaultEncryptionLevelIndex, 0 );
  577. OnCommand( CBN_SELCHANGE , IDC_COMBO_ENCRYPT_LVL , GetDlgItem( hwnd , IDC_COMBO_ENCRYPT_LVL ) );
  578. }
  579. pCfgcomp->Release( );
  580. }
  581. */
  582. CheckDlgButton( hwnd, // handle to dialog box
  583. IDC_CHECK_ENCRYPT, // button-control identifier
  584. BST_UNCHECKED // check state
  585. );
  586. //SendMessage( GetDlgItem( hwnd , IDC_CHECK_ENCRYPT ) , BM_CLICK , 0 , 0 );
  587. return FALSE;
  588. }
  589. //-----------------------------------------------------------------------------
  590. // Save out information when going to the next area
  591. //-----------------------------------------------------------------------------
  592. BOOL CSecurity::OnNotify( int idCtrl , LPNMHDR pnmh , HWND hDlg )
  593. {
  594. if( pnmh->code == PSN_SETACTIVE && g_bConnectionTypeChanged_forEncryption )
  595. {
  596. ODS( L"Encryption PSN_SETACTIVE\n" );
  597. ICfgComp *pCfgcomp;
  598. if( m_pCompdata->GetServer( &pCfgcomp ) != 0 )
  599. {
  600. ULONG ulItems = 0;
  601. HWND hCombo = GetDlgItem( hDlg , IDC_COMBO_ENCRYPT_LVL );
  602. ASSERT( hCombo != NULL );
  603. // Remove everything from the list
  604. SendMessage( hCombo , CB_RESETCONTENT , 0 , 0 );
  605. // WdName is an enumtype
  606. if( m_pEncrypt != NULL )
  607. {
  608. CoTaskMemFree( m_pEncrypt );
  609. m_pEncrypt = NULL;
  610. }
  611. if( SUCCEEDED( pCfgcomp->GetEncryptionLevels( g_ws.wdName , WdName , &ulItems , &m_pEncrypt ) ) )
  612. {
  613. for( ULONG i = 0; i < ulItems; ++i )
  614. {
  615. SendMessage( hCombo , CB_ADDSTRING , 0 , ( LPARAM )m_pEncrypt[ i ].szLevel );
  616. if( m_pEncrypt[ i ].Flags & ELF_DEFAULT )
  617. {
  618. m_DefaultEncryptionLevelIndex = i;
  619. }
  620. }
  621. SendMessage( hCombo , CB_SETCURSEL , ( WPARAM )m_DefaultEncryptionLevelIndex, 0 );
  622. OnCommand( CBN_SELCHANGE , IDC_COMBO_ENCRYPT_LVL , hCombo );
  623. // SendMessage( GetDlgItem( hDlg , IDC_CHECK_ENCRYPT ) , BM_CLICK , 0 , 0 );
  624. }
  625. else
  626. {
  627. // no encryption info insert value to none and grey out the control
  628. TCHAR tchNone[ 80 ];
  629. LoadString( _Module.GetResourceInstance( ) , IDS_NONE , tchNone , SIZE_OF_BUFFER( tchNone ) );
  630. SendMessage( hCombo , CB_ADDSTRING , 0 , ( LPARAM )tchNone );
  631. SendMessage( hCombo , CB_SETCURSEL , 0 , 0 );
  632. EnableWindow( hCombo , FALSE );
  633. }
  634. pCfgcomp->Release( );
  635. }
  636. g_bConnectionTypeChanged_forEncryption = FALSE;
  637. }
  638. else if( pnmh->code == PSN_WIZNEXT )
  639. {
  640. if( m_pEncrypt != NULL )
  641. {
  642. INT_PTR iSel = SendMessage( GetDlgItem( hDlg , IDC_COMBO_ENCRYPT_LVL ) , CB_GETCURSEL , 0 , 0 );
  643. if( iSel != CB_ERR )
  644. {
  645. g_uc.MinEncryptionLevel = ( UCHAR )m_pEncrypt[iSel].RegistryValue;
  646. }
  647. else
  648. {
  649. g_uc.MinEncryptionLevel = ( UCHAR )m_pEncrypt[m_DefaultEncryptionLevelIndex].RegistryValue;
  650. }
  651. }
  652. else
  653. {
  654. g_uc.MinEncryptionLevel = 0;
  655. }
  656. g_uc.fUseDefaultGina = SendMessage( GetDlgItem( hDlg , IDC_CHECK_ENCRYPT ) , BM_GETCHECK , 0 , 0 ) == BST_CHECKED;
  657. }
  658. return CDialogWizBase::OnNotify( idCtrl , pnmh , hDlg );
  659. }
  660. //-----------------------------------------------------------------------------
  661. BOOL CSecurity::GetPropertySheetPage( PROPSHEETPAGE& psp)
  662. {
  663. ZeroMemory( &psp , sizeof( PROPSHEETPAGE ) );
  664. psp.dwSize = sizeof( PROPSHEETPAGE );
  665. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  666. psp.hInstance = _Module.GetResourceInstance( );
  667. psp.pszTemplate = MAKEINTRESOURCE( IDD_SECURITY );
  668. psp.lParam = ( LPARAM )this;
  669. psp.pfnDlgProc = CSecurity::DlgProc;
  670. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_HDR_SECURITY );
  671. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBHDR_SECURITY );
  672. return TRUE;
  673. }
  674. //***********************************************************************************
  675. // Timeout settings dialog
  676. //
  677. #if 0 // not used in the connection wizard
  678. //-----------------------------------------------------------------------------
  679. INT_PTR CALLBACK CTimeout::DlgProc( HWND hwnd , UINT msg , WPARAM wp , LPARAM lp )
  680. {
  681. CTimeout *pDlg;
  682. if( msg == WM_INITDIALOG )
  683. {
  684. CTimeout *pDlg = ( CTimeout * )( ( PROPSHEETPAGE *)lp )->lParam ;
  685. //
  686. // Don't use a static pointer here
  687. // There will be concurrency issues
  688. //
  689. SetWindowLongPtr( hwnd , DWLP_USER , ( LONG_PTR )pDlg );
  690. if( !IsBadReadPtr( pDlg , sizeof( CTimeout ) ) )
  691. {
  692. pDlg->OnInitDialog( hwnd , wp , lp );
  693. }
  694. return 0;
  695. }
  696. else
  697. {
  698. pDlg = ( CTimeout * )GetWindowLongPtr( hwnd , DWLP_USER );
  699. if( IsBadReadPtr( pDlg , sizeof( CTimeout ) ) )
  700. {
  701. return FALSE;
  702. }
  703. }
  704. switch( msg )
  705. {
  706. case WM_DESTROY:
  707. pDlg->OnDestroy( );
  708. break;
  709. case WM_COMMAND:
  710. pDlg->OnCommand( HIWORD( wp ) , LOWORD( wp ) , ( HWND )lp );
  711. break;
  712. case WM_NOTIFY:
  713. return pDlg->OnNotify( ( int )wp , ( LPNMHDR )lp , hwnd );
  714. }
  715. return FALSE;
  716. }
  717. //-----------------------------------------------------------------------------
  718. // Set time out settings to a default setting
  719. //-----------------------------------------------------------------------------
  720. BOOL CTimeout::OnInitDialog( HWND hwnd , WPARAM wp , LPARAM lp )
  721. {
  722. TCHAR tchBuffer[ 80 ];
  723. HWND hCombo[ 3 ] =
  724. {
  725. GetDlgItem( hwnd , IDC_COMBO_CON_WZ ),
  726. GetDlgItem( hwnd , IDC_COMBO_DISCON_WZ ),
  727. GetDlgItem( hwnd , IDC_COMBO_IDLE_WZ )
  728. };
  729. DWORD rgdwTime[] = { 0 , 1 , 5 , 10 , 15 , 30 , 60 , 120 , 180 , 1440 , 2880 , ( DWORD )-1 };
  730. for( int idx = 0; rgdwTime[ idx ] != ( DWORD)-1; ++idx )
  731. {
  732. if( rgdwTime[ idx ] == 0 )
  733. {
  734. LoadString( _Module.GetResourceInstance( ) , IDS_NOTIMEOUT , tchBuffer , SIZE_OF_BUFFER( tchBuffer ) );
  735. }
  736. else
  737. {
  738. ConvertToDuration( rgdwTime[ idx ] , tchBuffer );
  739. }
  740. for( int inner = 0 ; inner < 3 ; ++inner )
  741. {
  742. SendMessage( hCombo[ inner ] , CB_ADDSTRING , 0 , ( LPARAM )&tchBuffer[0] );
  743. SendMessage( hCombo[ inner ] , CB_SETITEMDATA , idx , rgdwTime[ idx ] );
  744. }
  745. }
  746. SendMessage( hCombo[ 0 ] , CB_SETCURSEL , 0 , 0 );
  747. SendMessage( hCombo[ 1] , CB_SETCURSEL , 0 , 0 );
  748. SendMessage( hCombo[ 2 ] , CB_SETCURSEL , 0 , 0 );
  749. // force WM_COMMAND to be sent
  750. SendMessage( GetDlgItem( hwnd , IDC_RADIO_UDCCS_WZ ) , BM_CLICK , 0 , 0 ) ;
  751. LoadAbbreviates( );
  752. return FALSE;
  753. }
  754. //-----------------------------------------------------------------------------
  755. BOOL CTimeout::OnCommand( WORD wNotifyCode , WORD wID , HWND hwndCtrl )
  756. {
  757. BOOL bEnable;
  758. if( wNotifyCode == BN_CLICKED )
  759. {
  760. if( wID == IDC_RADIO_UDCCS_WZ )
  761. {
  762. bEnable = FALSE;
  763. }
  764. else
  765. {
  766. bEnable = TRUE;
  767. }
  768. int rgID[] = { IDC_STATIC_CON , IDC_STATIC_DISCON , IDC_STATIC_IDLE , IDC_COMBO_CON_WZ , IDC_COMBO_DISCON_WZ , IDC_COMBO_IDLE_WZ , -1 };
  769. EnableGroup( GetParent( hwndCtrl ) , &rgID[0] , bEnable );
  770. }
  771. CTimeOutDlg::OnCommand( wNotifyCode , wID , hwndCtrl );
  772. return FALSE;
  773. }
  774. //-----------------------------------------------------------------------------
  775. // return TRUE if wish not to continue to the next page
  776. //-----------------------------------------------------------------------------
  777. BOOL CTimeout::OnNotify( int idCtrl , LPNMHDR pnmh , HWND hDlg )
  778. {
  779. if( pnmh->code == PSN_WIZNEXT )
  780. {
  781. if( SendMessage( GetDlgItem( hDlg , IDC_RADIO_UDCCS_WZ ) , BM_GETCHECK , 0 , 0 ) == BST_CHECKED )
  782. {
  783. g_uc.fInheritMaxSessionTime = 1;
  784. g_uc.fInheritMaxDisconnectionTime = 1;
  785. g_uc.fInheritMaxIdleTime = 1;
  786. }
  787. else
  788. {
  789. g_uc.fInheritMaxSessionTime = 0;
  790. g_uc.fInheritMaxDisconnectionTime = 0;
  791. g_uc.fInheritMaxIdleTime = 0;
  792. if( !ConvertToMinutes( GetDlgItem( hDlg , IDC_COMBO_CON_WZ ) , &g_uc.MaxConnectionTime ) )
  793. {
  794. SetWindowLongPtr( hDlg , DWLP_MSGRESULT , -1 );
  795. return TRUE;
  796. }
  797. if( !ConvertToMinutes( GetDlgItem( hDlg , IDC_COMBO_DISCON_WZ ) , &g_uc.MaxDisconnectionTime ) )
  798. {
  799. SetWindowLongPtr( hDlg , DWLP_MSGRESULT , -1 );
  800. return TRUE;
  801. }
  802. if( !ConvertToMinutes( GetDlgItem( hDlg , IDC_COMBO_IDLE_WZ ) , &g_uc.MaxIdleTime ) )
  803. {
  804. SetWindowLongPtr( hDlg , DWLP_MSGRESULT , -1 );
  805. return TRUE;
  806. }
  807. }
  808. }
  809. return CDialogWizBase::OnNotify( idCtrl , pnmh , hDlg );
  810. }
  811. //-----------------------------------------------------------------------------
  812. BOOL CTimeout::GetPropertySheetPage( PROPSHEETPAGE& psp)
  813. {
  814. ZeroMemory( &psp , sizeof( PROPSHEETPAGE ) );
  815. psp.dwSize = sizeof( PROPSHEETPAGE );
  816. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  817. psp.hInstance = _Module.GetResourceInstance( );
  818. psp.pszTemplate = MAKEINTRESOURCE( IDD_TIMEOUT );
  819. psp.lParam = ( LPARAM )this;
  820. psp.pfnDlgProc = CTimeout::DlgProc;
  821. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_HDR_TIMEOUT );
  822. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBHDR_TIMEOUT );
  823. return TRUE;
  824. }
  825. //-----------------------------------------------------------------------------
  826. int CTimeout::GetCBXSTATEindex( HWND hCombo )
  827. {
  828. int idx = -1;
  829. switch( GetDlgCtrlID( hCombo ) )
  830. {
  831. case IDC_COMBO_CON_WZ:
  832. idx = 0;
  833. break;
  834. case IDC_COMBO_DISCON_WZ:
  835. idx = 1;
  836. break;
  837. case IDC_COMBO_IDLE_WZ:
  838. idx = 2;
  839. break;
  840. }
  841. return idx;
  842. }
  843. #endif
  844. //***********************************************************************************
  845. #if 0 // object not used in connection wizard
  846. //-----------------------------------------------------------------------------
  847. INT_PTR CALLBACK CAutoLogon::DlgProc( HWND hwnd , UINT msg , WPARAM wp , LPARAM lp )
  848. {
  849. CAutoLogon *pDlg;
  850. if( msg == WM_INITDIALOG )
  851. {
  852. CAutoLogon *pDlg = ( CAutoLogon * )( ( PROPSHEETPAGE *)lp )->lParam ;
  853. //
  854. // Don't use a static pointer here
  855. // There will be concurrency issues
  856. //
  857. SetWindowLongPtr( hwnd , DWLP_USER , ( LONG_PTR )pDlg );
  858. if( !IsBadReadPtr( pDlg , sizeof( CAutoLogon ) ) )
  859. {
  860. pDlg->OnInitDialog( hwnd , wp , lp );
  861. }
  862. return 0;
  863. }
  864. else
  865. {
  866. pDlg = ( CAutoLogon * )GetWindowLongPtr( hwnd , DWLP_USER );
  867. if( IsBadReadPtr( pDlg , sizeof( CAutoLogon ) ) )
  868. {
  869. return FALSE;
  870. }
  871. }
  872. switch( msg )
  873. {
  874. case WM_DESTROY:
  875. pDlg->OnDestroy( );
  876. break;
  877. case WM_COMMAND:
  878. pDlg->OnCommand( HIWORD( wp ) , LOWORD( wp ) , ( HWND )lp );
  879. break;
  880. case WM_NOTIFY:
  881. return pDlg->OnNotify( ( int )wp , ( LPNMHDR )lp , hwnd );
  882. }
  883. return FALSE;
  884. }
  885. //-----------------------------------------------------------------------------
  886. BOOL CAutoLogon::OnCommand( WORD wNotifyCode , WORD wID , HWND hwndCtrl )
  887. {
  888. int rgID[] = { IDC_EDIT_USRNAME_WZ , IDC_STATIC_USRNAME , IDC_EDIT_DOMAIN_WZ , IDC_STATIC_DOMAIN , IDC_EDIT_PASSWD_WZ , IDC_STATIC_PASSWD , IDC_EDIT_CONFIRM_WZ , IDC_STATIC_CONPASSWD , -1 };
  889. if( wNotifyCode == BN_CLICKED )
  890. {
  891. if( wID == IDC_CHECK_ICCP_WZ )
  892. {
  893. BOOL bChecked = SendMessage( hwndCtrl , BM_GETCHECK , 0 , 0 ) == BST_CHECKED ;
  894. EnableGroup( GetParent( hwndCtrl ) , &rgID[ 0 ] , !bChecked );
  895. if( !bChecked )
  896. {
  897. EnableGroup( GetParent( hwndCtrl ) , &rgID[ 4 ] , !( SendMessage( GetDlgItem( GetParent( hwndCtrl ) , IDC_CHECK_PROMPTPASSWD_WZ ) , BM_GETCHECK , 0 , 0 ) == BST_CHECKED ) );
  898. SendMessage(GetDlgItem(GetParent(hwndCtrl), IDC_RADIO_LGINFO_WZ),BM_SETCHECK,(WPARAM)BST_CHECKED,0);
  899. }
  900. else
  901. {
  902. SendMessage(GetDlgItem(GetParent(hwndCtrl), IDC_RADIO_LGINFO_WZ),BM_SETCHECK,(WPARAM)BST_UNCHECKED,0);
  903. }
  904. }
  905. else if( wID == IDC_CHECK_PROMPTPASSWD_WZ )
  906. {
  907. if( SendMessage( GetDlgItem( GetParent( hwndCtrl ) , IDC_CHECK_ICCP_WZ ) , BM_GETCHECK , 0 , 0 ) == BST_UNCHECKED )
  908. {
  909. EnableGroup( GetParent( hwndCtrl ) , &rgID[ 4 ] , !( SendMessage( hwndCtrl , BM_GETCHECK , 0 , 0 ) == BST_CHECKED ) );
  910. }
  911. }
  912. else if( wID == IDC_RADIO_LGINFO_WZ )
  913. {
  914. BOOL bChecked = SendMessage( hwndCtrl , BM_GETCHECK , 0 , 0 ) == BST_CHECKED ;
  915. if(bChecked)
  916. {
  917. SendMessage(GetDlgItem(GetParent(hwndCtrl), IDC_CHECK_ICCP_WZ),BM_SETCHECK,(WPARAM)BST_UNCHECKED,0);
  918. EnableGroup( GetParent( hwndCtrl ) , &rgID[ 0 ] , TRUE );
  919. EnableGroup( GetParent( hwndCtrl ) , &rgID[ 4 ] , !( SendMessage( GetDlgItem( GetParent( hwndCtrl ) , IDC_CHECK_PROMPTPASSWD_WZ ) , BM_GETCHECK , 0 , 0 ) == BST_CHECKED ) );
  920. }
  921. else
  922. {
  923. SendMessage(GetDlgItem(GetParent(hwndCtrl), IDC_CHECK_ICCP_WZ),BM_SETCHECK,(WPARAM)BST_CHECKED,0);
  924. }
  925. //SendMessage(GetDlgItem(GetParent(hwndCtrl), IDC_CHECK_ICCP_WZ),BM_CLICK,0,0);
  926. }
  927. }
  928. return FALSE;
  929. }
  930. //-----------------------------------------------------------------------------
  931. BOOL CAutoLogon::OnInitDialog( HWND hwnd , WPARAM wp , LPARAM lp )
  932. {
  933. SendMessage( GetDlgItem( hwnd , IDC_EDIT_USRNAME_WZ ) , EM_SETLIMITTEXT , ( WPARAM )USERNAME_LENGTH , 0 );
  934. SendMessage( GetDlgItem( hwnd , IDC_EDIT_DOMAIN_WZ ) , EM_SETLIMITTEXT , ( WPARAM )DOMAIN_LENGTH , 0 );
  935. SendMessage( GetDlgItem( hwnd , IDC_EDIT_PASSWD_WZ ) , EM_SETLIMITTEXT , ( WPARAM )PASSWORD_LENGTH , 0 );
  936. SendMessage( GetDlgItem( hwnd , IDC_EDIT_CONFIRM_WZ ) , EM_SETLIMITTEXT , ( WPARAM )PASSWORD_LENGTH , 0 );
  937. SendMessage( GetDlgItem( hwnd , IDC_CHECK_ICCP_WZ ) , BM_CLICK , 0 , 0 );
  938. return FALSE;
  939. }
  940. //-----------------------------------------------------------------------------
  941. BOOL CAutoLogon::GetPropertySheetPage( PROPSHEETPAGE& psp)
  942. {
  943. ZeroMemory( &psp , sizeof( PROPSHEETPAGE ) );
  944. psp.dwSize = sizeof( PROPSHEETPAGE );
  945. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  946. psp.hInstance = _Module.GetResourceInstance( );
  947. psp.pszTemplate = MAKEINTRESOURCE( IDD_AUTO_LOGON );
  948. psp.lParam = ( LPARAM )this;
  949. psp.pfnDlgProc = CAutoLogon::DlgProc;
  950. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_HEADER_LOGONSETTINGS );
  951. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBHEADER_LOGONSETTINGS );
  952. return TRUE;
  953. }
  954. //-----------------------------------------------------------------------------
  955. BOOL CAutoLogon::OnNotify( int idCtrl , LPNMHDR pnmh , HWND hDlg )
  956. {
  957. if( pnmh->code == PSN_WIZNEXT )
  958. {
  959. g_uc.fInheritAutoLogon = SendMessage( GetDlgItem( hDlg , IDC_CHECK_ICCP_WZ ) , BM_GETCHECK , 0 , 0 ) == BST_CHECKED ? TRUE : FALSE;
  960. if( !g_uc.fInheritAutoLogon )
  961. {
  962. if( !ConfirmPwd( hDlg ) )
  963. {
  964. SetWindowLongPtr( hDlg , DWLP_MSGRESULT , -1 );
  965. return TRUE;
  966. }
  967. }
  968. GetWindowText( GetDlgItem( hDlg , IDC_EDIT_USRNAME_WZ ) , g_uc.UserName , SIZE_OF_BUFFER( g_uc.UserName ) );
  969. GetWindowText( GetDlgItem( hDlg , IDC_EDIT_DOMAIN_WZ ) , g_uc.Domain , SIZE_OF_BUFFER( g_uc.Domain ) );
  970. GetWindowText( GetDlgItem( hDlg , IDC_EDIT_PASSWD_WZ ) , g_uc.Password , SIZE_OF_BUFFER( g_uc.Password ) );
  971. g_uc.fPromptForPassword = SendMessage( GetDlgItem( hDlg , IDC_CHECK_PROMPTPASSWD_WZ ) ,
  972. BM_GETCHECK , 0 , 0 ) == BST_CHECKED ? TRUE : FALSE;
  973. }
  974. return CDialogWizBase::OnNotify( idCtrl , pnmh , hDlg );
  975. }
  976. //-----------------------------------------------------------------------------
  977. BOOL CAutoLogon::ConfirmPwd( HWND hDlg )
  978. {
  979. TCHAR tchPzWd[ PASSWORD_LENGTH + 1];
  980. TCHAR tchConfirm[ PASSWORD_LENGTH + 1];
  981. if( SendMessage( GetDlgItem( hDlg , IDC_CHECK_LOGON_INHERIT ) , BM_GETCHECK , 0 , 0 ) == BST_CHECKED )
  982. {
  983. return TRUE;
  984. }
  985. int iSz = GetWindowText( GetDlgItem( hDlg , IDC_EDIT_PASSWD_WZ ) , tchPzWd , SIZE_OF_BUFFER( tchPzWd ) );
  986. // warn on the minimum and maximum sizes
  987. if( iSz > 0 && ( iSz < 6 || iSz > PASSWORD_LENGTH ) )
  988. {
  989. ErrMessage( hDlg , IDS_ERR_PASSWD );
  990. SetFocus( GetDlgItem( hDlg , IDC_EDIT_PASSWD_WZ ) );
  991. SendMessage( GetDlgItem( hDlg , IDC_EDIT_PASSWD_WZ ) , EM_SETSEL , ( WPARAM )0 , ( LPARAM )-1 );
  992. SetWindowText( GetDlgItem( hDlg , IDC_EDIT_CONFIRM_WZ ) , L"" );
  993. return FALSE;
  994. }
  995. int iSz2 = GetWindowText( GetDlgItem( hDlg , IDC_EDIT_CONFIRM_WZ ) , tchConfirm , SIZE_OF_BUFFER( tchConfirm ) );
  996. if( iSz == iSz2 )
  997. {
  998. if( iSz == 0 )
  999. {
  1000. return TRUE;
  1001. }
  1002. if( lstrcmp( tchPzWd , tchConfirm ) == 0 )
  1003. {
  1004. return TRUE;
  1005. }
  1006. }
  1007. ErrMessage( hDlg , IDS_ERR_PASSCONFIRM );
  1008. SetFocus( GetDlgItem( hDlg , IDC_EDIT_CONFIRM_WZ ) );
  1009. SetWindowText( GetDlgItem( hDlg , IDC_EDIT_CONFIRM_WZ ) , L"" );
  1010. return FALSE;
  1011. }
  1012. #endif
  1013. //***********************************************************************************
  1014. #if 0 // object no longer used in connection wizard
  1015. //-----------------------------------------------------------------------------
  1016. INT_PTR CALLBACK CInitProg::DlgProc( HWND hwnd , UINT msg , WPARAM wp , LPARAM lp )
  1017. {
  1018. CInitProg *pDlg;
  1019. if( msg == WM_INITDIALOG )
  1020. {
  1021. CInitProg *pDlg = ( CInitProg * )( ( PROPSHEETPAGE *)lp )->lParam ;
  1022. //
  1023. // Don't use a static pointer here
  1024. // There will be concurrency issues
  1025. //
  1026. SetWindowLongPtr( hwnd , DWLP_USER , ( LONG_PTR )pDlg );
  1027. if( !IsBadReadPtr( pDlg , sizeof( CInitProg ) ) )
  1028. {
  1029. pDlg->OnInitDialog( hwnd , wp , lp );
  1030. }
  1031. return 0;
  1032. }
  1033. else
  1034. {
  1035. pDlg = ( CInitProg * )GetWindowLongPtr( hwnd , DWLP_USER );
  1036. if( IsBadReadPtr( pDlg , sizeof( CInitProg ) ) )
  1037. {
  1038. return FALSE;
  1039. }
  1040. }
  1041. switch( msg )
  1042. {
  1043. case WM_DESTROY:
  1044. pDlg->OnDestroy( );
  1045. break;
  1046. case WM_COMMAND:
  1047. pDlg->OnCommand( HIWORD( wp ) , LOWORD( wp ) , ( HWND )lp );
  1048. break;
  1049. case WM_NOTIFY:
  1050. return pDlg->OnNotify( ( int )wp , ( LPNMHDR )lp , hwnd );
  1051. }
  1052. return FALSE;
  1053. }
  1054. //-----------------------------------------------------------------------------
  1055. BOOL CInitProg::OnInitDialog( HWND hwnd , WPARAM wp , LPARAM lp )
  1056. {
  1057. SendMessage( GetDlgItem( hwnd , IDC_EDIT_INITPROG_CMDLINE ) , EM_SETLIMITTEXT , ( WPARAM )INITIALPROGRAM_LENGTH , 0 );
  1058. SendMessage( GetDlgItem( hwnd , IDC_EDIT_INITPROG_WD ) , EM_SETLIMITTEXT , ( WPARAM )DIRECTORY_LENGTH , 0 );
  1059. SendMessage( GetDlgItem( hwnd , IDC_CHECK_INITPROG_INHERIT ) , BM_CLICK , 0 , 0 );
  1060. return FALSE;
  1061. }
  1062. //-----------------------------------------------------------------------------
  1063. BOOL CInitProg::OnCommand( WORD wNotifyCode , WORD wID , HWND hwndCtrl )
  1064. {
  1065. if( wNotifyCode == BN_CLICKED && wID == IDC_CHECK_INITPROG_INHERIT )
  1066. {
  1067. int rgID[] = { IDC_EDIT_INITPROG_CMDLINE , IDC_STATIC_CMDLINE , IDC_EDIT_INITPROG_WD , IDC_STATIC_WF , -1 };
  1068. EnableGroup( GetParent( hwndCtrl ) , &rgID[0] , SendMessage( hwndCtrl , BM_GETCHECK , 0 , 0 ) == BST_UNCHECKED );
  1069. }
  1070. return FALSE;
  1071. }
  1072. //-----------------------------------------------------------------------------
  1073. BOOL CInitProg::GetPropertySheetPage( PROPSHEETPAGE& psp)
  1074. {
  1075. ZeroMemory( &psp , sizeof( PROPSHEETPAGE ) );
  1076. psp.dwSize = sizeof( PROPSHEETPAGE );
  1077. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  1078. psp.hInstance = _Module.GetResourceInstance( );
  1079. psp.pszTemplate = MAKEINTRESOURCE( IDD_INITIAL_PROGRAM );
  1080. psp.lParam = ( LPARAM )this;
  1081. psp.pfnDlgProc = CInitProg::DlgProc;
  1082. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_HDR_INITPRG );
  1083. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBHDR_INITPRG );
  1084. return TRUE;
  1085. }
  1086. //-----------------------------------------------------------------------------
  1087. BOOL CInitProg::OnNotify( int idCtrl , LPNMHDR pnmh , HWND hDlg )
  1088. {
  1089. g_uc.fInheritInitialProgram = SendMessage( GetDlgItem( hDlg , IDC_CHECK_INITPROG_INHERIT ) , BM_GETCHECK , 0 , 0 );
  1090. if( !g_uc.fInheritInitialProgram )
  1091. {
  1092. GetWindowText( GetDlgItem( hDlg , IDC_EDIT_INITPROG_CMDLINE ) , g_uc.InitialProgram , SIZE_OF_BUFFER( g_uc.InitialProgram ) );
  1093. GetWindowText( GetDlgItem( hDlg , IDC_EDIT_INITPROG_WD ) , g_uc.WorkDirectory , SIZE_OF_BUFFER( g_uc.WorkDirectory ) );
  1094. }
  1095. return CDialogWizBase::OnNotify( idCtrl , pnmh , hDlg );
  1096. }
  1097. #endif
  1098. //***********************************************************************************
  1099. //-----------------------------------------------------------------------------
  1100. INT_PTR CALLBACK CRemotectrl::DlgProc( HWND hwnd , UINT msg , WPARAM wp , LPARAM lp )
  1101. {
  1102. CRemotectrl *pDlg;
  1103. if( msg == WM_INITDIALOG )
  1104. {
  1105. pDlg = ( CRemotectrl * )( ( PROPSHEETPAGE *)lp )->lParam ;
  1106. //
  1107. // Don't use a static pointer here
  1108. // There will be concurrency issues
  1109. //
  1110. SetWindowLongPtr( hwnd , DWLP_USER , ( LONG_PTR )pDlg );
  1111. if( !IsBadReadPtr( pDlg , sizeof( CRemotectrl ) ) )
  1112. {
  1113. pDlg->OnInitDialog( hwnd , wp , lp );
  1114. }
  1115. return 0;
  1116. }
  1117. else
  1118. {
  1119. pDlg = ( CRemotectrl * )GetWindowLongPtr( hwnd , DWLP_USER );
  1120. if( IsBadReadPtr( pDlg , sizeof( CRemotectrl ) ) )
  1121. {
  1122. return FALSE;
  1123. }
  1124. }
  1125. switch( msg )
  1126. {
  1127. case WM_DESTROY:
  1128. pDlg->OnDestroy( );
  1129. break;
  1130. case WM_COMMAND:
  1131. pDlg->OnCommand( HIWORD( wp ) , LOWORD( wp ) , ( HWND )lp );
  1132. break;
  1133. case WM_NOTIFY:
  1134. pDlg->OnNotify( ( int )wp , ( LPNMHDR )lp , hwnd );
  1135. break;
  1136. }
  1137. return FALSE;
  1138. }
  1139. //-----------------------------------------------------------------------------
  1140. // Set default values for Remote control dialog
  1141. //-----------------------------------------------------------------------------
  1142. BOOL CRemotectrl::OnInitDialog( HWND hwnd , WPARAM wp , LPARAM lp )
  1143. {
  1144. UNREFERENCED_PARAMETER( wp );
  1145. UNREFERENCED_PARAMETER( lp );
  1146. SendMessage( GetDlgItem( hwnd , IDC_RADIO_REMOTECTRL_WATCH ) , BM_SETCHECK , ( WPARAM )TRUE , 0 );
  1147. SendMessage( GetDlgItem( hwnd , IDC_CHECK_REMOTECTRL_NOTIFYUSER ) , BM_SETCHECK , ( WPARAM )TRUE , 0 );
  1148. SendMessage( GetDlgItem( hwnd , IDC_RADIO_INHERIT_REMOTE_CONTROL ) , BM_CLICK , 0 , 0 );
  1149. return FALSE;
  1150. }
  1151. //-----------------------------------------------------------------------------
  1152. BOOL CRemotectrl::OnCommand( WORD wNotifyCode , WORD wID , HWND hwndCtrl )
  1153. {
  1154. if( wNotifyCode == BN_CLICKED && wID == IDC_RADIO_INHERIT_REMOTE_CONTROL ||
  1155. wID == IDC_RADIO_REMOTECTRL_NO || wID == IDC_RADIO_ENABLE_REMOTECONTROL )
  1156. {
  1157. int rgID[] = { IDC_CHECK_REMOTECTRL_NOTIFYUSER , IDC_RADIO_REMOTECTRL_WATCH , IDC_RADIO_REMOTECTRL_CONTROL , -1 };
  1158. EnableGroup( GetParent( hwndCtrl ) , rgID , SendMessage( GetDlgItem( GetParent( hwndCtrl ) ,
  1159. IDC_RADIO_ENABLE_REMOTECONTROL ) , BM_GETCHECK , 0 , 0 ) == BST_CHECKED );
  1160. }
  1161. return FALSE;
  1162. }
  1163. //-----------------------------------------------------------------------------
  1164. BOOL CRemotectrl::OnNotify( int idCtrl , LPNMHDR pnmh , HWND hDlg )
  1165. {
  1166. if( pnmh->code == PSN_WIZNEXT )
  1167. {
  1168. if( SendMessage( GetDlgItem( hDlg , IDC_RADIO_INHERIT_REMOTE_CONTROL ) , BM_GETCHECK , 0 , 0 ) == BST_UNCHECKED )
  1169. {
  1170. g_uc.fInheritShadow = FALSE;
  1171. if( SendMessage( GetDlgItem( hDlg , IDC_RADIO_REMOTECTRL_NO ) , BM_GETCHECK , 0 , 0 ) == BST_UNCHECKED )
  1172. {
  1173. BOOL bCheckNotify = ( BOOL )SendMessage( GetDlgItem( hDlg , IDC_CHECK_REMOTECTRL_NOTIFYUSER ) , BM_GETCHECK , 0 , 0 );
  1174. BOOL bRadioControl = ( BOOL )SendMessage( GetDlgItem( hDlg , IDC_RADIO_REMOTECTRL_CONTROL ) , BM_GETCHECK , 0 , 0 );
  1175. if( bCheckNotify )
  1176. {
  1177. if( bRadioControl )
  1178. {
  1179. g_uc.Shadow = Shadow_EnableInputNotify;
  1180. }
  1181. else
  1182. {
  1183. g_uc.Shadow = Shadow_EnableNoInputNotify;
  1184. }
  1185. }
  1186. else
  1187. {
  1188. if( bRadioControl )
  1189. {
  1190. g_uc.Shadow = Shadow_EnableInputNoNotify;
  1191. }
  1192. else
  1193. {
  1194. g_uc.Shadow = Shadow_EnableNoInputNoNotify;
  1195. }
  1196. }
  1197. }
  1198. else
  1199. {
  1200. g_uc.Shadow = Shadow_Disable;
  1201. }
  1202. }
  1203. else
  1204. {
  1205. g_uc.fInheritShadow = TRUE;
  1206. }
  1207. }
  1208. return CDialogWizBase::OnNotify( idCtrl , pnmh , hDlg );
  1209. }
  1210. //-----------------------------------------------------------------------------
  1211. BOOL CRemotectrl::GetPropertySheetPage( PROPSHEETPAGE& psp)
  1212. {
  1213. ZeroMemory( &psp , sizeof( PROPSHEETPAGE ) );
  1214. psp.dwSize = sizeof( PROPSHEETPAGE );
  1215. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  1216. psp.hInstance = _Module.GetResourceInstance( );
  1217. psp.pszTemplate = MAKEINTRESOURCE( IDD_REMOTE_CONTROL );
  1218. psp.lParam = ( LPARAM )this;
  1219. psp.pfnDlgProc = CRemotectrl::DlgProc;
  1220. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_HDR_REMOTE );
  1221. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBHDR_REMOTE );
  1222. return TRUE;
  1223. }
  1224. //***********************************************************************************
  1225. #if 0 // object not used in connection wizard
  1226. //-----------------------------------------------------------------------------
  1227. INT_PTR CALLBACK CWallPaper::DlgProc( HWND hwnd , UINT msg , WPARAM wp , LPARAM lp )
  1228. {
  1229. CWallPaper *pDlg;
  1230. if( msg == WM_INITDIALOG )
  1231. {
  1232. CWallPaper *pDlg = ( CWallPaper * )( ( PROPSHEETPAGE *)lp )->lParam ;
  1233. //
  1234. // Don't use a static pointer here
  1235. // There will be concurrency issues
  1236. //
  1237. SetWindowLongPtr( hwnd , DWLP_USER , ( LONG_PTR )pDlg );
  1238. if( !IsBadReadPtr( pDlg , sizeof( CWallPaper ) ) )
  1239. {
  1240. pDlg->OnInitDialog( hwnd , wp , lp );
  1241. }
  1242. return 0;
  1243. }
  1244. else
  1245. {
  1246. pDlg = ( CWallPaper * )GetWindowLongPtr( hwnd , DWLP_USER );
  1247. if( IsBadReadPtr( pDlg , sizeof( CWallPaper ) ) )
  1248. {
  1249. return FALSE;
  1250. }
  1251. }
  1252. switch( msg )
  1253. {
  1254. case WM_DESTROY:
  1255. pDlg->OnDestroy( );
  1256. break;
  1257. case WM_NOTIFY:
  1258. pDlg->OnNotify( ( int )wp , ( LPNMHDR )lp , hwnd );
  1259. break;
  1260. }
  1261. return FALSE;
  1262. }
  1263. //-----------------------------------------------------------------------------
  1264. BOOL CWallPaper::OnInitDialog( HWND hwnd , WPARAM wp , LPARAM lp )
  1265. {
  1266. return FALSE;
  1267. }
  1268. //-----------------------------------------------------------------------------
  1269. BOOL CWallPaper::GetPropertySheetPage( PROPSHEETPAGE& psp)
  1270. {
  1271. ZeroMemory( &psp , sizeof( PROPSHEETPAGE ) );
  1272. psp.dwSize = sizeof( PROPSHEETPAGE );
  1273. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  1274. psp.hInstance = _Module.GetResourceInstance( );
  1275. psp.pszTemplate = MAKEINTRESOURCE( IDD_WALLPAPER );
  1276. psp.lParam = ( LPARAM )this;
  1277. psp.pfnDlgProc = CWallPaper::DlgProc;
  1278. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_HDR_WALLPR );
  1279. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBHDR_WALLPR );
  1280. return TRUE;
  1281. }
  1282. //-----------------------------------------------------------------------------
  1283. BOOL CWallPaper::OnNotify( int idCtrl , LPNMHDR pnmh , HWND hDlg )
  1284. {
  1285. if( pnmh->code == PSN_WIZNEXT )
  1286. {
  1287. g_uc.fWallPaperDisabled = SendMessage( GetDlgItem( hDlg , IDC_CHECK_WALLPAPER ) , BM_GETCHECK , 0 , 0 );
  1288. }
  1289. return CDialogWizBase::OnNotify( idCtrl , pnmh , hDlg );
  1290. }
  1291. #endif
  1292. //***********************************************************************************
  1293. //-----------------------------------------------------------------------------
  1294. CConProp::CConProp( CCompdata *pCompdata )
  1295. {
  1296. m_pCompdata = pCompdata;
  1297. m_iOldSel = -1;
  1298. }
  1299. //-----------------------------------------------------------------------------
  1300. INT_PTR CALLBACK CConProp::DlgProc( HWND hwnd , UINT msg , WPARAM wp , LPARAM lp )
  1301. {
  1302. CConProp *pDlg;
  1303. if( msg == WM_INITDIALOG )
  1304. {
  1305. CConProp *pDlg = ( CConProp * )( ( PROPSHEETPAGE *)lp )->lParam ;
  1306. //
  1307. // Don't use a static pointer here
  1308. // There will be concurrency issues
  1309. //
  1310. SetWindowLongPtr( hwnd , DWLP_USER , ( LONG_PTR )pDlg );
  1311. if( !IsBadReadPtr( pDlg , sizeof( CConProp ) ) )
  1312. {
  1313. pDlg->OnInitDialog( hwnd , wp , lp );
  1314. }
  1315. return 0;
  1316. }
  1317. else
  1318. {
  1319. pDlg = ( CConProp * )GetWindowLongPtr( hwnd , DWLP_USER );
  1320. if( IsBadReadPtr( pDlg , sizeof( CConProp ) ) )
  1321. {
  1322. return FALSE;
  1323. }
  1324. }
  1325. switch( msg )
  1326. {
  1327. case WM_DESTROY:
  1328. pDlg->OnDestroy( );
  1329. break;
  1330. case WM_NOTIFY:
  1331. return pDlg->OnNotify( ( int )wp , ( LPNMHDR )lp , hwnd );
  1332. }
  1333. return FALSE;
  1334. }
  1335. //-----------------------------------------------------------------------------
  1336. BOOL CConProp::OnInitDialog( HWND hDlg , WPARAM wp , LPARAM lp )
  1337. {
  1338. UNREFERENCED_PARAMETER( wp );
  1339. UNREFERENCED_PARAMETER( lp );
  1340. g_pObj = NULL;
  1341. SendMessage( GetDlgItem( hDlg , IDC_EDIT_COMMENT_WZ ) , EM_SETLIMITTEXT , ( WPARAM )WINSTATIONCOMMENT_LENGTH , 0 );
  1342. SendMessage( GetDlgItem( hDlg , IDC_EDIT_WSNAME_WZ ) , EM_SETLIMITTEXT , ( WPARAM )( WINSTATIONNAME_LENGTH - WINSTATION_NAME_TRUNCATE_BY ), 0 );
  1343. return FALSE;
  1344. }
  1345. //-----------------------------------------------------------------------------
  1346. BOOL CConProp::GetPropertySheetPage( PROPSHEETPAGE& psp)
  1347. {
  1348. ZeroMemory( &psp , sizeof( PROPSHEETPAGE ) );
  1349. psp.dwSize = sizeof( PROPSHEETPAGE );
  1350. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  1351. psp.hInstance = _Module.GetResourceInstance( );
  1352. psp.pszTemplate = MAKEINTRESOURCE( IDD_CONNECTION_PROP );
  1353. psp.lParam = ( LPARAM )this;
  1354. psp.pfnDlgProc = CConProp::DlgProc;
  1355. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_HDR_TRANSTYPE );
  1356. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBHDR_TRANSTYPE );
  1357. return TRUE;
  1358. }
  1359. //-----------------------------------------------------------------------------
  1360. BOOL CConProp::OnNotify( int idCtrl , LPNMHDR pnmh , HWND hDlg )
  1361. {
  1362. ICfgComp *pCfgcomp;
  1363. if( pnmh->code == PSN_SETACTIVE && g_bConnectionTypeChanged_forConProps )
  1364. {
  1365. PDNAMEW * pDname;
  1366. ULONG ulItems = 0;
  1367. ULONG cbSize = 0;
  1368. ODS( L"CConProp::OnNotify -- PSN_SETACTIVE\n" );
  1369. if( m_pCompdata->GetServer( &pCfgcomp ) == 0 )
  1370. {
  1371. ODS( L"CConProp::OnNotify - PSN_SETACTIVE getserver failed\n" );
  1372. return FALSE;
  1373. }
  1374. // remove every item from the list
  1375. HWND hCombo = GetDlgItem( hDlg , IDC_COMBO_TRANSPORT_WZ );
  1376. ASSERT( hCombo != NULL );
  1377. // Remove everything from the list
  1378. SendMessage( hCombo , CB_RESETCONTENT , 0 , 0 );
  1379. // WdName is a flag and not a variable
  1380. if( SUCCEEDED( pCfgcomp->GetTransportTypes( g_ws.wdName , WdName , &ulItems , &cbSize , ( WCHAR ** )&pDname ) ) )
  1381. {
  1382. for( ULONG i = 0 ; i < ulItems ; ++i )
  1383. {
  1384. SendMessage( hCombo , CB_ADDSTRING , 0 , ( LPARAM )pDname[ i ] );
  1385. }
  1386. SendMessage( hCombo , CB_SETCURSEL , ( WPARAM ) 0 , 0 );
  1387. CoTaskMemFree( pDname );
  1388. }
  1389. pCfgcomp->Release( );
  1390. g_bConnectionTypeChanged_forConProps = FALSE;
  1391. }
  1392. else if( pnmh->code == PSN_WIZNEXT )
  1393. {
  1394. DWORD dwErr = 0;
  1395. if( GetWindowText( GetDlgItem( hDlg , IDC_EDIT_WSNAME_WZ ) , g_ws.Name , SIZE_OF_BUFFER( g_ws.Name ) ) == 0 || !IsValidConnectionName( g_ws.Name , &dwErr ) )
  1396. {
  1397. if( dwErr == ERROR_INVALID_FIRSTCHARACTER )
  1398. {
  1399. ErrMessage( hDlg , IDS_ERR_INVALIDFIRSTCHAR );
  1400. }
  1401. else
  1402. {
  1403. ErrMessage( hDlg , IDS_ERR_INVALIDCHARS );
  1404. }
  1405. SetFocus( GetDlgItem( hDlg , IDC_EDIT_WSNAME_WZ ) );
  1406. SetWindowLongPtr( hDlg , DWLP_MSGRESULT , -1 );
  1407. return TRUE;
  1408. }
  1409. if( m_pCompdata->GetServer( &pCfgcomp ) == 0 )
  1410. {
  1411. return FALSE;
  1412. }
  1413. BOOL bUnique;
  1414. if( SUCCEEDED( pCfgcomp->IsWSNameUnique( g_ws.Name , &bUnique ) ) )
  1415. {
  1416. if( !bUnique )
  1417. {
  1418. ErrMessage( hDlg , IDS_ERR_CONEXIST );
  1419. SetFocus( GetDlgItem( hDlg , IDC_EDIT_WSNAME_WZ ) );
  1420. SendMessage( GetDlgItem( hDlg , IDC_EDIT_WSNAME_WZ ) , EM_SETSEL , ( WPARAM )0 , ( LPARAM )-1 );
  1421. SetWindowLongPtr( hDlg , DWLP_MSGRESULT , -1 );
  1422. pCfgcomp->Release( );
  1423. return TRUE;
  1424. }
  1425. }
  1426. GetWindowText( GetDlgItem( hDlg , IDC_EDIT_COMMENT_WZ ) , g_ws.Comment , SIZE_OF_BUFFER( g_ws.Comment ) );
  1427. INT_PTR iSel = SendMessage( GetDlgItem( hDlg , IDC_COMBO_TRANSPORT_WZ ) , CB_GETCURSEL , 0 , 0 );
  1428. if( iSel != CB_ERR )
  1429. {
  1430. SendMessage( GetDlgItem( hDlg , IDC_COMBO_TRANSPORT_WZ ) , CB_GETLBTEXT , iSel , ( LPARAM )g_ws.pdName );
  1431. if( iSel != m_iOldSel )
  1432. {
  1433. g_nAsyncOrNetwork = 0;
  1434. m_iOldSel = iSel;
  1435. }
  1436. }
  1437. // get the SDCLASS
  1438. DWORD dwSdClass = 0;
  1439. if( FAILED( pCfgcomp->GetTransportType( g_ws.wdName , g_ws.pdName , &dwSdClass ) ) )
  1440. {
  1441. dwSdClass = SdNone;
  1442. ODS( L"GetTransPortType failed @ CConProp::OnNotify\n" );
  1443. }
  1444. if( dwSdClass == SdNetwork && g_nAsyncOrNetwork != LAN_PAGE )
  1445. {
  1446. g_nAsyncOrNetwork = LAN_PAGE;
  1447. VERIFY_S( TRUE , RemovePages( hDlg ) );
  1448. VERIFY_S( TRUE , AddPages( hDlg , LAN_PAGE , g_ws.wdName ) );
  1449. }
  1450. else if( dwSdClass == SdAsync && g_nAsyncOrNetwork != ASYNC_PAGE )
  1451. {
  1452. g_nAsyncOrNetwork = ASYNC_PAGE;
  1453. VERIFY_S( TRUE , RemovePages( hDlg ) );
  1454. VERIFY_S( TRUE , AddPages( hDlg , ASYNC_PAGE , g_ws.wdName ) );
  1455. }
  1456. else if( dwSdClass != SdAsync && dwSdClass != SdNetwork )
  1457. {
  1458. // remove g_nAsyncOrNetwork page and let citrix or third party vendor worry about the transport type
  1459. g_nAsyncOrNetwork = FIN_PAGE;
  1460. VERIFY_S( TRUE , RemovePages( hDlg ) );
  1461. VERIFY_S( TRUE , AddPages( hDlg , -1 , g_ws.wdName ) ); // only add citrix or 3rd parth pages
  1462. // I'm tempted
  1463. // g_nAsyncOrNetwork = 0;
  1464. }
  1465. pCfgcomp->Release( );
  1466. }
  1467. return CDialogWizBase::OnNotify( idCtrl , pnmh , hDlg );
  1468. }
  1469. //-------------------------------------------------------------------------------
  1470. // We're about to update lanpage or asyncpage and slap in citrix additional pages
  1471. // so we need to remove all of them first even the final page
  1472. //-------------------------------------------------------------------------------
  1473. BOOL CConProp::RemovePages( HWND hDlg )
  1474. {
  1475. HPROPSHEETPAGE hPage = NULL;
  1476. for( int idx = /*g_nAsyncOrNetwork*/ LAN_PAGE; idx < MS_DIALOG_COUNT ; idx++ )
  1477. {
  1478. hPage= *m_pCompdata->m_hPages.GetAt( idx );
  1479. if( hPage != NULL )
  1480. {
  1481. PropSheet_RemovePage( GetParent( hDlg ) , 0 , hPage );
  1482. m_pCompdata->m_hPages.SetAt( idx , NULL );
  1483. }
  1484. }
  1485. for( idx = 0 ; idx < ( m_hOtherPages.GetSize( ) ) ; ++idx )
  1486. {
  1487. hPage = *m_hOtherPages.GetAt( idx );
  1488. if( hPage != NULL )
  1489. {
  1490. PropSheet_RemovePage( GetParent( hDlg ) , 0 , hPage );
  1491. m_hOtherPages.SetAt( idx , NULL );
  1492. }
  1493. m_hOtherPages.DeleteArray( );
  1494. }
  1495. // remove final page
  1496. hPage= *m_pCompdata->m_hPages.GetAt( FIN_PAGE );
  1497. if( hPage != NULL )
  1498. {
  1499. PropSheet_RemovePage( GetParent( hDlg ) , 0 , hPage );
  1500. m_pCompdata->m_hPages.SetAt( FIN_PAGE , NULL );
  1501. }
  1502. return TRUE;
  1503. }
  1504. //-----------------------------------------------------------------------------
  1505. // Now include lanpage or async page or either and slapin citrix pages
  1506. //-----------------------------------------------------------------------------
  1507. BOOL CConProp::AddPages( HWND hwnd , int idx , LPTSTR szDriverName )
  1508. {
  1509. PROPSHEETPAGE psp;
  1510. ASSERT( szDriverName != NULL );
  1511. if( idx == LAN_PAGE )
  1512. {
  1513. if( *m_pCompdata->m_hPages.GetAt( LAN_PAGE ) == NULL )
  1514. {
  1515. m_pCompdata->m_pDlg[ LAN_PAGE ]->GetPropertySheetPage( psp );
  1516. m_pCompdata->m_hPages.SetAt( LAN_PAGE , CreatePropertySheetPage( &psp ) );
  1517. PropSheet_AddPage( GetParent( hwnd ) , *m_pCompdata->m_hPages.GetAt( LAN_PAGE ) );
  1518. }
  1519. }
  1520. else if( idx == ASYNC_PAGE )
  1521. {
  1522. if( *m_pCompdata->m_hPages.GetAt( ASYNC_PAGE ) == NULL )
  1523. {
  1524. m_pCompdata->m_pDlg[ ASYNC_PAGE ]->GetPropertySheetPage( psp );
  1525. m_pCompdata->m_hPages.SetAt( ASYNC_PAGE , CreatePropertySheetPage( &psp ) );
  1526. PropSheet_AddPage( GetParent( hwnd ) , *m_pCompdata->m_hPages.GetAt( ASYNC_PAGE ) );
  1527. }
  1528. }
  1529. // add thirdparty pages
  1530. ODS( L"Adding third party page\n" );
  1531. VERIFY_S( TRUE , InsertThirdPartyPages( szDriverName ) );
  1532. for( idx = 0 ; idx < ( m_hOtherPages.GetSize( ) ) ; ++idx )
  1533. {
  1534. HPROPSHEETPAGE hPage = *m_hOtherPages.GetAt( idx );
  1535. if( hPage != NULL )
  1536. {
  1537. PropSheet_AddPage( GetParent( hwnd ) , hPage );
  1538. m_hOtherPages.SetAt( idx , hPage );
  1539. }
  1540. }
  1541. if( *m_pCompdata->m_hPages.GetAt( FIN_PAGE ) == NULL )
  1542. {
  1543. m_pCompdata->m_pDlg[ FIN_PAGE ]->GetPropertySheetPage( psp );
  1544. m_pCompdata->m_hPages.SetAt( FIN_PAGE , CreatePropertySheetPage( &psp ) );
  1545. PropSheet_AddPage( GetParent( hwnd ) , *m_pCompdata->m_hPages.GetAt( FIN_PAGE ) );
  1546. return TRUE;
  1547. }
  1548. return FALSE;
  1549. }
  1550. //-----------------------------------------------------------------------------
  1551. BOOL CConProp::InsertThirdPartyPages( LPTSTR pszKey )
  1552. {
  1553. HKEY hKey;
  1554. TCHAR tchKey[ MAX_PATH ];
  1555. TCHAR tchCLSID[ 40 ];
  1556. CLSID clsidOther;
  1557. DWORD dwSize;
  1558. //LPEXTENDTSWIZARD pObj = NULL;
  1559. // make sure the key passed in is valid
  1560. if (pszKey == NULL)
  1561. return FALSE;
  1562. // make sure the key will fit in the buffer
  1563. if ( lstrlen(pszKey) + lstrlen(tchThirdPartyPath) >= MAX_PATH )
  1564. return FALSE;
  1565. lstrcpy( tchKey , tchThirdPartyPath );
  1566. lstrcat( tchKey , pszKey );
  1567. HRESULT hr = E_FAIL;
  1568. if( g_pObj != NULL )
  1569. {
  1570. g_pObj->Release( );
  1571. // we set this to NULL in case Cocreate fails we don't want to
  1572. // deference an interface that went away.
  1573. g_pObj = NULL;
  1574. }
  1575. do
  1576. {
  1577. if( RegOpenKey( HKEY_LOCAL_MACHINE , tchKey , &hKey ) != ERROR_SUCCESS )
  1578. {
  1579. ODS( L"CConProp::InsertThirdPartyPages RegOpenKey failed\n" );
  1580. break;
  1581. }
  1582. dwSize = sizeof( tchCLSID );
  1583. if( RegQueryValueEx( hKey , L"CLSID" , NULL , NULL , ( LPBYTE )&tchCLSID[ 0 ] , &dwSize ) != ERROR_SUCCESS )
  1584. {
  1585. ODS( L"CConProp::InsertThirdPartyPages RegQueryValueEx failed\n" );
  1586. break;
  1587. }
  1588. if( FAILED( CLSIDFromString( tchCLSID , &clsidOther ) ) )
  1589. {
  1590. ODS( L"CConProp::InsertThirdPartyPages CLSIDFromString failed\n" );
  1591. break;
  1592. }
  1593. if( FAILED( CoCreateInstance( clsidOther , NULL , CLSCTX_INPROC_SERVER , IID_IExtendTSWizard , ( LPVOID *) &g_pObj ) ) )
  1594. {
  1595. ODS( L"CConProp::InsertThirdPartyPages CoCreate failed\n" );
  1596. break;
  1597. }
  1598. if( FAILED( g_pObj->AddPages( ( LPWIZARDPROVIDER )this ) ) )
  1599. {
  1600. ODS( L"CConProp::InsertThirdPartyPages ExtWiz->Addpages failed\n" );
  1601. break;
  1602. }
  1603. if( FAILED( g_pObj->SetWinstationName( g_ws.Name ) ) )
  1604. {
  1605. ODS( L"CConProp::InsertThirdPartyPages ExtWiz->SetWinstationName failed\n" );
  1606. break;
  1607. }
  1608. hr = S_OK;
  1609. }while( 0 );
  1610. RegCloseKey( hKey );
  1611. if( FAILED( hr ) )
  1612. {
  1613. return FALSE;
  1614. }
  1615. return TRUE;
  1616. }
  1617. //-----------------------------------------------------------------------------
  1618. STDMETHODIMP CConProp::QueryInterface( REFIID riid , LPVOID *ppobj )
  1619. {
  1620. ODS( L"TSCC-WIZ CConProp QI--" );
  1621. if( riid == IID_IUnknown )
  1622. {
  1623. ODS( L"IUnknown" );
  1624. *ppobj = ( LPUNKNOWN )this;
  1625. }
  1626. else if( riid == IID_IWizardProvider )
  1627. {
  1628. ODS( L"IWizardProvider" );
  1629. *ppobj = ( IWizardProvider *)this;
  1630. }
  1631. else
  1632. {
  1633. DBGMSG( L"Interface not supported %x\n" , riid );
  1634. *ppobj = NULL;
  1635. return( E_NOINTERFACE );
  1636. }
  1637. AddRef( );
  1638. ODS( L"\n" );
  1639. return S_OK;
  1640. }
  1641. //-----------------------------------------------------------------------------
  1642. // For IWizardProvider
  1643. //-----------------------------------------------------------------------------
  1644. STDMETHODIMP_( ULONG ) CConProp::AddRef( )
  1645. {
  1646. return InterlockedIncrement( ( LPLONG )&m_cRef );
  1647. }
  1648. //-----------------------------------------------------------------------------
  1649. // For IWizardProvider
  1650. //-----------------------------------------------------------------------------
  1651. STDMETHODIMP_( ULONG ) CConProp::Release( )
  1652. {
  1653. if( InterlockedDecrement( ( LPLONG )&m_cRef ) == 0 )
  1654. {
  1655. //
  1656. // DONOT delete this
  1657. //
  1658. return 0;
  1659. }
  1660. return m_cRef;
  1661. }
  1662. //-----------------------------------------------------------------------------
  1663. // This is the call back function IExtendTSWizard will use to add pages to
  1664. // the array
  1665. //-----------------------------------------------------------------------------
  1666. STDMETHODIMP CConProp::AddPage( HPROPSHEETPAGE hPage )
  1667. {
  1668. if( m_hOtherPages.Insert( hPage ) > 0 )
  1669. {
  1670. return S_OK;
  1671. }
  1672. return E_FAIL;
  1673. }
  1674. //***********************************************************************************
  1675. CAsync::CAsync( CCompdata *pComdata )
  1676. {
  1677. m_pCompdata = pComdata;
  1678. }
  1679. //-----------------------------------------------------------------------------
  1680. BOOL CAsync::OnInitDialog( HWND hwnd , WPARAM wp , LPARAM lp )
  1681. {
  1682. UNREFERENCED_PARAMETER( wp );
  1683. UNREFERENCED_PARAMETER( lp );
  1684. UNREFERENCED_PARAMETER( hwnd );
  1685. ICfgComp *pCfgcomp = NULL;
  1686. BOOL bRet = TRUE;
  1687. if( m_pCompdata->GetServer( &pCfgcomp ) == 0 )
  1688. {
  1689. ODS( L"Wizard could obtain backend interface for CAsync\n" );
  1690. return FALSE;
  1691. }
  1692. // populate CAsyncDlg members
  1693. m_uc = g_uc;
  1694. pCfgcomp->GetAsyncConfig( g_ws.wdName , WdName , &m_ac );
  1695. pCfgcomp->Release( );
  1696. return bRet;
  1697. }
  1698. //-----------------------------------------------------------------------------
  1699. INT_PTR CALLBACK CAsync::DlgProc( HWND hwnd , UINT msg , WPARAM wp , LPARAM lp )
  1700. {
  1701. CAsync *pDlg;
  1702. if( msg == WM_INITDIALOG )
  1703. {
  1704. CAsync *pDlg = ( CAsync * )( ( PROPSHEETPAGE *)lp )->lParam ;
  1705. //
  1706. // Don't use a static pointer here
  1707. // There will be concurrency issues
  1708. //
  1709. SetWindowLongPtr( hwnd , DWLP_USER , ( LONG_PTR )pDlg );
  1710. if( !IsBadReadPtr( pDlg , sizeof( CAsync ) ) )
  1711. {
  1712. pDlg->OnInitDialog( hwnd , wp , lp );
  1713. }
  1714. return 0;
  1715. }
  1716. else
  1717. {
  1718. pDlg = ( CAsync * )GetWindowLongPtr( hwnd , DWLP_USER );
  1719. if( IsBadReadPtr( pDlg , sizeof( CAsync ) ) )
  1720. {
  1721. return FALSE;
  1722. }
  1723. }
  1724. switch( msg )
  1725. {
  1726. case WM_DESTROY:
  1727. pDlg->OnDestroy( );
  1728. break;
  1729. case WM_COMMAND:
  1730. pDlg->OnCommand( HIWORD( wp ) , LOWORD( wp ) , ( HWND )lp );
  1731. break;
  1732. case WM_NOTIFY:
  1733. pDlg->OnNotify( ( int )wp , ( LPNMHDR )lp , hwnd );
  1734. break;
  1735. }
  1736. return FALSE;
  1737. }
  1738. //-----------------------------------------------------------------------------
  1739. BOOL CAsync::GetPropertySheetPage( PROPSHEETPAGE& psp )
  1740. {
  1741. ZeroMemory( &psp , sizeof( PROPSHEETPAGE ) );
  1742. psp.dwSize = sizeof( PROPSHEETPAGE );
  1743. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  1744. psp.hInstance = _Module.GetResourceInstance( );
  1745. psp.pszTemplate = MAKEINTRESOURCE( IDD_ASYNC_WIZ );
  1746. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_HDR_ASYNC );
  1747. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBHDR_ASYNC );
  1748. psp.lParam = ( LPARAM )this;
  1749. psp.pfnDlgProc = CAsync::DlgProc;
  1750. return TRUE;
  1751. }
  1752. //-----------------------------------------------------------------------------
  1753. BOOL CAsync::OnDestroy( )
  1754. {
  1755. AsyncRelease( );
  1756. return CDialogWizBase::OnDestroy( );
  1757. }
  1758. //-----------------------------------------------------------------------------
  1759. BOOL CAsync::OnNotify( int idCtrl , LPNMHDR pnmh , HWND hDlg )
  1760. {
  1761. if( pnmh->code == PSN_WIZNEXT )
  1762. {
  1763. g_uc = m_uc;
  1764. g_ac = m_ac;
  1765. }
  1766. g_ws.PdClass = SdAsync;
  1767. if( pnmh->code == PSN_SETACTIVE )
  1768. {
  1769. ICfgComp * pCfgcomp = NULL;
  1770. if( m_pCompdata->GetServer( &pCfgcomp ) == 0 )
  1771. {
  1772. ODS( L"Wizard could obtain backend interface for CAsync\n" );
  1773. return FALSE;
  1774. }
  1775. BOOL bRet = CAsyncDlg::OnInitDialog( hDlg , g_ws.wdName , NULL , pCfgcomp ) ;
  1776. if(FALSE == bRet)
  1777. {
  1778. PropSheet_PressButton( GetParent(hDlg),PSBTN_BACK );
  1779. }
  1780. if(pCfgcomp)
  1781. {
  1782. pCfgcomp->Release();
  1783. }
  1784. }
  1785. return CDialogWizBase::OnNotify( idCtrl , pnmh , hDlg );
  1786. }
  1787. //-----------------------------------------------------------------------------
  1788. BOOL CAsync::OnCommand( WORD wNotifyCode , WORD wID , HWND hwndCtrl )
  1789. {
  1790. BOOL bDummy;
  1791. return CAsyncDlg::OnCommand( wNotifyCode , wID , hwndCtrl , &bDummy );
  1792. }
  1793. //***********************************************************************************
  1794. //-----------------------------------------------------------------------------
  1795. INT_PTR CALLBACK CFin::DlgProc( HWND hwnd , UINT msg , WPARAM wp , LPARAM lp )
  1796. {
  1797. CFin *pDlg;
  1798. if( msg == WM_INITDIALOG )
  1799. {
  1800. CFin *pDlg = ( CFin * )( ( PROPSHEETPAGE *)lp )->lParam ;
  1801. //
  1802. // Don't use a static pointer here
  1803. // There will be concurrency issues
  1804. //
  1805. SetWindowLongPtr( hwnd , DWLP_USER , ( LONG_PTR )pDlg );
  1806. if( !IsBadReadPtr( pDlg , sizeof( CFin ) ) )
  1807. {
  1808. pDlg->OnInitDialog( hwnd , wp , lp );
  1809. }
  1810. return 0;
  1811. }
  1812. else
  1813. {
  1814. pDlg = ( CFin * )GetWindowLongPtr( hwnd , DWLP_USER );
  1815. if( IsBadReadPtr( pDlg , sizeof( CFin ) ) )
  1816. {
  1817. return FALSE;
  1818. }
  1819. }
  1820. switch( msg )
  1821. {
  1822. case WM_DESTROY:
  1823. pDlg->OnDestroy( );
  1824. break;
  1825. case WM_NOTIFY:
  1826. pDlg->OnNotify( ( int )wp , ( LPNMHDR )lp , hwnd );
  1827. break;
  1828. }
  1829. return FALSE;
  1830. }
  1831. //-----------------------------------------------------------------------------
  1832. BOOL CFin::OnInitDialog( HWND hwnd , WPARAM wp , LPARAM lp )
  1833. {
  1834. UNREFERENCED_PARAMETER( wp );
  1835. UNREFERENCED_PARAMETER( lp );
  1836. LOGFONT lgfn;
  1837. int iFontSize;
  1838. TCHAR szFontSize[16];
  1839. ZeroMemory( &lgfn , sizeof( LOGFONT ) );
  1840. LoadString( _Module.GetResourceInstance( ) , IDS_VERDANABLDFONTSIZE , szFontSize , SIZE_OF_BUFFER(szFontSize) );
  1841. iFontSize = _ttoi( szFontSize );
  1842. HDC hdc = ::GetDC( NULL );
  1843. if( hdc != NULL )
  1844. {
  1845. lgfn.lfHeight = MulDiv( -iFontSize , GetDeviceCaps(hdc , LOGPIXELSY), 72);
  1846. LoadString( _Module.GetResourceInstance( ) , IDS_VERDANABLDFONTNAME , lgfn.lfFaceName , SIZE_OF_BUFFER(lgfn.lfFaceName) );
  1847. m_hFont = CreateFontIndirect( &lgfn );
  1848. ASSERT( m_hFont != NULL ); // let me know if we got it or not
  1849. SetWindowText( GetDlgItem(hwnd , IDC_CONNECTION_NAME ) ,g_ws.Name );
  1850. SendMessage( GetDlgItem( hwnd , IDC_STATIC_FINISH ) , WM_SETFONT , ( WPARAM )m_hFont , MAKELPARAM( TRUE , 0 ) );
  1851. ReleaseDC( NULL , hdc );
  1852. }
  1853. return FALSE;
  1854. }
  1855. //-----------------------------------------------------------------------------
  1856. BOOL CFin::OnDestroy( )
  1857. {
  1858. DeleteObject( m_hFont );
  1859. return CDialogWizBase::OnDestroy( );
  1860. }
  1861. //-----------------------------------------------------------------------------
  1862. BOOL CFin::GetPropertySheetPage( PROPSHEETPAGE& psp)
  1863. {
  1864. ZeroMemory( &psp , sizeof( PROPSHEETPAGE ) );
  1865. psp.dwSize = sizeof( PROPSHEETPAGE );
  1866. psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER;
  1867. psp.hInstance = _Module.GetResourceInstance( );
  1868. psp.pszTemplate = MAKEINTRESOURCE( IDD_FINISH );
  1869. psp.lParam = ( LPARAM )this;
  1870. psp.pfnDlgProc = CFin::DlgProc;
  1871. return TRUE;
  1872. }
  1873. //-----------------------------------------------------------------------------
  1874. BOOL CFin::OnNotify( int idCtrl , LPNMHDR pnmh , HWND hDlg )
  1875. {
  1876. UNREFERENCED_PARAMETER( idCtrl );
  1877. HRESULT hResult = S_OK;
  1878. if( pnmh->code == PSN_SETACTIVE )
  1879. {
  1880. PropSheet_SetWizButtons( GetParent( hDlg ) , PSWIZB_BACK | PSWIZB_FINISH );
  1881. }
  1882. else if( pnmh->code == PSN_WIZFINISH )
  1883. {
  1884. ICfgComp *pCfgcomp;
  1885. m_pCompdata->GetServer( &pCfgcomp );
  1886. //PSECURITY_DESCRIPTOR pSd;
  1887. //LONG lSdsize;
  1888. g_ws.fEnableWinstation = 1;
  1889. BOOL bUnique;
  1890. // verify that network adapter was not modified
  1891. // bugid 253896
  1892. if( SUCCEEDED( pCfgcomp->IsWSNameUnique( g_ws.Name , &bUnique ) ) )
  1893. {
  1894. if( !bUnique )
  1895. {
  1896. ErrMessage( hDlg , IDS_ERR_LANRECFG );
  1897. pCfgcomp->Release( );
  1898. return FALSE;
  1899. }
  1900. }
  1901. if(g_ws.PdClass == SdNetwork)
  1902. {
  1903. if( SUCCEEDED( pCfgcomp->IsNetWorkConnectionUnique( g_ws.wdName , g_ws.pdName , ( ULONG )g_ws.LanAdapter , &bUnique ) ) )
  1904. {
  1905. if( !bUnique )
  1906. {
  1907. ErrMessage( hDlg , IDS_ERR_LANRECFG );
  1908. pCfgcomp->Release( );
  1909. return FALSE;
  1910. }
  1911. }
  1912. }
  1913. TCHAR tchWdkey[ 80 ];
  1914. if( SUCCEEDED( pCfgcomp->GetWdKey( g_ws.wdName , tchWdkey ) ) )
  1915. {
  1916. WDCONFIG2 WdConfig;
  1917. ULONG ulByteCount;
  1918. if( RegWdQuery( NULL, tchWdkey, &WdConfig , sizeof( WDCONFIG2 ) , &ulByteCount ) == ERROR_SUCCESS )
  1919. {
  1920. g_uc.fAutoClientDrives = WdConfig.User.fAutoClientDrives;
  1921. g_uc.fAutoClientLpts = WdConfig.User.fAutoClientLpts;
  1922. g_uc.fDisableCam = WdConfig.User.fDisableCam;
  1923. g_uc.fDisableCcm = WdConfig.User.fDisableCcm;
  1924. g_uc.fDisableCdm = WdConfig.User.fDisableCdm;
  1925. g_uc.fDisableClip = WdConfig.User.fDisableClip;
  1926. g_uc.fDisableCpm = WdConfig.User.fDisableCpm;
  1927. g_uc.fDisableLPT = WdConfig.User.fDisableLPT;
  1928. g_uc.fInheritAutoClient = WdConfig.User.fInheritAutoClient;
  1929. g_uc.fForceClientLptDef = WdConfig.User.fForceClientLptDef;
  1930. g_uc.ColorDepth = WdConfig.User.ColorDepth;
  1931. }
  1932. else
  1933. {
  1934. ODS( L"TSCC:Holy cow our wdkeys were not copied going default\n" );
  1935. // Set default values for pages that were removed
  1936. // Logon setting
  1937. g_uc.fAutoClientLpts = 1;
  1938. //g_uc.fAutoClientDrives = 1;
  1939. g_uc.fDisableCcm = 1;
  1940. g_uc.fForceClientLptDef = 1;
  1941. }
  1942. }
  1943. g_uc.fInheritMaxSessionTime = 1;
  1944. g_uc.fInheritMaxDisconnectionTime = 1;
  1945. g_uc.fInheritMaxIdleTime = 1;
  1946. g_uc.fInheritResetBroken = 1;
  1947. g_uc.fInheritReconnectSame = 1;
  1948. // Environment
  1949. g_uc.fInheritInitialProgram = 1;
  1950. g_uc.fPromptForPassword = 1;
  1951. // Client Settings
  1952. g_uc.fWallPaperDisabled = 1;
  1953. g_uc.fInheritAutoLogon = 1;
  1954. // Disable cursor flash on servers
  1955. g_uc.fCursorBlinkDisabled = 1;
  1956. if(g_ws.PdClass == SdAsync)
  1957. {
  1958. ODS( L"TSCC : Async connection about to be configured\n" );
  1959. g_ws.uMaxInstanceCount = 1;
  1960. hResult = pCfgcomp->CreateNewWS( g_ws , sizeof( USERCONFIG ) , &g_uc , &g_ac) ;
  1961. }
  1962. else
  1963. {
  1964. hResult = pCfgcomp->CreateNewWS( g_ws , sizeof( USERCONFIG ) , &g_uc , NULL) ;
  1965. }
  1966. if( SUCCEEDED(hResult) )
  1967. {
  1968. ODS( L"New WS created\n" );
  1969. if( g_pObj != NULL )
  1970. {
  1971. ODS( L" calling finito\n" );
  1972. if( FAILED( g_pObj->Finito( ) ) )
  1973. {
  1974. ODS( L"TSCC : CFin::OnNotify@g_pObj failed final call\n" );
  1975. }
  1976. ODS( L"about to release object\n" );
  1977. g_pObj->Release( );
  1978. //g_pObj = NULL;
  1979. }
  1980. CResultNode *pResultNode = ( CResultNode * )new CResultNode( );
  1981. if( pResultNode != NULL )
  1982. {
  1983. pResultNode->SetConName( g_ws.Name , SIZE_OF_BUFFER( g_ws.Name ) );
  1984. pResultNode->SetTTName( g_ws.pdName , SIZE_OF_BUFFER( g_ws.pdName ) );
  1985. pResultNode->SetTypeName( g_ws.wdName , SIZE_OF_BUFFER( g_ws.wdName ) );
  1986. pResultNode->SetComment( g_ws.Comment , SIZE_OF_BUFFER( g_ws.Comment ) );
  1987. pResultNode->EnableConnection( g_ws.fEnableWinstation );
  1988. pResultNode->SetImageIdx( ( g_ws.fEnableWinstation ? 1 : 2 ) );
  1989. pResultNode->SetServer( pCfgcomp );
  1990. m_pCompdata->m_rnNodes.Insert( pResultNode );
  1991. }
  1992. if( g_nAsyncOrNetwork == ASYNC_PAGE )
  1993. {
  1994. WS *pWs;
  1995. LONG lSz;
  1996. TCHAR tchWrnBuf[ 256 ];
  1997. TCHAR tchOutput[ 512 ];
  1998. if( SUCCEEDED( pCfgcomp->GetWSInfo(g_ws.Name , &lSz , &pWs ) ) )
  1999. {
  2000. if( pWs->fEnableWinstation && pWs->PdClass == SdAsync )
  2001. {
  2002. ASYNCCONFIGW AsyncConfig;
  2003. HRESULT hResult = pCfgcomp->GetAsyncConfig(pWs->Name,WsName,&AsyncConfig);
  2004. if( SUCCEEDED( hResult ) )
  2005. {
  2006. if( AsyncConfig.ModemName[0] )
  2007. {
  2008. LoadString( _Module.GetResourceInstance( ) , IDS_REBOOT_REQD , tchOutput , SIZE_OF_BUFFER( tchOutput ) );
  2009. LoadString( _Module.GetResourceInstance( ) , IDS_WARN_TITLE , tchWrnBuf , SIZE_OF_BUFFER( tchWrnBuf ) );
  2010. MessageBox( hDlg , tchOutput , tchWrnBuf , MB_ICONWARNING | MB_OK );
  2011. }
  2012. }
  2013. }
  2014. CoTaskMemFree( pWs );
  2015. }
  2016. }
  2017. }
  2018. else
  2019. {
  2020. if( hResult == E_ACCESSDENIED )
  2021. {
  2022. TscAccessDeniedMsg( hDlg );
  2023. }
  2024. else
  2025. {
  2026. TscGeneralErrMsg( hDlg );
  2027. }
  2028. }
  2029. pCfgcomp->Release();
  2030. }
  2031. return TRUE;
  2032. }
  2033. //-----------------------------------------------------------------------------
  2034. CFin::CFin( CCompdata * pCompdata)
  2035. {
  2036. m_pCompdata = pCompdata;
  2037. }
  2038. //-----------------------------------------------------------------------------
  2039. void EnableGroup( HWND hParent , LPINT rgID , BOOL bEnable )
  2040. {
  2041. while( rgID && *rgID != ( DWORD )-1 )
  2042. {
  2043. EnableWindow( GetDlgItem( hParent , *rgID ) , bEnable );
  2044. rgID++;
  2045. }
  2046. }