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.

510 lines
12 KiB

  1. //-------------------------------------------------------------------
  2. //
  3. // FILE: SecDlgs.cpp
  4. //
  5. // Summary;
  6. // This file contians the Secondary Dialogs,
  7. // functions and dialog procs
  8. //
  9. // Entry Points;
  10. //
  11. // History;
  12. // Nov-30-94 MikeMi Created
  13. // Mar-14-95 MikeMi Added F1 Message Filter and PWM_HELP message
  14. //
  15. //-------------------------------------------------------------------
  16. #include <windows.h>
  17. #include <htmlhelp.h>
  18. #include "resource.h"
  19. #include "liccpa.hpp"
  20. #include <strsafe.h>
  21. extern "C"
  22. {
  23. INT_PTR CALLBACK dlgprocLicViolation( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
  24. INT_PTR CALLBACK dlgprocCommon( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
  25. }
  26. // used to define dlg initialization using common dlgproc
  27. //
  28. enum DLG_TYPE
  29. {
  30. DLGTYPE_AGREEMENT_PERSEAT,
  31. DLGTYPE_AGREEMENT_PERSERVER,
  32. DLGTYPE_PERSEATSETUP,
  33. DLGTYPE_SERVERAPP
  34. };
  35. // used to pass info to a common dlgproc
  36. //
  37. typedef struct tagCOMMONDLGPARAM
  38. {
  39. LPWSTR pszDisplayName;
  40. DWORD dwLimit;
  41. LPWSTR pszHelpFile;
  42. DWORD dwHelpContext;
  43. DLG_TYPE dtType;
  44. } COMMONDLGPARAM, *PCOMMONDLGPARAM;
  45. //-------------------------------------------------------------------
  46. //
  47. // Function: dlgprocLicViolation
  48. //
  49. // Summary;
  50. // The dialog procedure for the Dialog
  51. //
  52. // Arguments;
  53. // hwndDlg [in] - handle of Dialog window
  54. // uMsg [in] - message
  55. // lParam1 [in] - first message parameter
  56. // lParam2 [in] - second message parameter
  57. //
  58. // Return;
  59. // message dependant
  60. //
  61. // Notes;
  62. //
  63. // History;
  64. // Dec-05-1994 MikeMi Created
  65. // Mar-14-95 MikeMi Added F1 PWM_HELP message
  66. //
  67. //-------------------------------------------------------------------
  68. INT_PTR CALLBACK dlgprocLicViolation( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
  69. {
  70. UNREFERENCED_PARAMETER(lParam);
  71. BOOL frt = FALSE;
  72. switch (uMsg)
  73. {
  74. case WM_INITDIALOG:
  75. CenterDialogToScreen( hwndDlg );
  76. frt = TRUE; // we use the default focus
  77. break;
  78. case WM_COMMAND:
  79. switch (HIWORD( wParam ))
  80. {
  81. case BN_CLICKED:
  82. switch (LOWORD( wParam ))
  83. {
  84. case IDCANCEL:
  85. frt = TRUE; // use as save flag
  86. // intentional no break
  87. case IDOK:
  88. EndDialog( hwndDlg, frt );
  89. frt = FALSE;
  90. break;
  91. case IDC_BUTTONHELP:
  92. PostMessage( hwndDlg, PWM_HELP, 0, 0 );
  93. break;
  94. default:
  95. break;
  96. }
  97. break;
  98. default:
  99. break;
  100. }
  101. break;
  102. default:
  103. if (PWM_HELP == uMsg)
  104. {
  105. ::HtmlHelp( hwndDlg, LICCPA_HTMLHELPFILE, HH_DISPLAY_TOPIC,0);
  106. }
  107. break;
  108. }
  109. return( frt );
  110. }
  111. //-------------------------------------------------------------------
  112. //
  113. // Function: OnCommonInitDialog
  114. //
  115. // Summary;
  116. // Handle the initialization of the Common Dialog
  117. //
  118. // Arguments;
  119. // hwndDlg [in] - the dialog to initialize
  120. // pcdParams [in] - used to get displayname, helpfile
  121. //
  122. // Notes;
  123. //
  124. // History;
  125. // Dec-05-1994 MikeMi Created
  126. //
  127. //-------------------------------------------------------------------
  128. void OnCommonInitDialog( HWND hwndDlg, PCOMMONDLGPARAM pcdParams )
  129. {
  130. HWND hwndOK = GetDlgItem( hwndDlg, IDOK );
  131. CenterDialogToScreen( hwndDlg );
  132. switch( pcdParams->dtType )
  133. {
  134. case DLGTYPE_AGREEMENT_PERSEAT:
  135. InitStaticWithService2( hwndDlg, IDC_STATICINFO, pcdParams->pszDisplayName );
  136. break;
  137. case DLGTYPE_AGREEMENT_PERSERVER:
  138. {
  139. WCHAR szText[LTEMPSTR_SIZE];
  140. WCHAR szTemp[LTEMPSTR_SIZE];
  141. GetDlgItemText( hwndDlg, IDC_STATICINFO, szTemp, LTEMPSTR_SIZE );
  142. //
  143. // need both service display name and number of conncurrent connections
  144. //
  145. HRESULT hr = StringCbPrintf( szText, sizeof(szText), szTemp,
  146. pcdParams->dwLimit,
  147. pcdParams->pszDisplayName );
  148. if (SUCCEEDED(hr))
  149. SetDlgItemText( hwndDlg, IDC_STATICINFO, szText );
  150. }
  151. break;
  152. case DLGTYPE_PERSEATSETUP:
  153. InitStaticWithService( hwndDlg, IDC_STATICTITLE, pcdParams->pszDisplayName );
  154. InitStaticWithService2( hwndDlg, IDC_STATICINFO, pcdParams->pszDisplayName );
  155. break;
  156. case DLGTYPE_SERVERAPP:
  157. break;
  158. default:
  159. break;
  160. }
  161. // disable OK button at start!
  162. EnableWindow( hwndOK, FALSE );
  163. // if help is not defined, remove the button
  164. if (NULL == pcdParams->pszHelpFile)
  165. {
  166. HWND hwndHelp = GetDlgItem( hwndDlg, IDC_BUTTONHELP );
  167. EnableWindow( hwndHelp, FALSE );
  168. ShowWindow( hwndHelp, SW_HIDE );
  169. }
  170. }
  171. //-------------------------------------------------------------------
  172. //
  173. // Function: OnCommonAgree
  174. //
  175. // Summary;
  176. // Handle user interaction with Agree check box
  177. //
  178. // Arguments;
  179. // hwndDlg [in] - the dialog that contains the check box
  180. //
  181. // Notes;
  182. //
  183. // History;
  184. // Dec-05-1994 MikeMi Created
  185. //
  186. //-------------------------------------------------------------------
  187. void OnCommonAgree( HWND hwndDlg )
  188. {
  189. HWND hwndOK = GetDlgItem( hwndDlg, IDOK );
  190. BOOL fChecked = !IsDlgButtonChecked( hwndDlg, IDC_AGREE );
  191. CheckDlgButton( hwndDlg, IDC_AGREE, fChecked );
  192. EnableWindow( hwndOK, fChecked );
  193. }
  194. //-------------------------------------------------------------------
  195. //
  196. // Function: dlgprocCommon
  197. //
  198. // Summary;
  199. // The dialog procedure for the Common legal Dialogs
  200. //
  201. // Arguments;
  202. // hwndDlg [in] - handle of Dialog window
  203. // uMsg [in] - message
  204. // lParam1 [in] - first message parameter
  205. // lParam2 [in] - second message parameter
  206. //
  207. // Return;
  208. // message dependant
  209. //
  210. // Notes;
  211. //
  212. // History;
  213. // Dec-05-1994 MikeMi Created
  214. // Mar-14-95 MikeMi Added F1 PWM_HELP message
  215. //
  216. //-------------------------------------------------------------------
  217. INT_PTR CALLBACK dlgprocCommon( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
  218. {
  219. BOOL frt = FALSE;
  220. static PCOMMONDLGPARAM pcdParams;
  221. switch (uMsg)
  222. {
  223. case WM_INITDIALOG:
  224. pcdParams = (PCOMMONDLGPARAM)lParam;
  225. OnCommonInitDialog( hwndDlg, pcdParams );
  226. frt = TRUE; // we use the default focus
  227. break;
  228. case WM_COMMAND:
  229. switch (HIWORD( wParam ))
  230. {
  231. case BN_CLICKED:
  232. switch (LOWORD( wParam ))
  233. {
  234. case IDOK:
  235. frt = TRUE; // use as save flag
  236. // intentional no break
  237. case IDCANCEL:
  238. EndDialog( hwndDlg, frt );
  239. frt = FALSE;
  240. break;
  241. case IDC_BUTTONHELP:
  242. PostMessage( hwndDlg, PWM_HELP, 0, 0 );
  243. break;
  244. case IDC_AGREE:
  245. OnCommonAgree( hwndDlg );
  246. break;
  247. default:
  248. break;
  249. }
  250. break;
  251. default:
  252. break;
  253. }
  254. break;
  255. default:
  256. if (PWM_HELP == uMsg)
  257. {
  258. ::HtmlHelp( hwndDlg, LICCPA_HTMLHELPFILE, HH_DISPLAY_TOPIC,0);
  259. }
  260. break;
  261. }
  262. return( frt );
  263. }
  264. //-------------------------------------------------------------------
  265. //
  266. // Function: LicviolationDialog
  267. //
  268. // Summary;
  269. // Init and Raise the license Violation dialog
  270. //
  271. // Arguments;
  272. // hwndParent [in] - handle of parent window
  273. //
  274. // Return;
  275. // 1 - use OK operation, NO was pressed to exit
  276. // 0 - use Cancel operation, YES was pressed to exit
  277. // -1 - General Dialog error
  278. //
  279. // Notes;
  280. //
  281. // History;
  282. // Dec-05-1994 MikeMi Created
  283. //
  284. //-------------------------------------------------------------------
  285. int LicViolationDialog( HWND hwndParent )
  286. {
  287. return( (int)DialogBox(g_hinst,
  288. MAKEINTRESOURCE(IDD_LICVIOLATIONDLG),
  289. hwndParent,
  290. dlgprocLicViolation ) );
  291. }
  292. //-------------------------------------------------------------------
  293. //
  294. // Function: SetupPerOnlyDialog
  295. //
  296. // Summary;
  297. // Init and Raise the setup for per seat only dialog
  298. //
  299. // Arguments;
  300. // hwndParent [in] - handle of parent window
  301. // pszDisplayName [in] - the service displayname
  302. // pszHelpFile [in] - the helpfile for the help button
  303. // dwHelpContext [in] - the help context for the help button
  304. //
  305. // Return;
  306. // 1 - OK button was used to exit
  307. // 0 - Cancel button was used to exit
  308. // -1 - General Dialog error
  309. //
  310. // Notes;
  311. //
  312. // History;
  313. // Dec-05-1994 MikeMi Created
  314. //
  315. //-------------------------------------------------------------------
  316. int SetupPerOnlyDialog( HWND hwndParent,
  317. LPCWSTR pszDisplayName,
  318. LPCWSTR pszHelpFile,
  319. DWORD dwHelpContext )
  320. {
  321. COMMONDLGPARAM dlgParam;
  322. dlgParam.pszDisplayName = (LPWSTR)pszDisplayName;
  323. dlgParam.pszHelpFile = (LPWSTR)pszHelpFile;
  324. dlgParam.dwHelpContext = dwHelpContext;
  325. dlgParam.dtType = DLGTYPE_PERSEATSETUP;
  326. return( (int)DialogBoxParam(g_hinst,
  327. MAKEINTRESOURCE(IDD_SETUP2DLG),
  328. hwndParent,
  329. dlgprocCommon,
  330. (LPARAM)&dlgParam) );
  331. }
  332. //-------------------------------------------------------------------
  333. //
  334. // Function: PerServerAgreementDialog
  335. //
  336. // Summary;
  337. // Init and Raise the per server legal dialog
  338. //
  339. // Arguments;
  340. // hwndParent [in] - handle of parent window
  341. // pszDisplayName [in] - the service displayname
  342. // dwLimit [in] - the number of concurrent connections
  343. // pszHelpFile [in] - the helpfile for the help button
  344. // dwHelpContext [in] - the help context for the help button
  345. //
  346. // Return;
  347. // 1 - OK button was used to exit
  348. // 0 - Cancel button was used to exit
  349. // -1 - General Dialog error
  350. //
  351. // Notes;
  352. //
  353. // History;
  354. // Dec-05-1994 MikeMi Created
  355. //
  356. //-------------------------------------------------------------------
  357. int PerServerAgreementDialog( HWND hwndParent,
  358. LPCWSTR pszDisplayName,
  359. DWORD dwLimit,
  360. LPCWSTR pszHelpFile,
  361. DWORD dwHelpContext )
  362. {
  363. COMMONDLGPARAM dlgParam;
  364. dlgParam.pszDisplayName = (LPWSTR)pszDisplayName;
  365. dlgParam.dwLimit = dwLimit;
  366. dlgParam.pszHelpFile = (LPWSTR)pszHelpFile;
  367. dlgParam.dwHelpContext = dwHelpContext;
  368. dlgParam.dtType = DLGTYPE_AGREEMENT_PERSERVER;
  369. return( (int)DialogBoxParam(g_hinst,
  370. MAKEINTRESOURCE(IDD_PERSERVERDLG),
  371. hwndParent,
  372. dlgprocCommon,
  373. (LPARAM)&dlgParam ) );
  374. }
  375. //-------------------------------------------------------------------
  376. //
  377. // Function: PerSeatAgreementDialog
  378. //
  379. // Summary;
  380. // Init and Raise the per seat legal dialog
  381. //
  382. // Arguments;
  383. // hwndParent [in] - handle of parent window
  384. // pszDisplayName [in] - the service displayname
  385. // pszHelpFile [in] - the helpfile for the help button
  386. // dwHelpContext [in] - the help context for the help button
  387. //
  388. // Return;
  389. // 1 - OK button was used to exit
  390. // 0 - Cancel button was used to exit
  391. // -1 - General Dialog error
  392. //
  393. // Notes;
  394. //
  395. // History;
  396. // Dec-05-1994 MikeMi Created
  397. //
  398. //-------------------------------------------------------------------
  399. int PerSeatAgreementDialog( HWND hwndParent,
  400. LPCWSTR pszDisplayName,
  401. LPCWSTR pszHelpFile,
  402. DWORD dwHelpContext )
  403. {
  404. COMMONDLGPARAM dlgParam;
  405. dlgParam.pszDisplayName = (LPWSTR)pszDisplayName;
  406. dlgParam.pszHelpFile = (LPWSTR)pszHelpFile;
  407. dlgParam.dwHelpContext = dwHelpContext;
  408. dlgParam.dtType = DLGTYPE_AGREEMENT_PERSEAT;
  409. return( (int)DialogBoxParam(g_hinst,
  410. MAKEINTRESOURCE(IDD_PERSEATDLG),
  411. hwndParent,
  412. dlgprocCommon,
  413. (LPARAM)&dlgParam ) );
  414. }
  415. //-------------------------------------------------------------------
  416. //
  417. // Function: ServerAppAgreementDialog
  418. //
  419. // Summary;
  420. // Init and Raise the Server and App legal dialog
  421. //
  422. // Arguments;
  423. // hwndParent [in] - handle of parent window
  424. // pszHelpFile [in] - the helpfile for the help button
  425. // dwHelpContext [in] - the help context for the help button
  426. //
  427. // Return;
  428. // 1 - OK button was used to exit
  429. // 0 - Cancel button was used to exit
  430. // -1 - General Dialog error
  431. //
  432. // Notes;
  433. //
  434. // History;
  435. // Dec-05-1994 MikeMi Created
  436. //
  437. //-------------------------------------------------------------------
  438. int ServerAppAgreementDialog( HWND hwndParent,
  439. LPCWSTR pszHelpFile,
  440. DWORD dwHelpContext )
  441. {
  442. COMMONDLGPARAM dlgParam;
  443. dlgParam.pszDisplayName = NULL;
  444. dlgParam.pszHelpFile = (LPWSTR)pszHelpFile;
  445. dlgParam.dwHelpContext = dwHelpContext;
  446. dlgParam.dtType = DLGTYPE_SERVERAPP;
  447. return( (int)DialogBoxParam(g_hinst,
  448. MAKEINTRESOURCE(IDD_SERVERAPPDLG),
  449. hwndParent,
  450. dlgprocCommon,
  451. (LPARAM)&dlgParam ) );
  452. }