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.

264 lines
8.1 KiB

  1. #include "Precomp.h"
  2. #include "resource.h"
  3. #include "global.h"
  4. #include "PropPg.h"
  5. //#include "SelTargt.h"
  6. #include "FileParm.h"
  7. #include "nmakwiz.h"
  8. ////////////////////////////////////////////////////////////////////////////////////////////////////
  9. // Static member vars
  10. /* static */ CDistributionSheet* CDistributionSheet::ms_pDistributionFileSheet = NULL;
  11. /* static */ int CDistributionSheet::ms_MaxDistributionFilePathLen;
  12. /* static */ TCHAR CDistributionSheet::ms_szOFNData[ MAX_PATH];
  13. ////////////////////////////////////////////////////////////////////////////////////////////////////
  14. // Static member fns
  15. INT_PTR CALLBACK CDistributionSheet::DlgProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) {
  16. switch( message )
  17. {
  18. case WM_INITDIALOG:
  19. {
  20. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_NEXT | PSWIZB_BACK );
  21. ms_pDistributionFileSheet->CreateFilePanes(hDlg);
  22. return TRUE;
  23. }
  24. case WM_COMMAND:
  25. {
  26. switch (GET_WM_COMMAND_ID(wParam, lParam))
  27. {
  28. case IDC_BUTTON_BROWSE_DISTRIBUTION_FILE_PATH:
  29. {
  30. switch (GET_WM_COMMAND_CMD(wParam, lParam))
  31. {
  32. case BN_CLICKED:
  33. {
  34. ms_pDistributionFileSheet->m_pDistroFilePane->QueryFilePath( );
  35. return TRUE;
  36. break;
  37. }
  38. }
  39. break;
  40. }
  41. case IDC_BUTTON_BROWSE_AUTO_CONFIG_PATH:
  42. {
  43. switch (GET_WM_COMMAND_CMD(wParam, lParam))
  44. {
  45. case BN_CLICKED:
  46. {
  47. ms_pDistributionFileSheet->m_pAutoFilePane->QueryFilePath( );
  48. return TRUE;
  49. break;
  50. }
  51. }
  52. break;
  53. }
  54. }
  55. break;
  56. }
  57. case WM_NOTIFY:
  58. {
  59. switch( reinterpret_cast< NMHDR FAR* >( lParam )->code )
  60. {
  61. case PSN_QUERYCANCEL:
  62. SetWindowLong( hDlg, DWL_MSGRESULT, !VerifyExitMessageBox());
  63. return TRUE;
  64. case PSN_SETACTIVE:
  65. g_hwndActive = hDlg;
  66. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_NEXT | PSWIZB_BACK );
  67. ms_pDistributionFileSheet->m_pDistroFilePane->Validate(FALSE);
  68. ms_pDistributionFileSheet->m_pAutoFilePane->Validate(FALSE);
  69. return TRUE;
  70. case PSN_WIZNEXT:
  71. // Distro
  72. if( !ms_pDistributionFileSheet->m_pDistroFilePane->Validate(TRUE) )
  73. {
  74. SetWindowLong( hDlg, DWL_MSGRESULT, -1 );
  75. return TRUE;
  76. }
  77. // AutoConf
  78. if( !ms_pDistributionFileSheet->m_pAutoFilePane->Validate(TRUE) )
  79. {
  80. SetWindowLong( hDlg, DWL_MSGRESULT, -1 );
  81. return TRUE;
  82. }
  83. if( ms_pDistributionFileSheet->m_pAutoFilePane->OptionEnabled() )
  84. {
  85. if( !Edit_GetTextLength(
  86. GetDlgItem( ms_pDistributionFileSheet->m_pAutoFilePane->GetHwnd(),
  87. IDC_AUTOCONF_URL ) ) )
  88. {
  89. NmrkMessageBox(MAKEINTRESOURCE(IDS_NEED_CONF_SERVER), NULL, MB_OK | MB_ICONWARNING );
  90. SetWindowLong( hDlg, DWL_MSGRESULT, -1 );
  91. return TRUE;
  92. }
  93. }
  94. else if( ms_pDistributionFileSheet->m_bHadAutoConf )
  95. {
  96. if( IDNO == NmrkMessageBox(MAKEINTRESOURCE(IDS_TURNING_OFF_AUTOCONF), NULL, MB_YESNO | MB_ICONWARNING ) )
  97. {
  98. ms_pDistributionFileSheet->m_pAutoFilePane->SetCheck( IDC_CHECK_AUTOCONFIG_CLIENTS, TRUE );
  99. SetWindowLong( hDlg, DWL_MSGRESULT, -1 );
  100. return TRUE;
  101. }
  102. else
  103. {
  104. ms_pDistributionFileSheet->m_pAutoFilePane->SetEditData( IDC_EDIT_AUTO_CONFIG_FILE_PATH, ms_pDistributionFileSheet->m_szLastLocation );
  105. ms_pDistributionFileSheet->m_bLastRoundUp = TRUE;
  106. }
  107. }
  108. return TRUE;
  109. }
  110. }
  111. default:
  112. break;
  113. }
  114. return FALSE;
  115. }
  116. ////////////////////////////////////////////////////////////////////////////////////////////////////
  117. // Member fns
  118. CDistributionSheet::CDistributionSheet( void )
  119. : m_PropertySheetPage( MAKEINTRESOURCE( IDD_PROPPAGE_DEFAULT ),
  120. CDistributionSheet::DlgProc /*,
  121. PSP_HASHELP */
  122. ),
  123. m_pDistroFilePane( NULL ), m_pAutoFilePane( NULL ), m_bHadAutoConf( FALSE ), m_bLastRoundUp( FALSE ), m_szLastLocation( NULL )
  124. {
  125. ZeroMemory( &m_ofn, sizeof( OPENFILENAME ) );
  126. ms_MaxDistributionFilePathLen = MAX_PATH;
  127. ms_pDistributionFileSheet = this;
  128. }
  129. CDistributionSheet::~CDistributionSheet( void )
  130. {
  131. delete m_pDistroFilePane;
  132. m_pDistroFilePane = NULL;
  133. delete m_pAutoFilePane;
  134. m_pAutoFilePane = NULL;
  135. delete [] m_szLastLocation;
  136. m_szLastLocation = NULL;
  137. ms_pDistributionFileSheet = NULL;
  138. }
  139. void CDistributionSheet::CreateFilePanes(HWND hWndDlg)
  140. {
  141. RECT rect;
  142. GetClientRect( hWndDlg, &rect );
  143. int iWidth = rect.right - CPropertyDataWindow2::mcs_iLeft;
  144. int iTop = CPropertyDataWindow2::mcs_iTop + CPropertyDataWindow2::mcs_iBorder;
  145. // The top panel is being given 1/3 of the vertical space
  146. int iHeight = MulDiv( rect.bottom, 1, 3 );
  147. m_pDistroFilePane = new CFilePanePropWnd2(hWndDlg,
  148. IDD_FILEPANE_DISTRO,
  149. TEXT("IDD_FILEPANE_DISTRO"),
  150. 0,
  151. CPropertyDataWindow2::mcs_iLeft,
  152. iTop,
  153. iWidth,
  154. iHeight );
  155. HWND hwndCond = GetDlgItem( m_pDistroFilePane->GetHwnd(), IDC_CHECK_CREATE_DISTRIBUTION );
  156. m_pDistroFilePane->ConnectControlsToCheck( IDC_CHECK_CREATE_DISTRIBUTION, 2,
  157. new CControlID( hwndCond,
  158. IDC_CHECK_CREATE_DISTRIBUTION,
  159. IDC_EDIT_DISTRIBUTION_FILE_PATH,
  160. CControlID::EDIT ),
  161. new CControlID( hwndCond,
  162. IDC_CHECK_CREATE_DISTRIBUTION,
  163. IDC_BUTTON_BROWSE_DISTRIBUTION_FILE_PATH,
  164. // Note this is not a check but I don't think I care
  165. CControlID::CHECK ) );
  166. m_pDistroFilePane->SetFilePane( FALSE, IDC_EDIT_DISTRIBUTION_FILE_PATH,
  167. IDC_CHECK_CREATE_DISTRIBUTION,
  168. IDC_BUTTON_BROWSE_DISTRIBUTION_FILE_PATH,
  169. TEXT( "Application (*.exe)" ),
  170. TEXT( ".exe" ),
  171. TEXT( "Nm3c.exe" ) );
  172. m_pDistroFilePane->SetCheck( IDC_CHECK_CREATE_DISTRIBUTION, TRUE );
  173. //iHeight = rect.bottom - iHeight;
  174. m_pAutoFilePane = new CFilePanePropWnd2(hWndDlg,
  175. IDD_FILEPANE_AUTOCONF,
  176. TEXT("IDD_FILEPANE_AUTOCONF"),
  177. 0,
  178. CPropertyDataWindow2::mcs_iLeft,
  179. iHeight,
  180. iWidth,
  181. rect.bottom - iHeight );
  182. hwndCond = GetDlgItem( m_pAutoFilePane->GetHwnd(), IDC_CHECK_AUTOCONFIG_CLIENTS );
  183. m_pAutoFilePane->ConnectControlsToCheck( IDC_CHECK_AUTOCONFIG_CLIENTS, 3,
  184. new CControlID( hwndCond,
  185. IDC_CHECK_AUTOCONFIG_CLIENTS,
  186. IDC_EDIT_AUTO_CONFIG_FILE_PATH,
  187. CControlID::EDIT ),
  188. new CControlID( hwndCond,
  189. IDC_CHECK_AUTOCONFIG_CLIENTS,
  190. IDC_AUTOCONF_URL,
  191. CControlID::EDIT ),
  192. new CControlID( hwndCond,
  193. IDC_CHECK_AUTOCONFIG_CLIENTS,
  194. IDC_BUTTON_BROWSE_AUTO_CONFIG_PATH,
  195. // Note this is not a check but I don't think I care
  196. CControlID::CHECK ) );
  197. m_pAutoFilePane->SetFilePane( FALSE, IDC_EDIT_AUTO_CONFIG_FILE_PATH,
  198. IDC_CHECK_AUTOCONFIG_CLIENTS,
  199. IDC_BUTTON_BROWSE_AUTO_CONFIG_PATH,
  200. TEXT( "Application Settings(*.inf)" ),
  201. TEXT( ".inf" ),
  202. TEXT( "nm3conf.inf" ) );
  203. m_pAutoFilePane->SetCheck( IDC_CHECK_AUTOCONFIG_CLIENTS, FALSE );
  204. if (g_pWiz->m_IntroSheet.GetFilePane()->OptionEnabled())
  205. {
  206. m_pDistroFilePane->ReadSettings();
  207. m_pAutoFilePane->ReadSettings();
  208. }
  209. if (m_bHadAutoConf = m_pAutoFilePane->OptionEnabled())
  210. {
  211. m_szLastLocation = new TCHAR[ MAX_PATH ];
  212. assert( m_szLastLocation );
  213. m_pAutoFilePane->GetPathAndFile( m_szLastLocation );
  214. }
  215. m_pAutoFilePane->ShowWindow( TRUE );
  216. m_pDistroFilePane->ShowWindow( TRUE );
  217. }