Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

772 lines
23 KiB

  1. //Copyright (c) 1998 - 1999 Microsoft Corporation
  2. #include "precomp.h"
  3. #if !defined(_WIN32_WINNT)
  4. #define _WIN32_WINNT 0x0400
  5. #endif
  6. #include "wincrypt.h"
  7. #include "tlsapip.h"
  8. #include "lrwizapi.h"
  9. #include "wincrypt.h"
  10. #include "dlgproc.h"
  11. #include "propdlgs.h"
  12. #include "global.h"
  13. #include "utils.h"
  14. #define ACTIVATIONMETHOD_KEY "ACTIVATIONMETHOD"
  15. CGlobal *g_CGlobal = NULL;
  16. BOOL WINAPI DllMain (HANDLE hInst,ULONG ul_reason_for_call,LPVOID lpReserved)
  17. {
  18. switch(ul_reason_for_call)
  19. {
  20. case DLL_PROCESS_ATTACH:
  21. if (g_CGlobal == NULL)
  22. {
  23. g_CGlobal = new CGlobal;
  24. if (g_CGlobal == NULL)
  25. {
  26. return FALSE;
  27. }
  28. SetInstanceHandle((HINSTANCE)hInst);
  29. }
  30. break;
  31. case DLL_PROCESS_DETACH:
  32. if (g_CGlobal != NULL)
  33. {
  34. delete g_CGlobal;
  35. g_CGlobal = NULL;
  36. }
  37. break;
  38. default:
  39. break;
  40. }
  41. return TRUE;
  42. }
  43. DWORD
  44. IsLicenseServerRegistered(HWND hWndParent,
  45. LPCTSTR pszLSName,
  46. PDWORD pdwServerStatus)
  47. {
  48. DWORD dwRetCode = ERROR_SUCCESS;
  49. GetGlobalContext()->SetLSName(pszLSName);
  50. if (!GetGlobalContext()->IsLSRunning())
  51. {
  52. dwRetCode = LRWIZ_ERROR_LS_NOT_RUNNING;
  53. goto done;
  54. }
  55. dwRetCode = GetGlobalContext()->IsLicenseServerRegistered(pdwServerStatus);
  56. if (dwRetCode == ERROR_SUCCESS && *pdwServerStatus == LSERVERSTATUS_UNREGISTER &&
  57. GetGlobalContext()->IsOnlineCertRequestCreated())
  58. {
  59. *pdwServerStatus = LSERVERSTATUS_WAITFORPIN;
  60. }
  61. GetGlobalContext()->FreeGlobal();
  62. done:
  63. return dwRetCode;
  64. }
  65. DWORD
  66. GetConnectionType(HWND hWndParent,
  67. LPCTSTR pszLSName,
  68. WIZCONNECTION* pConnectionType)
  69. {
  70. DWORD dwRetCode = ERROR_SUCCESS;
  71. TCHAR lpBuffer[64];
  72. // *pConnectionType = GetGlobalContext()->GetActivationMethod();
  73. //
  74. // Connect to the given LS Registry & read the current ConnectionType.
  75. //
  76. GetGlobalContext()->SetLSName(pszLSName);
  77. GetGlobalContext()->GetFromRegistery(ACTIVATIONMETHOD_KEY, lpBuffer, TRUE);
  78. if (_tcslen(lpBuffer) != 0)
  79. {
  80. *pConnectionType = (WIZCONNECTION) _ttoi(lpBuffer);
  81. if (*pConnectionType == CONNECTION_FAX)
  82. *pConnectionType = CONNECTION_DEFAULT;
  83. }
  84. else
  85. {
  86. *pConnectionType = CONNECTION_DEFAULT;
  87. }
  88. GetGlobalContext()->FreeGlobal();
  89. return dwRetCode;
  90. }
  91. DWORD
  92. StartWizard(
  93. HWND hWndParent,
  94. WIZACTION WizAction,
  95. LPCTSTR pszLSName,
  96. PBOOL pbRefresh
  97. )
  98. {
  99. DWORD dwRetCode = LRWIZ_SUCCESS;
  100. BOOL bStatus = TRUE;
  101. PageInfo PageInfo = {0};
  102. PROPSHEETPAGE psp = {0};
  103. HPROPSHEETPAGE ahpsp[NO_OF_PAGES] = {0};
  104. PROPSHEETHEADER psh = {0};
  105. UINT i = 0;
  106. DWORD dwLSStatus = 0;
  107. GetGlobalContext()->SetWizAction(WizAction);
  108. GetGlobalContext()->SetLSName(pszLSName);
  109. if(!GetGlobalContext()->IsLSRunning())
  110. {
  111. LRMessageBox(hWndParent,IDS_ERR_LSCONNECT_FAILED);
  112. dwRetCode = LRWIZ_ERROR_LS_NOT_RUNNING;
  113. goto done;
  114. }
  115. dwRetCode = GetGlobalContext()->InitGlobal();
  116. if (dwRetCode != ERROR_SUCCESS)
  117. {
  118. LRMessageBox(hWndParent,dwRetCode,LRGetLastError());
  119. goto done;
  120. }
  121. dwRetCode = GetGlobalContext()->GetLSCertificates(&dwLSStatus);
  122. if (dwRetCode != ERROR_SUCCESS)
  123. {
  124. LRMessageBox(hWndParent,dwRetCode,LRGetLastError());
  125. goto done;
  126. }
  127. if (dwLSStatus == LSERVERSTATUS_UNREGISTER && GetGlobalContext()->IsOnlineCertRequestCreated())
  128. {
  129. dwLSStatus = LSERVERSTATUS_WAITFORPIN;
  130. }
  131. //
  132. // Show properties if WizAction is WIZACTION_SHOWPROPERTIES
  133. //
  134. if(WizAction == WIZACTION_SHOWPROPERTIES)
  135. {
  136. dwRetCode = ShowProperties(hWndParent);
  137. *pbRefresh = GetReFresh();
  138. return dwRetCode;
  139. }
  140. // verify the registry entries if the LS is already registered and the
  141. // connection method is Internet
  142. if ((GetGlobalContext()->GetActivationMethod() == CONNECTION_INTERNET ||
  143. GetGlobalContext()->GetActivationMethod() == CONNECTION_DEFAULT)
  144. && dwLSStatus == LSERVERSTATUS_REGISTER_INTERNET )
  145. {
  146. dwRetCode = GetGlobalContext()->CheckRequieredFields();
  147. if (dwRetCode != ERROR_SUCCESS)
  148. {
  149. LRMessageBox(hWndParent,dwRetCode,LRGetLastError());
  150. goto done;
  151. }
  152. }
  153. if (dwLSStatus == LSERVERSTATUS_WAITFORPIN)
  154. {
  155. GetGlobalContext()->SetWizAction(WIZACTION_CONTINUEREGISTERLS);
  156. }
  157. assert(dwLSStatus == LSERVERSTATUS_UNREGISTER ||
  158. dwLSStatus == LSERVERSTATUS_WAITFORPIN ||
  159. dwLSStatus == LSERVERSTATUS_REGISTER_INTERNET ||
  160. dwLSStatus == LSERVERSTATUS_REGISTER_OTHER);
  161. GetGlobalContext()->SetLSStatus(dwLSStatus);
  162. //Create All the pages here
  163. // New Welcome page which explains the process, etc.
  164. psp.dwSize = sizeof( psp );
  165. psp.hInstance = GetInstanceHandle();
  166. psp.lParam = (LPARAM)&PageInfo;
  167. psp.pfnDlgProc = WelcomeDlgProc;
  168. psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER;
  169. psp.pszTemplate = MAKEINTRESOURCE( IDD_WELCOME );
  170. ahpsp[PG_NDX_WELCOME] = CreatePropertySheetPage( &psp );
  171. // New page for choosing the Mode of Registration
  172. psp.dwSize = sizeof( psp );
  173. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  174. psp.hInstance = GetInstanceHandle();
  175. psp.lParam = (LPARAM)&PageInfo;
  176. psp.pfnDlgProc = GetModeDlgProc;
  177. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_TITLE20 );
  178. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBTITLE20 );
  179. psp.pszTemplate = MAKEINTRESOURCE( IDD_DLG_GETREGMODE );
  180. ahpsp[PG_NDX_GETREGMODE]= CreatePropertySheetPage( &psp );
  181. //
  182. //Customer Information(2) page for CA Request(Online/Offline)
  183. //
  184. memset(&psp,0,sizeof(psp));
  185. psp.dwSize = sizeof( psp );
  186. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  187. psp.hInstance = GetInstanceHandle();
  188. psp.lParam = (LPARAM)&PageInfo;
  189. psp.pfnDlgProc = ContactInfo1DlgProc;
  190. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_TITLE4 );
  191. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBTITLE4 );
  192. psp.pszTemplate = MAKEINTRESOURCE( IDD_CONTACTINFO1 );
  193. ahpsp[PG_NDX_CONTACTINFO1] = CreatePropertySheetPage( &psp );
  194. //
  195. //Customer Information(1) page for CA Request(Online/Offline)
  196. //
  197. memset(&psp,0,sizeof(psp));
  198. psp.dwSize = sizeof( psp );
  199. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  200. psp.hInstance = GetInstanceHandle();
  201. psp.lParam = (LPARAM)&PageInfo;
  202. psp.pfnDlgProc = ContactInfo2DlgProc;
  203. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_TITLE3 );
  204. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBTITLE3 );
  205. psp.pszTemplate = MAKEINTRESOURCE( IDD_CONTACTINFO2 );
  206. ahpsp[PG_NDX_CONTACTINFO2] = CreatePropertySheetPage( &psp );
  207. #ifdef XXX
  208. //
  209. //Processing Request page(Online)
  210. //
  211. memset(&psp,0,sizeof(psp));
  212. psp.dwSize = sizeof( psp );
  213. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  214. psp.hInstance = GetInstanceHandle();
  215. psp.lParam = (LPARAM)&PageInfo;
  216. psp.pfnDlgProc = ProcessingDlgProc;
  217. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_TITLE5 );
  218. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBTITLE5 );
  219. psp.pszTemplate = MAKEINTRESOURCE( IDD_PROCESSING );
  220. ahpsp[PG_NDX_PROCESSING] = CreatePropertySheetPage( &psp );
  221. #endif
  222. //
  223. //Registration Complete page for CA Request(Online/Offline)
  224. //
  225. memset(&psp,0,sizeof(psp));
  226. psp.dwSize = sizeof( psp );
  227. psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER;
  228. psp.hInstance = GetInstanceHandle();
  229. psp.lParam = (LPARAM)&PageInfo;
  230. psp.pfnDlgProc = ProgressDlgProc;
  231. psp.pszTemplate = MAKEINTRESOURCE( IDD_PROGRESS );
  232. ahpsp[PG_NDX_PROGRESS] = CreatePropertySheetPage( &psp );
  233. //
  234. //Certificate PIN page for CA Request(Online)
  235. //
  236. memset(&psp,0,sizeof(psp));
  237. psp.dwSize = sizeof( psp );
  238. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  239. psp.hInstance = GetInstanceHandle();
  240. psp.lParam = (LPARAM)&PageInfo;
  241. psp.pfnDlgProc = PINDlgProc;
  242. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_TITLE9 );
  243. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBTITLE9 );
  244. psp.pszTemplate = MAKEINTRESOURCE( IDD_DLG_PIN );
  245. ahpsp[PG_NDX_DLG_PIN] = CreatePropertySheetPage( &psp );
  246. //
  247. //Choose Program page for CH Request(Online/Offline)
  248. //
  249. memset(&psp,0,sizeof(psp));
  250. psp.dwSize = sizeof( psp );
  251. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  252. psp.hInstance = GetInstanceHandle();
  253. psp.lParam = (LPARAM)&PageInfo;
  254. psp.pfnDlgProc = CustInfoLicenseType;
  255. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_TITLE10 );
  256. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBTITLE10 );
  257. psp.pszTemplate = MAKEINTRESOURCE( IDD_LICENSETYPE );
  258. ahpsp[PG_NDX_CH_REGISTER_1] = CreatePropertySheetPage( &psp );
  259. //
  260. // Select Program & Client License Information page for CH Request(Online/Offline)
  261. //
  262. memset(&psp,0,sizeof(psp));
  263. psp.dwSize = sizeof( psp );
  264. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  265. psp.hInstance = GetInstanceHandle();
  266. psp.lParam = (LPARAM)&PageInfo;
  267. psp.pfnDlgProc = CHRegisterSelectDlgProc;
  268. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_TITLE11 );
  269. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBTITLE11 );
  270. psp.pszTemplate = MAKEINTRESOURCE( IDD_CH_REGISTER_SELECT);
  271. ahpsp[PG_NDX_CH_REGISTER_SELECT] = CreatePropertySheetPage( &psp );
  272. //
  273. //Molp Program & Client License Information page for CH Request(Online/Offline)
  274. //
  275. memset(&psp,0,sizeof(psp));
  276. psp.dwSize = sizeof( psp );
  277. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  278. psp.hInstance = GetInstanceHandle();
  279. psp.lParam = (LPARAM)&PageInfo;
  280. psp.pfnDlgProc = CHRegisterMOLPDlgProc;
  281. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_TITLE12 );
  282. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBTITLE12 );
  283. psp.pszTemplate = MAKEINTRESOURCE( IDD_CH_REGISTER_MOLP);
  284. ahpsp[PG_NDX_CH_REGISTER_MOLP] = CreatePropertySheetPage( &psp );
  285. //
  286. // Options after registering
  287. //
  288. memset(&psp,0,sizeof(psp));
  289. psp.dwSize = sizeof( psp );
  290. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  291. psp.hInstance = GetInstanceHandle();
  292. psp.lParam = (LPARAM)&PageInfo;
  293. psp.pfnDlgProc = ContinueReg;
  294. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_TITLE18 );
  295. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBTITLE18 );
  296. psp.pszTemplate = MAKEINTRESOURCE( IDD_CONTINUEREG );
  297. ahpsp[PG_NDX_CONTINUEREG] = CreatePropertySheetPage( &psp );
  298. // New Dialog Box to complete the Telephone Registration
  299. memset(&psp,0,sizeof(psp));
  300. psp.dwSize = sizeof( psp );
  301. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  302. psp.hInstance = GetInstanceHandle();
  303. psp.lParam = (LPARAM)&PageInfo;
  304. psp.pfnDlgProc = TelRegProc;
  305. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_TITLE19 );
  306. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBTITLE19 );
  307. psp.pszTemplate = MAKEINTRESOURCE( IDD_DLG_TELREG);
  308. ahpsp[PG_NDX_TELREG] = CreatePropertySheetPage( &psp );
  309. // New Dialog Box to complete the Telephone LKP stuff
  310. memset(&psp,0,sizeof(psp));
  311. psp.dwSize = sizeof( psp );
  312. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  313. psp.hInstance = GetInstanceHandle();
  314. psp.lParam = (LPARAM)&PageInfo;
  315. psp.pfnDlgProc = TelLKPProc;
  316. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_TITLE21 );
  317. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBTITLE21 );
  318. psp.pszTemplate = MAKEINTRESOURCE( IDD_DLG_TELLKP);
  319. ahpsp[PG_NDX_TELLKP] = CreatePropertySheetPage( &psp );
  320. // New Dialog Box to complete the Retail SPK Implementation
  321. memset(&psp,0,sizeof(psp));
  322. psp.dwSize = sizeof( psp );
  323. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  324. psp.hInstance = GetInstanceHandle();
  325. psp.lParam = (LPARAM)&PageInfo;
  326. psp.pfnDlgProc = RetailSPKProc;
  327. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_TITLE22 );
  328. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBTITLE22 );
  329. psp.pszTemplate = MAKEINTRESOURCE( IDD_DLG_RETAILSPK );
  330. ahpsp[PG_NDX_RETAILSPK] = CreatePropertySheetPage( &psp );
  331. // New Dialog Box to complete the Cert Log Infor (before re-issuing/revoking certs)
  332. memset(&psp,0,sizeof(psp));
  333. psp.dwSize = sizeof( psp );
  334. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  335. psp.hInstance = GetInstanceHandle();
  336. psp.lParam = (LPARAM)&PageInfo;
  337. psp.pfnDlgProc = CertLogProc;
  338. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_TITLE24 );
  339. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBTITLE24 );
  340. psp.pszTemplate = MAKEINTRESOURCE( IDD_DLG_CERTLOG_INFO );
  341. ahpsp[PG_NDX_CERTLOG] = CreatePropertySheetPage( &psp );
  342. // Telephone Revocation
  343. memset(&psp,0,sizeof(psp));
  344. psp.dwSize = sizeof( psp );
  345. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  346. psp.hInstance = GetInstanceHandle();
  347. psp.lParam = (LPARAM)&PageInfo;
  348. psp.pfnDlgProc = ConfRevokeProc;
  349. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_TITLE25 );
  350. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBTITLE25 );
  351. psp.pszTemplate = MAKEINTRESOURCE( IDD_DLG_CONFREVOKE );
  352. ahpsp[PG_NDX_CONFREVOKE] = CreatePropertySheetPage( &psp );
  353. // Telephone re-issue
  354. memset(&psp,0,sizeof(psp));
  355. psp.dwSize = sizeof( psp );
  356. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  357. psp.hInstance = GetInstanceHandle();
  358. psp.lParam = (LPARAM)&PageInfo;
  359. psp.pfnDlgProc = TelReissueProc;
  360. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_TITLE26 );
  361. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBTITLE26 );
  362. psp.pszTemplate = MAKEINTRESOURCE( IDD_DLG_TELREG_REISSUE );
  363. ahpsp[PG_NDX_TELREG_REISSUE] = CreatePropertySheetPage( &psp );
  364. // Telephone Country/Region
  365. memset(&psp,0,sizeof(psp));
  366. psp.dwSize = sizeof( psp );
  367. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  368. psp.hInstance = GetInstanceHandle();
  369. psp.lParam = (LPARAM)&PageInfo;
  370. psp.pfnDlgProc = CountryRegionProc;
  371. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_TITLE27 );
  372. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBTITLE27 );
  373. psp.pszTemplate = MAKEINTRESOURCE( IDD_DLG_COUNTRYREGION );
  374. ahpsp[PG_NDX_COUNTRYREGION] = CreatePropertySheetPage( &psp );
  375. // WWW Registration
  376. memset(&psp,0,sizeof(psp));
  377. psp.dwSize = sizeof( psp );
  378. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  379. psp.hInstance = GetInstanceHandle();
  380. psp.lParam = (LPARAM)&PageInfo;
  381. psp.pfnDlgProc = WWWRegProc;
  382. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_TITLE28 );
  383. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBTITLE28 );
  384. psp.pszTemplate = MAKEINTRESOURCE( IDD_DLG_WWWREG);
  385. ahpsp[PG_NDX_WWWREG] = CreatePropertySheetPage( &psp );
  386. // WWW LKP Download
  387. memset(&psp,0,sizeof(psp));
  388. psp.dwSize = sizeof( psp );
  389. psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  390. psp.hInstance = GetInstanceHandle();
  391. psp.lParam = (LPARAM)&PageInfo;
  392. psp.pfnDlgProc = WWWLKPProc;
  393. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_TITLE29 );
  394. psp.pszHeaderSubTitle = MAKEINTRESOURCE( IDS_SUBTITLE29 );
  395. psp.pszTemplate = MAKEINTRESOURCE( IDD_DLG_WWWLKP);
  396. ahpsp[PG_NDX_WWWLKP] = CreatePropertySheetPage( &psp );
  397. psh.dwFlags = PSH_WIZARD | PSH_WIZARD97 | PSH_WATERMARK | PSH_HEADER;
  398. //psh.pszbmWatermark = 0;
  399. //psh.pszbmHeader = 0;
  400. psh.pszbmWatermark = MAKEINTRESOURCE(IDB_CLIENT_CONN);
  401. psh.pszbmHeader = MAKEINTRESOURCE(IDB_CLIENT_CONN_HDR);
  402. psh.dwSize = sizeof( psh );
  403. psh.hInstance = GetInstanceHandle();
  404. psh.hwndParent = hWndParent;
  405. psh.pszCaption = MAKEINTRESOURCE( IDS_TITLE );
  406. psh.phpage = ahpsp;
  407. psh.nStartPage = 0;
  408. psh.nPages = NO_OF_PAGES;
  409. PageInfo.TotalPages = NO_OF_PAGES;
  410. //
  411. // Create the bold fonts.
  412. //
  413. SetupFonts( GetInstanceHandle(), NULL, &PageInfo.hBigBoldFont, &PageInfo.hBoldFont );
  414. //
  415. // Validate all the pages.
  416. //
  417. for(i = 0; i < NO_OF_PAGES; i++ )
  418. {
  419. if( ahpsp[i] == 0 )
  420. {
  421. bStatus = FALSE;
  422. }
  423. }
  424. //
  425. // Display the wizard.
  426. //
  427. if( bStatus )
  428. {
  429. if( PropertySheet( &psh ) == -1 )
  430. {
  431. bStatus = FALSE;
  432. }
  433. }
  434. if( !bStatus )
  435. {
  436. //
  437. // Manually destroy the pages if something failed.
  438. //
  439. for(i = 0; i < psh.nPages; i++)
  440. {
  441. if( ahpsp[i] )
  442. {
  443. DestroyPropertySheetPage( ahpsp[i] );
  444. }
  445. }
  446. }
  447. //
  448. // Destroy the fonts that were created.
  449. //
  450. DestroyFonts( PageInfo.hBigBoldFont, PageInfo.hBoldFont );
  451. done:
  452. if(!bStatus)
  453. {
  454. LRMessageBox(hWndParent,IDS_ERR_CREATE_FAILED);
  455. dwRetCode = LRWIZ_ERROR_CREATE_FAILED;
  456. }
  457. if (dwRetCode == 0 || dwRetCode == LRWIZ_SUCCESS)
  458. {
  459. *pbRefresh = GetReFresh();
  460. }
  461. GetGlobalContext()->FreeGlobal();
  462. return dwRetCode;
  463. }
  464. VOID
  465. SetControlFont(
  466. IN HFONT hFont,
  467. IN HWND hwnd,
  468. IN INT nId
  469. )
  470. {
  471. if( hFont )
  472. {
  473. HWND hwndControl = GetDlgItem(hwnd, nId);
  474. if( hwndControl )
  475. {
  476. SetWindowFont(hwndControl, hFont, TRUE);
  477. }
  478. }
  479. }
  480. VOID
  481. SetupFonts(
  482. IN HINSTANCE hInstance,
  483. IN HWND hwnd,
  484. IN HFONT *pBigBoldFont,
  485. IN HFONT *pBoldFont
  486. )
  487. {
  488. //
  489. // Create the fonts we need based on the dialog font
  490. //
  491. NONCLIENTMETRICS ncm = {0};
  492. ncm.cbSize = sizeof(ncm);
  493. SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
  494. LOGFONT BigBoldLogFont = ncm.lfMessageFont;
  495. LOGFONT BoldLogFont = ncm.lfMessageFont;
  496. //
  497. // Create Big Bold Font and Bold Font
  498. //
  499. BigBoldLogFont.lfWeight = FW_BOLD;
  500. BoldLogFont.lfWeight = FW_BOLD;
  501. TCHAR FontSizeString[MAX_PATH];
  502. INT FontSize;
  503. //
  504. // Load size and name from resources, since these may change
  505. // from locale to locale based on the size of the system font, etc.
  506. //
  507. if(!LoadString(hInstance,IDS_LARGEFONTNAME,BigBoldLogFont.lfFaceName,LF_FACESIZE))
  508. {
  509. lstrcpy(BigBoldLogFont.lfFaceName,TEXT("MS Shell Dlg"));
  510. }
  511. if(LoadString(hInstance,IDS_LARGEFONTSIZE,FontSizeString,sizeof(FontSizeString)/sizeof(TCHAR)))
  512. {
  513. FontSize = _tcstoul( FontSizeString, NULL, 10 );
  514. }
  515. else
  516. {
  517. FontSize = 12;
  518. }
  519. HDC hdc = GetDC( hwnd );
  520. if( hdc )
  521. {
  522. BigBoldLogFont.lfHeight = 0 - (GetDeviceCaps(hdc,LOGPIXELSY) * FontSize / 72);
  523. *pBigBoldFont = CreateFontIndirect(&BigBoldLogFont);
  524. *pBoldFont = CreateFontIndirect(&BoldLogFont);
  525. ReleaseDC(hwnd,hdc);
  526. }
  527. }
  528. VOID
  529. DestroyFonts(
  530. IN HFONT hBigBoldFont,
  531. IN HFONT hBoldFont
  532. )
  533. {
  534. if( hBigBoldFont )
  535. {
  536. DeleteObject( hBigBoldFont );
  537. }
  538. if( hBoldFont )
  539. {
  540. DeleteObject( hBoldFont );
  541. }
  542. }
  543. DWORD ShowProperties(HWND hWndParent)
  544. {
  545. DWORD dwRetCode = ERROR_SUCCESS;
  546. BOOL bStatus = TRUE;
  547. PROPSHEETPAGE psp = {0};
  548. HPROPSHEETPAGE ahpsp[NO_OF_PROP_PAGES] = {0};
  549. PROPSHEETHEADER psh = {0};
  550. UINT i = 0;
  551. //
  552. //Create All the pages here
  553. //
  554. // Registration Mode Page
  555. memset(&psp,0,sizeof(psp));
  556. psp.dwSize = sizeof( psp );
  557. psp.dwFlags = PSP_DEFAULT | PSP_USETITLE | PSP_PREMATURE ;
  558. psp.hInstance = GetInstanceHandle();
  559. psp.lParam = NULL;
  560. psp.pfnDlgProc = PropModeDlgProc;
  561. psp.pszTitle = MAKEINTRESOURCE( IDS_TITLE36 );
  562. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_TITLE36 );
  563. psp.pszTemplate = MAKEINTRESOURCE( IDD_DLG_PROP_MODE);
  564. ahpsp[PG_NDX_PROP_MODE]= CreatePropertySheetPage( &psp );
  565. //Program Type Page
  566. memset(&psp,0,sizeof(psp));
  567. psp.dwSize = sizeof( psp );
  568. psp.dwFlags = PSP_DEFAULT | PSP_USETITLE | PSP_PREMATURE;
  569. psp.hInstance = GetInstanceHandle();
  570. psp.lParam = NULL;
  571. psp.pfnDlgProc = PropProgramDlgProc;
  572. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_TITLE37 );
  573. psp.pszTitle = MAKEINTRESOURCE( IDS_TITLE37 );
  574. psp.pszTemplate = MAKEINTRESOURCE( IDD_DLG_PROP_PROGRAM);
  575. ahpsp[PG_NDX_PROP_PROGRAM] = CreatePropertySheetPage( &psp );
  576. // Customer Information (I) page
  577. memset(&psp,0,sizeof(psp));
  578. psp.dwSize = sizeof( psp );
  579. psp.dwFlags = PSP_DEFAULT | PSP_USETITLE | PSP_PREMATURE;
  580. psp.hInstance = GetInstanceHandle();
  581. psp.lParam = NULL;
  582. psp.pfnDlgProc = PropCustInfoADlgProc;
  583. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_TITLE38 );
  584. psp.pszTitle = MAKEINTRESOURCE( IDS_TITLE38 );
  585. psp.pszTemplate = MAKEINTRESOURCE( IDD_DLG_PROP_CUSTINFO_a);
  586. ahpsp[PG_NDX_PROP_CUSTINFO_a] = CreatePropertySheetPage( &psp );
  587. // Customer Information (II) page
  588. memset(&psp,0,sizeof(psp));
  589. psp.dwSize = sizeof( psp );
  590. psp.dwFlags = PSP_DEFAULT | PSP_USETITLE | PSP_PREMATURE;
  591. psp.hInstance = GetInstanceHandle();
  592. psp.lParam = NULL;
  593. psp.pfnDlgProc = PropCustInfoBDlgProc;
  594. psp.pszHeaderTitle = MAKEINTRESOURCE( IDS_TITLE39 );
  595. psp.pszTitle = MAKEINTRESOURCE( IDS_TITLE39 );
  596. psp.pszTemplate = MAKEINTRESOURCE( IDD_DLG_PROP_CUSTINFO_b);
  597. ahpsp[PG_NDX_PROP_CUSTINFO_b] = CreatePropertySheetPage( &psp );
  598. psh.dwFlags = PSH_DEFAULT | PSH_PROPTITLE | PSH_NOAPPLYNOW| PSH_NOCONTEXTHELP;
  599. psh.dwSize = sizeof( psh );
  600. psh.hInstance = GetInstanceHandle();
  601. psh.hwndParent = hWndParent;
  602. psh.pszCaption = MAKEINTRESOURCE( IDS_TITLE );
  603. psh.phpage = ahpsp;
  604. psh.nStartPage = 0;
  605. psh.nPages = NO_OF_PROP_PAGES;
  606. //
  607. // Validate all the pages.
  608. //
  609. for( i = 0; i < NO_OF_PROP_PAGES; i++ )
  610. {
  611. if( ahpsp[i] == 0 )
  612. {
  613. bStatus = FALSE;
  614. }
  615. }
  616. //
  617. // Display the wizard.
  618. //
  619. if( bStatus )
  620. {
  621. if( PropertySheet( &psh ) == -1 )
  622. {
  623. bStatus = FALSE;
  624. }
  625. }
  626. if( !bStatus )
  627. {
  628. //
  629. // Manually destroy the pages if something failed.
  630. //
  631. for(i = 0; i < psh.nPages; i++)
  632. {
  633. if( ahpsp[i] )
  634. {
  635. DestroyPropertySheetPage( ahpsp[i] );
  636. }
  637. }
  638. }
  639. if(!bStatus)
  640. {
  641. LRMessageBox(hWndParent,IDS_ERR_CREATE_FAILED);
  642. dwRetCode = LRWIZ_ERROR_CREATE_FAILED;
  643. }
  644. return dwRetCode;
  645. }