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.

2792 lines
118 KiB

  1. //***************************************************************************
  2. //* Copyright (c) Microsoft Corporation 1995. All rights reserved. *
  3. //***************************************************************************
  4. //* *
  5. //* PAGEFCNS.C - *
  6. //* *
  7. //***************************************************************************
  8. // MODIFYORCREATE page should have a button to 'quick display' CDF file
  9. //***************************************************************************
  10. //* INCLUDE FILES *
  11. //***************************************************************************
  12. #include "pch.h"
  13. #pragma hdrstop
  14. #include "cabpack.h"
  15. #include "sdsutils.h"
  16. void SetFontForControl(HWND hwnd, UINT uiID);
  17. //***************************************************************************
  18. //* GLOBAL VARIABLES *
  19. //***************************************************************************
  20. CDF g_CDF = { 0 }; // Generally, these are settings that
  21. // will be stored in the CABPack
  22. // Directive File.
  23. BOOL g_fFinish = FALSE;
  24. char g_szInitialDir[MAX_PATH];
  25. extern HFONT g_hFont;
  26. extern PSTR pResvSizes[];
  27. extern HINSTANCE g_hInst; // Pointer to Instance
  28. //###########################################################################
  29. //# ####################################################
  30. //# WELCOME PAGE ####################################################
  31. //# ####################################################
  32. //###########################################################################
  33. //***************************************************************************
  34. //* *
  35. //* NAME: WelcomeInit *
  36. //* *
  37. //* SYNOPSIS: Called when this page is displayed. *
  38. //* *
  39. //* REQUIRES: hDlg: Dialog window *
  40. //* fFirstInit: TRUE if this is the first time the dialog is *
  41. //* initialized, FALSE if this InitProc has been *
  42. //* called before (e.g. went past this page and *
  43. //* backed up). *
  44. //* *
  45. //* RETURNS: BOOL: Always TRUE *
  46. //* *
  47. //***************************************************************************
  48. BOOL WelcomeInit( HWND hDlg, BOOL fFirstInit )
  49. {
  50. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_NEXT );
  51. SetFontForControl(hDlg, IDC_EDIT_OPEN_CDF);
  52. if ( fFirstInit )
  53. {
  54. if ( lstrlen( g_CDF.achFilename ) > 0 ) {
  55. CheckDlgButton( hDlg, IDC_RAD_CREATE_NEW, FALSE );
  56. CheckDlgButton( hDlg, IDC_RAD_OPEN_EXISTING, TRUE );
  57. SetDlgItemText( hDlg, IDC_EDIT_OPEN_CDF, g_CDF.achFilename );
  58. } else {
  59. CheckDlgButton( hDlg, IDC_RAD_CREATE_NEW, TRUE );
  60. CheckDlgButton( hDlg, IDC_RAD_OPEN_EXISTING, FALSE );
  61. EnableDlgItem( hDlg, IDC_EDIT_OPEN_CDF, FALSE );
  62. EnableDlgItem( hDlg, IDC_BUT_BROWSE, FALSE );
  63. }
  64. }
  65. // Initialize the CABPack Directive File information.
  66. g_CDF.fSave = TRUE;
  67. g_CDF.uShowWindow = bResShowDefault;
  68. g_CDF.uPackPurpose = IDC_CMD_RUNCMD;
  69. g_CDF.dwReboot |= REBOOT_YES;
  70. g_CDF.szCompressionType = achMSZIP;
  71. g_CDF.uCompressionLevel = 7;
  72. lstrcpy( g_CDF.szCabLabel, CAB_DEFSETUPMEDIA );
  73. lstrcpy( g_CDF.achSourceFile, KEY_FILELIST );
  74. // g_CDF.wSortOrder = _SORT_DESCENDING | _SORT_FILENAME;
  75. // prepare for the GetOpenFileName init dir
  76. GetCurrentDirectory( sizeof(g_szInitialDir), g_szInitialDir );
  77. DeleteAllItems();
  78. return TRUE;
  79. }
  80. //***************************************************************************
  81. //* *
  82. //* NAME: WelcomeCmd *
  83. //* *
  84. //* SYNOPSIS: Called when dialog control pressed on page. *
  85. //* *
  86. //* REQUIRES: hDlg: Dialog window *
  87. //* uCtrlID: Control ID of control that was touched *
  88. //* pfGotoPage: If TRUE, goto the page puNextPage *
  89. //* puNextPage: Proc can fill this with next page to go to *
  90. //* pfKeepHistory: Page will not be kept in history if proc *
  91. //* fills this in with FALSE. *
  92. //* *
  93. //* RETURNS: BOOL: *
  94. //* *
  95. //***************************************************************************
  96. BOOL WelcomeCmd( HWND hDlg, UINT uCtrlID, BOOL *pfGotoPage, UINT *puNextPage,
  97. BOOL *pfKeepHistory )
  98. {
  99. CHAR achFilename[MAX_PATH] = { '\0' };
  100. BOOL fResult;
  101. switch ( uCtrlID ) {
  102. case IDC_RAD_OPEN_EXISTING:
  103. EnableDlgItem( hDlg, IDC_EDIT_OPEN_CDF, TRUE );
  104. EnableDlgItem( hDlg, IDC_BUT_BROWSE, TRUE );
  105. break;
  106. case IDC_RAD_CREATE_NEW:
  107. EnableDlgItem( hDlg, IDC_EDIT_OPEN_CDF, FALSE );
  108. EnableDlgItem( hDlg, IDC_BUT_BROWSE, FALSE );
  109. break;
  110. case IDC_BUT_BROWSE:
  111. fResult = MyOpen( hDlg, IDS_FILTER_CDF,
  112. achFilename, sizeof(achFilename), 0,
  113. NULL, NULL, EXT_SED_NODOT );
  114. if ( fResult ) {
  115. SetDlgItemText( hDlg, IDC_EDIT_OPEN_CDF, achFilename );
  116. }
  117. break;
  118. }
  119. return TRUE;
  120. }
  121. //***************************************************************************
  122. //* *
  123. //* NAME: WelcomeOK *
  124. //* *
  125. //* SYNOPSIS: Called when Next or Back btns pressed on this page. *
  126. //* *
  127. //* REQUIRES: hDlg: Dialog window *
  128. //* fForward: TRUE if 'Next' was pressed, FALSE if 'Back' *
  129. //* puNextPage: if 'Next' was pressed, proc can fill this *
  130. //* in with next page to go to. This parameter *
  131. //* is ingored if 'Back' was pressed. *
  132. //* pfKeepHistory: Page will not be kept in history if proc *
  133. //* fills this in with FALSE. *
  134. //* *
  135. //* RETURNS: BOOL: TRUE means turn to next page. FALSE to keep *
  136. //* the current page. *
  137. //* *
  138. //***************************************************************************
  139. BOOL WelcomeOK( HWND hDlg, BOOL fForward, UINT *puNextPage,
  140. BOOL *pfKeepHistory )
  141. {
  142. LPSTR szTemp;
  143. ASSERT( puNextPage );
  144. ASSERT( pfKeepHistory );
  145. ASSERT( fForward ); // Only go forward from this page
  146. if ( fForward ) {
  147. if ( IsDlgButtonChecked( hDlg, IDC_RAD_OPEN_EXISTING ) ) {
  148. GetDlgItemText( hDlg, IDC_EDIT_OPEN_CDF, g_CDF.achFilename,
  149. sizeof(g_CDF.achFilename) );
  150. if ( lstrlen( g_CDF.achFilename ) != 0 ) {
  151. GetFullPathName( g_CDF.achFilename, sizeof(g_CDF.achFilename),
  152. g_CDF.achFilename, &szTemp );
  153. }
  154. if ( ! FileExists( g_CDF.achFilename ) ) {
  155. DisplayFieldErrorMsg( hDlg, IDC_EDIT_OPEN_CDF,
  156. IDS_ERR_CDF_DOESNT_EXIST );
  157. return FALSE;
  158. } else {
  159. if ( ! ReadCDF( hDlg ) ) {
  160. return FALSE;
  161. }
  162. *puNextPage = ORD_PAGE_MODIFY;
  163. }
  164. } else {
  165. g_CDF.achFilename[0] = '\0';
  166. *puNextPage = ORD_PAGE_PURPOSE;
  167. }
  168. }
  169. return TRUE;
  170. }
  171. //###########################################################################
  172. //# ####################################################
  173. //# MODIFY PAGE ####################################################
  174. //# ####################################################
  175. //###########################################################################
  176. //***************************************************************************
  177. //* *
  178. //* NAME: ModifyInit *
  179. //* *
  180. //* SYNOPSIS: Called when this page is displayed. *
  181. //* *
  182. //* REQUIRES: hDlg: Dialog window *
  183. //* fFirstInit: TRUE if this is the first time the dialog is *
  184. //* initialized, FALSE if this InitProc has been *
  185. //* called before (e.g. went past this page and *
  186. //* backed up). *
  187. //* *
  188. //* RETURNS: BOOL: Always TRUE *
  189. //* *
  190. //***************************************************************************
  191. BOOL ModifyInit( HWND hDlg, BOOL fFirstInit )
  192. {
  193. CheckDlgButton( hDlg, IDC_RAD_CREATE, TRUE );
  194. CheckDlgButton( hDlg, IDC_RAD_MODIFY, FALSE );
  195. return TRUE;
  196. }
  197. //***************************************************************************
  198. //* *
  199. //* NAME: ModifyOK *
  200. //* *
  201. //* SYNOPSIS: Called when Next or Back btns pressed on this page. *
  202. //* *
  203. //* REQUIRES: hDlg: Dialog window *
  204. //* fForward: TRUE if 'Next' was pressed, FALSE if 'Back' *
  205. //* puNextPage: if 'Next' was pressed, proc can fill this *
  206. //* in with next page to go to. This parameter *
  207. //* is ingored if 'Back' was pressed. *
  208. //* pfKeepHistory: Page will not be kept in history if proc *
  209. //* fills this in with FALSE. *
  210. //* *
  211. //* RETURNS: BOOL: TRUE means turn to next page. FALSE to keep *
  212. //* the current page. *
  213. //* *
  214. //***************************************************************************
  215. BOOL ModifyOK( HWND hDlg, BOOL fForward, UINT *puNextPage,
  216. BOOL *pfKeepHistory )
  217. {
  218. ASSERT( puNextPage );
  219. ASSERT( pfKeepHistory );
  220. *pfKeepHistory = FALSE;
  221. if ( fForward ) {
  222. if ( IsDlgButtonChecked( hDlg, IDC_RAD_CREATE ) ) {
  223. *puNextPage = ORD_PAGE_CREATE;
  224. }
  225. }
  226. return TRUE;
  227. }
  228. //###########################################################################
  229. //# ####################################################
  230. //# TITLE PAGE ####################################################
  231. //# ####################################################
  232. //###########################################################################
  233. //***************************************************************************
  234. //* *
  235. //* NAME: TitleInit *
  236. //* *
  237. //* SYNOPSIS: Called when this page is displayed. *
  238. //* *
  239. //* REQUIRES: hDlg: Dialog window *
  240. //* fFirstInit: TRUE if this is the first time the dialog is *
  241. //* initialized, FALSE if this InitProc has been *
  242. //* called before (e.g. went past this page and *
  243. //* backed up). *
  244. //* *
  245. //* RETURNS: BOOL: Always TRUE *
  246. //* *
  247. //***************************************************************************
  248. BOOL TitleInit( HWND hDlg, BOOL fFirstInit )
  249. {
  250. SetFontForControl(hDlg, IDC_EDIT_TITLE);
  251. SendDlgItemMessage( hDlg, IDC_EDIT_TITLE, EM_LIMITTEXT, MAX_TITLE-2, 0L );
  252. SetDlgItemText( hDlg, IDC_EDIT_TITLE, g_CDF.achTitle );
  253. return TRUE;
  254. }
  255. //***************************************************************************
  256. //* *
  257. //* NAME: TitleOK *
  258. //* *
  259. //* SYNOPSIS: Called when Next or Back btns pressed on this page. *
  260. //* *
  261. //* REQUIRES: hDlg: Dialog window *
  262. //* fForward: TRUE if 'Next' was pressed, FALSE if 'Back' *
  263. //* puNextPage: if 'Next' was pressed, proc can fill this *
  264. //* in with next page to go to. This parameter *
  265. //* is ingored if 'Back' was pressed. *
  266. //* pfKeepHistory: Page will not be kept in history if proc *
  267. //* fills this in with FALSE. *
  268. //* *
  269. //* RETURNS: BOOL: TRUE means turn to next page. FALSE to keep *
  270. //* the current page. *
  271. //* *
  272. //***************************************************************************
  273. BOOL TitleOK( HWND hDlg, BOOL fForward, UINT *puNextPage,
  274. BOOL *pfKeepHistory )
  275. {
  276. ASSERT( puNextPage );
  277. ASSERT( pfKeepHistory );
  278. GetDlgItemText( hDlg, IDC_EDIT_TITLE, g_CDF.achTitle,
  279. sizeof(g_CDF.achTitle) );
  280. if ( fForward ) {
  281. if ( lstrlen( g_CDF.achTitle ) == 0 ) {
  282. DisplayFieldErrorMsg( hDlg, IDC_EDIT_TITLE, IDS_ERR_NO_TITLE );
  283. return FALSE;
  284. }
  285. }
  286. return TRUE;
  287. }
  288. //###########################################################################
  289. //# ####################################################
  290. //# PROMPT PAGE ####################################################
  291. //# ####################################################
  292. //###########################################################################
  293. //***************************************************************************
  294. //* *
  295. //* NAME: PromptInit *
  296. //* *
  297. //* SYNOPSIS: Called when this page is displayed. *
  298. //* *
  299. //* REQUIRES: hDlg: Dialog window *
  300. //* fFirstInit: TRUE if this is the first time the dialog is *
  301. //* initialized, FALSE if this InitProc has been *
  302. //* called before (e.g. went past this page and *
  303. //* backed up). *
  304. //* *
  305. //* RETURNS: BOOL: Always TRUE *
  306. //* *
  307. //***************************************************************************
  308. BOOL PromptInit( HWND hDlg, BOOL fFirstInit )
  309. {
  310. SetFontForControl(hDlg, IDC_EDIT_PROMPT);
  311. SendDlgItemMessage( hDlg, IDC_EDIT_PROMPT, EM_LIMITTEXT, MAX_PROMPT-2, 0L );
  312. SetDlgItemText( hDlg, IDC_EDIT_PROMPT, g_CDF.achPrompt );
  313. if ( g_CDF.fPrompt ) {
  314. CheckDlgButton( hDlg, IDC_RAD_NO_PROMPT, FALSE );
  315. CheckDlgButton( hDlg, IDC_RAD_YES_PROMPT, TRUE );
  316. EnableDlgItem( hDlg, IDC_EDIT_PROMPT, TRUE );
  317. } else {
  318. CheckDlgButton( hDlg, IDC_RAD_NO_PROMPT, TRUE );
  319. CheckDlgButton( hDlg, IDC_RAD_YES_PROMPT, FALSE );
  320. EnableDlgItem( hDlg, IDC_EDIT_PROMPT, FALSE );
  321. }
  322. return TRUE;
  323. }
  324. //***************************************************************************
  325. //* *
  326. //* NAME: PromptCmd *
  327. //* *
  328. //* SYNOPSIS: Called when dialog control pressed on page. *
  329. //* *
  330. //* REQUIRES: hDlg: Dialog window *
  331. //* uCtrlID: Control ID of control that was touched *
  332. //* pfGotoPage: If TRUE, goto the page puNextPage *
  333. //* puNextPage: Proc can fill this with next page to go to *
  334. //* pfKeepHistory: Page will not be kept in history if proc *
  335. //* fills this in with FALSE. *
  336. //* *
  337. //* RETURNS: BOOL: *
  338. //* *
  339. //***************************************************************************
  340. BOOL PromptCmd( HWND hDlg, UINT uCtrlID, BOOL *pfGotoPage, UINT *puNextPage,
  341. BOOL *pfKeepHistory )
  342. {
  343. switch ( uCtrlID ) {
  344. case IDC_RAD_YES_PROMPT:
  345. EnableDlgItem( hDlg, IDC_EDIT_PROMPT, TRUE );
  346. break;
  347. case IDC_RAD_NO_PROMPT:
  348. EnableDlgItem( hDlg, IDC_EDIT_PROMPT, FALSE );
  349. break;
  350. }
  351. return TRUE;
  352. }
  353. //***************************************************************************
  354. //* *
  355. //* NAME: PromptOK *
  356. //* *
  357. //* SYNOPSIS: Called when Next or Back btns pressed on this page. *
  358. //* *
  359. //* REQUIRES: hDlg: Dialog window *
  360. //* fForward: TRUE if 'Next' was pressed, FALSE if 'Back' *
  361. //* puNextPage: if 'Next' was pressed, proc can fill this *
  362. //* in with next page to go to. This parameter *
  363. //* is ingored if 'Back' was pressed. *
  364. //* pfKeepHistory: Page will not be kept in history if proc *
  365. //* fills this in with FALSE. *
  366. //* *
  367. //* RETURNS: BOOL: TRUE means turn to next page. FALSE to keep *
  368. //* the current page. *
  369. //* *
  370. //***************************************************************************
  371. BOOL PromptOK( HWND hDlg, BOOL fForward, UINT *puNextPage,
  372. BOOL *pfKeepHistory )
  373. {
  374. ASSERT( puNextPage );
  375. GetDlgItemText( hDlg, IDC_EDIT_PROMPT, g_CDF.achPrompt,
  376. sizeof(g_CDF.achPrompt) );
  377. if ( IsDlgButtonChecked( hDlg, IDC_RAD_YES_PROMPT ) ) {
  378. g_CDF.fPrompt = TRUE;
  379. } else {
  380. g_CDF.fPrompt = FALSE;
  381. }
  382. if ( fForward ) {
  383. if ( IsDlgButtonChecked( hDlg, IDC_RAD_YES_PROMPT ) ) {
  384. if ( lstrlen( g_CDF.achPrompt ) == 0 ) {
  385. DisplayFieldErrorMsg( hDlg, IDC_EDIT_PROMPT,
  386. IDS_ERR_NO_PROMPT );
  387. return FALSE;
  388. }
  389. }
  390. }
  391. return TRUE;
  392. }
  393. //###########################################################################
  394. //# ####################################################
  395. //# LICENSE PAGE ####################################################
  396. //# ####################################################
  397. //###########################################################################
  398. //***************************************************************************
  399. //* *
  400. //* NAME: LicenseTxtInit *
  401. //* *
  402. //* SYNOPSIS: Called when this page is displayed. *
  403. //* *
  404. //* REQUIRES: hDlg: Dialog window *
  405. //* fFirstInit: TRUE if this is the first time the dialog is *
  406. //* initialized, FALSE if this InitProc has been *
  407. //* called before (e.g. went past this page and *
  408. //* backed up). *
  409. //* *
  410. //* RETURNS: BOOL: Always TRUE *
  411. //* *
  412. //***************************************************************************
  413. BOOL LicenseTxtInit( HWND hDlg, BOOL fFirstInit )
  414. {
  415. SetFontForControl(hDlg, IDC_EDIT_LICENSE);
  416. SetDlgItemText( hDlg, IDC_EDIT_LICENSE, g_CDF.achLicense );
  417. if ( g_CDF.fLicense ) {
  418. CheckDlgButton( hDlg, IDC_RAD_NO_LICENSE, FALSE );
  419. CheckDlgButton( hDlg, IDC_RAD_YES_LICENSE, TRUE );
  420. EnableDlgItem( hDlg, IDC_EDIT_LICENSE, TRUE );
  421. EnableDlgItem( hDlg, IDC_BUT_BROWSE, TRUE );
  422. } else {
  423. CheckDlgButton( hDlg, IDC_RAD_NO_LICENSE, TRUE );
  424. CheckDlgButton( hDlg, IDC_RAD_YES_LICENSE, FALSE );
  425. EnableDlgItem( hDlg, IDC_EDIT_LICENSE, FALSE );
  426. EnableDlgItem( hDlg, IDC_BUT_BROWSE, FALSE );
  427. }
  428. return TRUE;
  429. }
  430. //***************************************************************************
  431. //* *
  432. //* NAME: LicenseTxtCmd *
  433. //* *
  434. //* SYNOPSIS: Called when dialog control pressed on page. *
  435. //* *
  436. //* REQUIRES: hDlg: Dialog window *
  437. //* uCtrlID: Control ID of control that was touched *
  438. //* pfGotoPage: If TRUE, goto the page puNextPage *
  439. //* puNextPage: Proc can fill this with next page to go to *
  440. //* pfKeepHistory: Page will not be kept in history if proc *
  441. //* fills this in with FALSE. *
  442. //* *
  443. //* RETURNS: BOOL: *
  444. //* *
  445. //***************************************************************************
  446. BOOL LicenseTxtCmd( HWND hDlg, UINT uCtrlID, BOOL *pfGotoPage, UINT *puNextPage,
  447. BOOL *pfKeepHistory )
  448. {
  449. CHAR achFilename[MAX_PATH] = { '\0' };
  450. BOOL fResult;
  451. switch ( uCtrlID ) {
  452. case IDC_RAD_YES_LICENSE:
  453. EnableDlgItem( hDlg, IDC_EDIT_LICENSE, TRUE );
  454. EnableDlgItem( hDlg, IDC_BUT_BROWSE, TRUE );
  455. break;
  456. case IDC_RAD_NO_LICENSE:
  457. EnableDlgItem( hDlg, IDC_EDIT_LICENSE, FALSE );
  458. EnableDlgItem( hDlg, IDC_BUT_BROWSE, FALSE );
  459. break;
  460. case IDC_BUT_BROWSE:
  461. fResult = MyOpen( hDlg, IDS_FILTER_TXT,
  462. achFilename, sizeof(achFilename), 0,
  463. NULL, NULL, EXT_TXT_NODOT );
  464. if ( fResult ) {
  465. SetDlgItemText( hDlg, IDC_EDIT_LICENSE, achFilename );
  466. }
  467. break;
  468. }
  469. return TRUE;
  470. }
  471. //***************************************************************************
  472. //* *
  473. //* NAME: LicenseTxtOK *
  474. //* *
  475. //* SYNOPSIS: Called when Next or Back btns pressed on this page. *
  476. //* *
  477. //* REQUIRES: hDlg: Dialog window *
  478. //* fForward: TRUE if 'Next' was pressed, FALSE if 'Back' *
  479. //* puNextPage: if 'Next' was pressed, proc can fill this *
  480. //* in with next page to go to. This parameter *
  481. //* is ingored if 'Back' was pressed. *
  482. //* pfKeepHistory: Page will not be kept in history if proc *
  483. //* fills this in with FALSE. *
  484. //* *
  485. //* RETURNS: BOOL: TRUE means turn to next page. FALSE to keep *
  486. //* the current page. *
  487. //* *
  488. //***************************************************************************
  489. BOOL LicenseTxtOK( HWND hDlg, BOOL fForward, UINT *puNextPage,
  490. BOOL *pfKeepHistory )
  491. {
  492. LPSTR szTemp;
  493. ASSERT( puNextPage );
  494. GetDlgItemText( hDlg, IDC_EDIT_LICENSE, g_CDF.achLicense,
  495. sizeof(g_CDF.achLicense) );
  496. if ( lstrlen( g_CDF.achLicense ) != 0 ) {
  497. GetFullPathName( g_CDF.achLicense, sizeof(g_CDF.achLicense),
  498. g_CDF.achLicense, &szTemp );
  499. }
  500. if ( IsDlgButtonChecked( hDlg, IDC_RAD_YES_LICENSE ) ) {
  501. g_CDF.fLicense = TRUE;
  502. } else {
  503. g_CDF.fLicense = FALSE;
  504. }
  505. if ( fForward ) {
  506. if ( IsDlgButtonChecked( hDlg, IDC_RAD_YES_LICENSE ) ) {
  507. if ( lstrlen( g_CDF.achLicense ) == 0 ) {
  508. DisplayFieldErrorMsg( hDlg, IDC_EDIT_LICENSE,
  509. IDS_ERR_NO_LICENSE );
  510. return FALSE;
  511. }
  512. if ( ! FileExists( g_CDF.achLicense ) ) {
  513. DisplayFieldErrorMsg( hDlg, IDC_EDIT_LICENSE,
  514. IDS_ERR_LICENSE_NOT_FOUND );
  515. return FALSE;
  516. }
  517. }
  518. }
  519. return TRUE;
  520. }
  521. //###########################################################################
  522. //# ####################################################
  523. //# FILES PAGE ####################################################
  524. //# ####################################################
  525. //###########################################################################
  526. //***************************************************************************
  527. //* *
  528. //* NAME: FilesInit *
  529. //* *
  530. //* SYNOPSIS: Called when this page is displayed. *
  531. //* *
  532. //* REQUIRES: hDlg: Dialog window *
  533. //* fFirstInit: TRUE if this is the first time the dialog is *
  534. //* initialized, FALSE if this InitProc has been *
  535. //* called before (e.g. went past this page and *
  536. //* backed up). *
  537. //* *
  538. //* RETURNS: BOOL: Always TRUE *
  539. //* *
  540. //***************************************************************************
  541. BOOL FilesInit( HWND hDlg, BOOL fFirstInit )
  542. {
  543. LV_COLUMN lvc;
  544. RECT Rect;
  545. PMYITEM pMyItem;
  546. LV_ITEM lvi;
  547. CHAR achTemp[MAX_STRING];
  548. // Every time we enter this page, we clean out the list view
  549. // and add back all the items from our internal list. This is
  550. // done because the list of items can change on other pages (like
  551. // if the user backs up to the first page, then loads another
  552. // CDF file).
  553. ListView_DeleteAllItems( GetDlgItem( hDlg, IDC_LV_CAB_FILES ) );
  554. lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
  555. lvi.state = 0;
  556. lvi.stateMask = 0;
  557. lvi.pszText = LPSTR_TEXTCALLBACK;
  558. lvi.iItem = 0;
  559. lvi.iSubItem = 0;
  560. pMyItem = GetFirstItem();
  561. while ( ! LastItem( pMyItem ) ) {
  562. lvi.lParam = (LPARAM) pMyItem;
  563. ListView_InsertItem( GetDlgItem( hDlg, IDC_LV_CAB_FILES ), &lvi );
  564. lvi.iItem += 1;
  565. pMyItem = GetNextItem( pMyItem );
  566. }
  567. if ( fFirstInit ) {
  568. // Setup the column headers
  569. GetWindowRect( GetDlgItem( hDlg, IDC_LV_CAB_FILES ), &Rect );
  570. lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT;
  571. lvc.fmt = LVCFMT_LEFT;
  572. lvc.cx = 80;
  573. LoadSz( IDS_HEADER_FILENAME, achTemp, sizeof(achTemp) );
  574. lvc.pszText = (LPSTR) LocalAlloc( LPTR, lstrlen(achTemp) + 1 );
  575. if ( ! lvc.pszText ) {
  576. ErrorMsg( hDlg, IDS_ERR_NO_MEMORY );
  577. return FALSE;
  578. }
  579. lstrcpy( lvc.pszText, achTemp );
  580. ListView_InsertColumn( GetDlgItem( hDlg, IDC_LV_CAB_FILES ), 0, &lvc );
  581. LocalFree( lvc.pszText );
  582. lvc.cx = Rect.right - Rect.left - 80;
  583. LoadSz( IDS_HEADER_PATH, achTemp, sizeof(achTemp) );
  584. lvc.pszText = (LPSTR) LocalAlloc( LPTR, lstrlen(achTemp) + 1 );
  585. if ( ! lvc.pszText ) {
  586. ErrorMsg( hDlg, IDS_ERR_NO_MEMORY );
  587. return FALSE;
  588. }
  589. lstrcpy( lvc.pszText, achTemp );
  590. ListView_InsertColumn( GetDlgItem( hDlg, IDC_LV_CAB_FILES ), 1, &lvc );
  591. LocalFree( lvc.pszText );
  592. EnableDlgItem( hDlg, IDC_BUT_REMOVE, FALSE );
  593. }
  594. return TRUE;
  595. }
  596. //***************************************************************************
  597. //* *
  598. //* NAME: FilesCmd *
  599. //* *
  600. //* SYNOPSIS: Called when dialog control pressed on page. *
  601. //* *
  602. //* REQUIRES: hDlg: Dialog window *
  603. //* uCtrlID: Control ID of control that was touched *
  604. //* pfGotoPage: If TRUE, goto the page puNextPage *
  605. //* puNextPage: Proc can fill this with next page to go to *
  606. //* pfKeepHistory: Page will not be kept in history if proc *
  607. //* fills this in with FALSE. *
  608. //* *
  609. //* RETURNS: BOOL: *
  610. //* *
  611. //***************************************************************************
  612. BOOL FilesCmd( HWND hDlg, UINT uCtrlID, BOOL *pfGotoPage, UINT *puNextPage,
  613. BOOL *pfKeepHistory )
  614. {
  615. LPSTR achFilename;
  616. INT FileOffset = 0;
  617. INT FileExtension = 0;
  618. BOOL fResult = TRUE;
  619. char szPath[MAX_PATH];
  620. ULONG ulIndex = 0;
  621. INT nIndex = 0;
  622. LV_ITEM lvi;
  623. INT nItem;
  624. HWND hwndFiles;
  625. SYSTEMTIME st;
  626. lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
  627. lvi.state = 0;
  628. lvi.stateMask = 0;
  629. lvi.pszText = LPSTR_TEXTCALLBACK;
  630. hwndFiles = GetDlgItem( hDlg, IDC_LV_CAB_FILES );
  631. switch ( uCtrlID )
  632. {
  633. case IDC_BUT_ADD:
  634. //allocate 8K buff to hold the file name list
  635. achFilename = LocalAlloc( LPTR, 1024*8 );
  636. if ( !achFilename )
  637. {
  638. ErrorMsg( hDlg, IDS_ERR_NO_MEMORY );
  639. return FALSE;
  640. }
  641. fResult = MyOpen( hDlg, IDS_FILTER_ALL,
  642. achFilename, 1024*8,
  643. OFN_ALLOWMULTISELECT,
  644. &FileOffset, &FileExtension, 0 );
  645. // We should do some error checking to make sure all the files
  646. // could fit in the buffer. Currently the buffer is big enough to
  647. // hold tons of files.
  648. if ( fResult )
  649. {
  650. lvi.iItem = ListView_GetItemCount( hwndFiles );
  651. // Add a trailing backslash to the pathname if it's not
  652. // the root dir
  653. lstrcpy( szPath, achFilename );
  654. lstrcpy( g_szInitialDir, szPath );
  655. AddPath( szPath, "" );
  656. // The open file common dialog returns two types of strings
  657. // when in MULTISELECT mode. The first one is when
  658. // multiple files are selected -- it returns:
  659. // "path \0 file1 \0 file2 \0 ... \0 fileN \0 \0"
  660. // The second is when only 1 file is selected:
  661. // "path\filename \0 \0"
  662. ulIndex = lstrlen( achFilename ) + 1;
  663. while ( achFilename[ulIndex] != '\0' )
  664. {
  665. if ( ! IsDuplicate( hDlg, IDC_LV_CAB_FILES,
  666. &achFilename[ulIndex], TRUE ) )
  667. {
  668. lvi.lParam = (LPARAM) AddItem( &achFilename[ulIndex],
  669. szPath );
  670. if ( ! lvi.lParam ) {
  671. ErrorMsg( hDlg, IDS_ERR_NO_MEMORY );
  672. LocalFree( achFilename );
  673. return FALSE;
  674. }
  675. GetSystemTime( &st );
  676. //SystemTimeToFileTime( &st, &g_CDF.ftFileListChange );
  677. lvi.iItem += 1;
  678. lvi.iSubItem = 0;
  679. ListView_InsertItem( hwndFiles, &lvi );
  680. }
  681. else
  682. {
  683. ErrorMsg1Param( hDlg, IDS_ERR_DUPE_FILE,
  684. &achFilename[ulIndex] );
  685. }
  686. ulIndex = ulIndex + lstrlen( &achFilename[ulIndex] ) + 1;
  687. }
  688. if ( ulIndex == (ULONG)(lstrlen( achFilename ) + 1) )
  689. {
  690. if ( ! IsDuplicate( hDlg, IDC_LV_CAB_FILES,
  691. &achFilename[FileOffset], TRUE ) )
  692. {
  693. // should have '\' at the end
  694. lstrcpyn( szPath, achFilename, FileOffset+1 );
  695. lstrcpy( g_szInitialDir, szPath );
  696. lvi.iSubItem = 0;
  697. lvi.lParam = (LPARAM) AddItem(
  698. &achFilename[FileOffset],
  699. szPath );
  700. if ( ! lvi.lParam ) {
  701. ErrorMsg( hDlg, IDS_ERR_NO_MEMORY );
  702. LocalFree( achFilename );
  703. return FALSE;
  704. }
  705. ListView_InsertItem( hwndFiles, &lvi );
  706. }
  707. else
  708. {
  709. ErrorMsg1Param( hDlg, IDS_ERR_DUPE_FILE,
  710. &achFilename[FileOffset] );
  711. }
  712. }
  713. }
  714. LocalFree( achFilename );
  715. if ( ListView_GetSelectedCount( hwndFiles ) )
  716. {
  717. EnableDlgItem( hDlg, IDC_BUT_REMOVE, TRUE );
  718. } else {
  719. EnableDlgItem( hDlg, IDC_BUT_REMOVE, FALSE );
  720. }
  721. break;
  722. case IDC_BUT_REMOVE:
  723. nItem = ListView_GetNextItem( hwndFiles, -1,
  724. LVNI_ALL | LVNI_SELECTED );
  725. while ( nItem != -1 )
  726. {
  727. lvi.mask = LVIF_PARAM;
  728. lvi.iItem = nItem;
  729. lvi.iSubItem = 0;
  730. ListView_GetItem( hwndFiles, &lvi );
  731. RemoveItem( (PMYITEM) lvi.lParam );
  732. //GetSystemTime( &st );
  733. //SystemTimeToFileTime( &st, &g_CDF.ftFileListChange );
  734. ListView_DeleteItem( hwndFiles, nItem );
  735. nItem = ListView_GetNextItem( hwndFiles, -1,
  736. LVNI_ALL | LVNI_SELECTED );
  737. }
  738. EnableDlgItem( hDlg, IDC_BUT_REMOVE, FALSE );
  739. break;
  740. }
  741. return fResult;
  742. }
  743. //***************************************************************************
  744. //* *
  745. //* NAME: FilesNotify *
  746. //* *
  747. //* SYNOPSIS: Called when a notification message sent to this page. *
  748. //* *
  749. //* REQUIRES: hDlg: Dialog window *
  750. //* wParam: *
  751. //* lParam: *
  752. //* *
  753. //* RETURNS: BOOL: *
  754. //* *
  755. //***************************************************************************
  756. BOOL FilesNotify( HWND hDlg, WPARAM wParam, LPARAM lParam )
  757. {
  758. switch ( ((LPNMHDR)lParam)->code ) {
  759. case LVN_GETDISPINFO:
  760. {
  761. LV_DISPINFO *pnmv = (LV_DISPINFO *) lParam;
  762. if ( pnmv->item.mask & LVIF_TEXT )
  763. {
  764. PMYITEM pMyItem = (PMYITEM) (pnmv->item.lParam);
  765. lstrcpy( pnmv->item.pszText,
  766. GetItemSz( pMyItem, pnmv->item.iSubItem ) );
  767. }
  768. break;
  769. }
  770. case LVN_ITEMCHANGED:
  771. {
  772. if ( ListView_GetSelectedCount( GetDlgItem( hDlg,
  773. IDC_LV_CAB_FILES ) ) )
  774. {
  775. EnableDlgItem( hDlg, IDC_BUT_REMOVE, TRUE );
  776. } else {
  777. EnableDlgItem( hDlg, IDC_BUT_REMOVE, FALSE );
  778. }
  779. break;
  780. }
  781. /*
  782. case LVN_COLUMNCLICK :
  783. {
  784. NM_LISTVIEW FAR *pnmv = (NM_LISTVIEW FAR *) lParam;
  785. if ( pnmv->iSubItem == 1 ) {
  786. if ( g_CDF.wSortOrder & _SORT_FILENAME ) {
  787. g_CDF.wSortOrder = g_CDF.wSortOrder ^ _SORT_ORDER;
  788. } else {
  789. g_CDF.wSortOrder = _SORT_FILENAME | _SORT_DESCENDING;
  790. }
  791. } else {
  792. if ( g_CDF.wSortOrder & _SORT_PATH ) {
  793. g_CDF.wSortOrder = g_CDF.wSortOrder ^ _SORT_ORDER;
  794. } else {
  795. g_CDF.wSortOrder = _SORT_PATH | _SORT_DESCENDING;
  796. }
  797. }
  798. ListView_SortItems( GetDlgItem( hDlg, IDC_LV_CAB_FILES ),
  799. CompareFunc, g_CDF.wSortOrder );
  800. break;
  801. }
  802. */
  803. }
  804. return TRUE;
  805. }
  806. //***************************************************************************
  807. //* *
  808. //* NAME: FilesOK *
  809. //* *
  810. //* SYNOPSIS: Called when Next or Back btns pressed on this page. *
  811. //* *
  812. //* REQUIRES: hDlg: Dialog window *
  813. //* fForward: TRUE if 'Next' was pressed, FALSE if 'Back' *
  814. //* puNextPage: if 'Next' was pressed, proc can fill this *
  815. //* in with next page to go to. This parameter *
  816. //* is ingored if 'Back' was pressed. *
  817. //* pfKeepHistory: Page will not be kept in history if proc *
  818. //* fills this in with FALSE. *
  819. //* *
  820. //* RETURNS: BOOL: TRUE means turn to next page. FALSE to keep *
  821. //* the current page. *
  822. //* *
  823. //***************************************************************************
  824. BOOL FilesOK( HWND hDlg, BOOL fForward, UINT *puNextPage,
  825. BOOL *pfKeepHistory )
  826. {
  827. ASSERT( puNextPage );
  828. if ( fForward )
  829. {
  830. if ( ListView_GetItemCount( GetDlgItem( hDlg, IDC_LV_CAB_FILES ) )
  831. == 0 )
  832. {
  833. ErrorMsg( hDlg, IDS_ERR_NO_FILES );
  834. return FALSE;
  835. }
  836. if ( g_CDF.uPackPurpose == IDC_CMD_EXTRACT )
  837. {
  838. *puNextPage = ORD_PAGE_SHOWWINDOW;
  839. }
  840. else if ( g_CDF.uPackPurpose == IDC_CMD_CREATECAB )
  841. {
  842. *puNextPage = ORD_PAGE_TARGET_CAB;
  843. }
  844. else
  845. ; // normal page order
  846. }
  847. return TRUE;
  848. }
  849. //###########################################################################
  850. //# ####################################################
  851. //# PACKPURPOSE PAGE ####################################################
  852. //# ####################################################
  853. //###########################################################################
  854. //***************************************************************************
  855. //* *
  856. //* NAME: PackPurposeInit *
  857. //* *
  858. //* SYNOPSIS: Called when this page is displayed. *
  859. //* *
  860. //* REQUIRES: hDlg: Dialog window *
  861. //* fFirstInit: TRUE if this is the first time the dialog is *
  862. //* initialized, FALSE if this InitProc has been *
  863. //* called before (e.g. went past this page and *
  864. //* backed up). *
  865. //* *
  866. //* RETURNS: BOOL: Always TRUE *
  867. //* *
  868. //***************************************************************************
  869. BOOL PackPurposeInit( HWND hDlg, BOOL fFirstInit )
  870. {
  871. CHAR msg[MAX_STRING];
  872. UINT idMsg;
  873. if ( CheckRadioButton( hDlg, IDC_CMD_RUNCMD, IDC_CMD_CREATECAB, g_CDF.uPackPurpose ) )
  874. {
  875. if ( g_CDF.uPackPurpose == IDC_CMD_RUNCMD )
  876. idMsg = IDS_CMD_RUNCMD;
  877. else if ( g_CDF.uPackPurpose == IDC_CMD_EXTRACT )
  878. idMsg = IDS_CMD_EXTRACT;
  879. else
  880. idMsg = IDS_CMD_CREATECAB;
  881. LoadSz( idMsg, msg, sizeof(msg) );
  882. SendMessage( GetDlgItem( hDlg, IDC_CMD_NOTES), WM_SETTEXT, 0, (LPARAM)msg );
  883. }
  884. else
  885. SysErrorMsg( hDlg );
  886. return TRUE;
  887. }
  888. //***************************************************************************
  889. //* *
  890. //* NAME: PackPurposeCmd *
  891. //* *
  892. //* SYNOPSIS: Called when dialog control pressed on page. *
  893. //* *
  894. //* REQUIRES: hDlg: Dialog window *
  895. //* uCtrlID: Control ID of control that was touched *
  896. //* pfGotoPage: If TRUE, goto the page puNextPage *
  897. //* puNextPage: Proc can fill this with next page to go to *
  898. //* pfKeepHistory: Page will not be kept in history if proc *
  899. //* fills this in with FALSE. *
  900. //* *
  901. //* RETURNS: BOOL: *
  902. //* *
  903. //***************************************************************************
  904. BOOL PackPurposeCmd( HWND hDlg, UINT uCtrlID, BOOL *pfGotoPage, UINT *puNextPage,
  905. BOOL *pfKeepHistory )
  906. {
  907. CHAR msg[MAX_STRING];
  908. int idMsg;
  909. switch ( uCtrlID )
  910. {
  911. case IDC_CMD_RUNCMD:
  912. if ( IsDlgButtonChecked( hDlg, IDC_CMD_RUNCMD ) )
  913. idMsg = IDS_CMD_RUNCMD;
  914. break;
  915. case IDC_CMD_EXTRACT:
  916. if ( IsDlgButtonChecked( hDlg, IDC_CMD_EXTRACT ) )
  917. idMsg = IDS_CMD_EXTRACT;
  918. break;
  919. case IDC_CMD_CREATECAB:
  920. if ( IsDlgButtonChecked( hDlg, IDC_CMD_CREATECAB ) )
  921. idMsg = IDS_CMD_CREATECAB;
  922. break;
  923. }
  924. LoadSz( idMsg, msg, sizeof(msg) );
  925. SendMessage( GetDlgItem( hDlg, IDC_CMD_NOTES), WM_SETTEXT, 0, (LPARAM)msg );
  926. return TRUE;
  927. }
  928. //***************************************************************************
  929. //* *
  930. //* NAME: PackPurposeOK *
  931. //* *
  932. //* SYNOPSIS: Called when Next or Back btns pressed on this page. *
  933. //* *
  934. //* REQUIRES: hDlg: Dialog window *
  935. //* fForward: TRUE if 'Next' was pressed, FALSE if 'Back' *
  936. //* puNextPage: if 'Next' was pressed, proc can fill this *
  937. //* in with next page to go to. This parameter *
  938. //* is ingored if 'Back' was pressed. *
  939. //* pfKeepHistory: Page will not be kept in history if proc *
  940. //* fills this in with FALSE. *
  941. //* *
  942. //* RETURNS: BOOL: TRUE means turn to next page. FALSE to keep *
  943. //* the current page. *
  944. //* *
  945. //***************************************************************************
  946. BOOL PackPurposeOK( HWND hDlg, BOOL fForward, UINT *puNextPage, BOOL *pfKeepHistory )
  947. {
  948. ASSERT( puNextPage );
  949. if ( IsDlgButtonChecked( hDlg, IDC_CMD_RUNCMD ) )
  950. {
  951. g_CDF.uPackPurpose = IDC_CMD_RUNCMD;
  952. }
  953. else if ( IsDlgButtonChecked( hDlg, IDC_CMD_EXTRACT ) )
  954. {
  955. g_CDF.uPackPurpose = IDC_CMD_EXTRACT;
  956. // leave long file name
  957. g_CDF.uExtractOpt |= EXTRACTOPT_LFN_YES;
  958. }
  959. else
  960. {
  961. g_CDF.uPackPurpose = IDC_CMD_CREATECAB;
  962. // load Default messagebox title name
  963. LoadSz( IDS_APPNAME, g_CDF.achTitle, sizeof(g_CDF.achTitle) );
  964. }
  965. if ( fForward )
  966. {
  967. if ( g_CDF.uPackPurpose == IDC_CMD_CREATECAB )
  968. {
  969. g_CDF.uExtractOpt |= CAB_RESVSP6K;
  970. *puNextPage = ORD_PAGE_FILES;
  971. }
  972. }
  973. else
  974. {
  975. if ( MsgBox( hDlg, IDS_LOSE_CHANGES, MB_ICONQUESTION, MB_YESNO ) == IDNO )
  976. {
  977. return FALSE;
  978. }
  979. }
  980. return TRUE;
  981. }
  982. //###########################################################################
  983. //# ####################################################
  984. //# COMMAND PAGE ####################################################
  985. //# ####################################################
  986. //###########################################################################
  987. //***************************************************************************
  988. //* *
  989. //* NAME: CommandInit *
  990. //* *
  991. //* SYNOPSIS: Called when this page is displayed. *
  992. //* *
  993. //* REQUIRES: hDlg: Dialog window *
  994. //* fFirstInit: TRUE if this is the first time the dialog is *
  995. //* initialized, FALSE if this InitProc has been *
  996. //* called before (e.g. went past this page and *
  997. //* backed up). *
  998. //* *
  999. //* RETURNS: BOOL: Always TRUE *
  1000. //* *
  1001. //***************************************************************************
  1002. BOOL CommandInit( HWND hDlg, BOOL fFirstInit )
  1003. {
  1004. LRESULT nCurSel;
  1005. PMYITEM pMyItem;
  1006. LPSTR szFile;
  1007. CHAR achExt[_MAX_EXT];
  1008. SetFontForControl(hDlg, IDC_CB_INSTALLCMD);
  1009. SetFontForControl(hDlg, IDC_CB_POSTCMD);
  1010. if ( !fFirstInit )
  1011. {
  1012. // cleanup old settings
  1013. SendDlgItemMessage( hDlg, IDC_CB_INSTALLCMD, CB_RESETCONTENT, 0, 0 );
  1014. SendDlgItemMessage( hDlg, IDC_CB_POSTCMD, CB_RESETCONTENT, 0, 0 );
  1015. g_CDF.uExtractOpt &= ~(EXTRACTOPT_ADVDLL);
  1016. // ADD EXE, BAT, COM and INF FILES TO THE COMBBOXes
  1017. pMyItem = GetFirstItem();
  1018. while ( ! LastItem( pMyItem ) )
  1019. {
  1020. szFile = GetItemSz( pMyItem, 0 );
  1021. _splitpath( szFile, NULL, NULL, NULL, achExt );
  1022. if ( lstrcmpi( achExt, achExtEXE ) == 0
  1023. || lstrcmpi( achExt, achExtBAT ) == 0
  1024. || lstrcmpi( achExt, achExtCOM ) == 0
  1025. || lstrcmpi( achExt, achExtINF ) == 0 )
  1026. {
  1027. SendDlgItemMessage( hDlg, IDC_CB_INSTALLCMD, CB_ADDSTRING, 0, (LPARAM)szFile );
  1028. SendDlgItemMessage( hDlg, IDC_CB_POSTCMD, CB_ADDSTRING, 0, (LPARAM)szFile );
  1029. }
  1030. pMyItem = GetNextItem( pMyItem );
  1031. }
  1032. SetCurrSelect( hDlg, IDC_CB_INSTALLCMD, g_CDF.achOrigiInstallCmd );
  1033. SendDlgItemMessage( hDlg, IDC_CB_POSTCMD, CB_ADDSTRING, 0, (LPARAM)achResNone );
  1034. if ( !SetCurrSelect( hDlg, IDC_CB_POSTCMD, g_CDF.achOrigiPostInstCmd ) )
  1035. {
  1036. nCurSel = SendDlgItemMessage( hDlg, IDC_CB_POSTCMD,
  1037. CB_FINDSTRINGEXACT, (WPARAM) -1,
  1038. (LPARAM)achResNone );
  1039. SendDlgItemMessage( hDlg, IDC_CB_POSTCMD, CB_SETCURSEL, (WPARAM)nCurSel, 0 );
  1040. }
  1041. }
  1042. return TRUE;
  1043. }
  1044. //***************************************************************************
  1045. //* *
  1046. //* NAME: CommandOK *
  1047. //* *
  1048. //* SYNOPSIS: Called when Next or Back btns pressed on this page. *
  1049. //* *
  1050. //* REQUIRES: hDlg: Dialog window *
  1051. //* fForward: TRUE if 'Next' was pressed, FALSE if 'Back' *
  1052. //* puNextPage: if 'Next' was pressed, proc can fill this *
  1053. //* in with next page to go to. This parameter *
  1054. //* is ingored if 'Back' was pressed. *
  1055. //* pfKeepHistory: Page will not be kept in history if proc *
  1056. //* fills this in with FALSE. *
  1057. //* *
  1058. //* RETURNS: BOOL: TRUE means turn to next page. FALSE to keep *
  1059. //* the current page. *
  1060. //* *
  1061. //***************************************************************************
  1062. BOOL CommandOK( HWND hDlg, BOOL fForward, UINT *puNextPage, BOOL *pfKeepHistory )
  1063. {
  1064. ASSERT( puNextPage );
  1065. SendMessage( GetDlgItem(hDlg, IDC_CB_INSTALLCMD), WM_GETTEXT,
  1066. (WPARAM)sizeof(g_CDF.achOrigiInstallCmd), (LPARAM)g_CDF.achOrigiInstallCmd );
  1067. RemoveBlanks( g_CDF.achOrigiInstallCmd );
  1068. if ( fForward && !lstrlen(g_CDF.achOrigiInstallCmd) )
  1069. {
  1070. ErrorMsg( hDlg, IDS_ERR_NO_SELECT );
  1071. return FALSE;
  1072. }
  1073. // set EXTRACTOPT_ADVDLL if needed
  1074. if ( !CheckAdvBit( g_CDF.achOrigiInstallCmd ) )
  1075. return FALSE;
  1076. SendMessage( GetDlgItem(hDlg, IDC_CB_POSTCMD), WM_GETTEXT,
  1077. (WPARAM)sizeof(g_CDF.achOrigiPostInstCmd), (LPARAM)g_CDF.achOrigiPostInstCmd );
  1078. RemoveBlanks( g_CDF.achOrigiPostInstCmd );
  1079. if ( lstrlen( g_CDF.achOrigiPostInstCmd ) && lstrcmpi(g_CDF.achOrigiPostInstCmd, achResNone) )
  1080. {
  1081. if ( !CheckAdvBit( g_CDF.achOrigiPostInstCmd ) )
  1082. return FALSE;
  1083. }
  1084. return TRUE;
  1085. }
  1086. //###########################################################################
  1087. //# ####################################################
  1088. //# SHOWWINDOW PAGE ####################################################
  1089. //# ####################################################
  1090. //###########################################################################
  1091. //***************************************************************************
  1092. //* *
  1093. //* NAME: ShowWindowInit *
  1094. //* *
  1095. //* SYNOPSIS: Called when this page is displayed. *
  1096. //* *
  1097. //* REQUIRES: hDlg: Dialog window *
  1098. //* fFirstInit: TRUE if this is the first time the dialog is *
  1099. //* initialized, FALSE if this InitProc has been *
  1100. //* called before (e.g. went past this page and *
  1101. //* backed up). *
  1102. //* *
  1103. //* RETURNS: BOOL: Always TRUE *
  1104. //* *
  1105. //***************************************************************************
  1106. BOOL ShowWindowInit( HWND hDlg, BOOL fFirstInit )
  1107. {
  1108. if ( g_CDF.uShowWindow == bResShowDefault ) {
  1109. CheckDlgButton( hDlg, IDC_RAD_DEFAULT, TRUE );
  1110. CheckDlgButton( hDlg, IDC_RAD_HIDDEN, FALSE );
  1111. CheckDlgButton( hDlg, IDC_RAD_MINIMIZED, FALSE );
  1112. CheckDlgButton( hDlg, IDC_RAD_MAXIMIZED, FALSE );
  1113. } else if ( g_CDF.uShowWindow == bResShowHidden ) {
  1114. CheckDlgButton( hDlg, IDC_RAD_DEFAULT, FALSE );
  1115. CheckDlgButton( hDlg, IDC_RAD_HIDDEN, TRUE );
  1116. CheckDlgButton( hDlg, IDC_RAD_MINIMIZED, FALSE );
  1117. CheckDlgButton( hDlg, IDC_RAD_MAXIMIZED, FALSE );
  1118. } else if ( g_CDF.uShowWindow == bResShowMin ) {
  1119. CheckDlgButton( hDlg, IDC_RAD_DEFAULT, FALSE );
  1120. CheckDlgButton( hDlg, IDC_RAD_HIDDEN, FALSE );
  1121. CheckDlgButton( hDlg, IDC_RAD_MINIMIZED, TRUE );
  1122. CheckDlgButton( hDlg, IDC_RAD_MAXIMIZED, FALSE );
  1123. } else {
  1124. CheckDlgButton( hDlg, IDC_RAD_DEFAULT, FALSE );
  1125. CheckDlgButton( hDlg, IDC_RAD_HIDDEN, FALSE );
  1126. CheckDlgButton( hDlg, IDC_RAD_MINIMIZED, FALSE );
  1127. CheckDlgButton( hDlg, IDC_RAD_MAXIMIZED, TRUE );
  1128. }
  1129. return TRUE;
  1130. }
  1131. //***************************************************************************
  1132. //* *
  1133. //* NAME: ShowWindowOK *
  1134. //* *
  1135. //* SYNOPSIS: Called when Next or Back btns pressed on this page. *
  1136. //* *
  1137. //* REQUIRES: hDlg: Dialog window *
  1138. //* fForward: TRUE if 'Next' was pressed, FALSE if 'Back' *
  1139. //* puNextPage: if 'Next' was pressed, proc can fill this *
  1140. //* in with next page to go to. This parameter *
  1141. //* is ingored if 'Back' was pressed. *
  1142. //* pfKeepHistory: Page will not be kept in history if proc *
  1143. //* fills this in with FALSE. *
  1144. //* *
  1145. //* RETURNS: BOOL: TRUE means turn to next page. FALSE to keep *
  1146. //* the current page. *
  1147. //* *
  1148. //***************************************************************************
  1149. BOOL ShowWindowOK( HWND hDlg, BOOL fForward, UINT *puNextPage,
  1150. BOOL *pfKeepHistory )
  1151. {
  1152. ASSERT( puNextPage );
  1153. if ( IsDlgButtonChecked( hDlg, IDC_RAD_DEFAULT ) ) {
  1154. g_CDF.uShowWindow = bResShowDefault;
  1155. } else if ( IsDlgButtonChecked( hDlg, IDC_RAD_HIDDEN ) ) {
  1156. g_CDF.uShowWindow = bResShowHidden;
  1157. } else if ( IsDlgButtonChecked( hDlg, IDC_RAD_MINIMIZED ) ) {
  1158. g_CDF.uShowWindow = bResShowMin;
  1159. } else {
  1160. g_CDF.uShowWindow = bResShowMax;
  1161. }
  1162. return TRUE;
  1163. }
  1164. //###########################################################################
  1165. //# ####################################################
  1166. //# FINISHMSG PAGE ####################################################
  1167. //# ####################################################
  1168. //###########################################################################
  1169. //***************************************************************************
  1170. //* *
  1171. //* NAME: FinishMsgInit *
  1172. //* *
  1173. //* SYNOPSIS: Called when this page is displayed. *
  1174. //* *
  1175. //* REQUIRES: hDlg: Dialog window *
  1176. //* fFirstInit: TRUE if this is the first time the dialog is *
  1177. //* initialized, FALSE if this InitProc has been *
  1178. //* called before (e.g. went past this page and *
  1179. //* backed up). *
  1180. //* *
  1181. //* RETURNS: BOOL: Always TRUE *
  1182. //* *
  1183. //***************************************************************************
  1184. BOOL FinishMsgInit( HWND hDlg, BOOL fFirstInit )
  1185. {
  1186. SetFontForControl(hDlg, IDC_EDIT_FINISHMSG);
  1187. SendDlgItemMessage( hDlg, IDC_EDIT_FINISHMSG, EM_LIMITTEXT, MAX_FINISHMSG-2, 0L );
  1188. SetDlgItemText( hDlg, IDC_EDIT_FINISHMSG, g_CDF.achFinishMsg );
  1189. if ( g_CDF.fFinishMsg ) {
  1190. CheckDlgButton( hDlg, IDC_RAD_NO_FINISHMSG, FALSE );
  1191. CheckDlgButton( hDlg, IDC_RAD_YES_FINISHMSG, TRUE );
  1192. EnableDlgItem( hDlg, IDC_EDIT_FINISHMSG, TRUE );
  1193. } else {
  1194. CheckDlgButton( hDlg, IDC_RAD_NO_FINISHMSG, TRUE );
  1195. CheckDlgButton( hDlg, IDC_RAD_YES_FINISHMSG, FALSE );
  1196. EnableDlgItem( hDlg, IDC_EDIT_FINISHMSG, FALSE );
  1197. }
  1198. return TRUE;
  1199. }
  1200. //***************************************************************************
  1201. //* *
  1202. //* NAME: FinishMsgCmd *
  1203. //* *
  1204. //* SYNOPSIS: Called when dialog control pressed on page. *
  1205. //* *
  1206. //* REQUIRES: hDlg: Dialog window *
  1207. //* uCtrlID: Control ID of control that was touched *
  1208. //* pfGotoPage: If TRUE, goto the page puNextPage *
  1209. //* puNextPage: Proc can fill this with next page to go to *
  1210. //* pfKeepHistory: Page will not be kept in history if proc *
  1211. //* fills this in with FALSE. *
  1212. //* *
  1213. //* RETURNS: BOOL: *
  1214. //* *
  1215. //***************************************************************************
  1216. BOOL FinishMsgCmd( HWND hDlg, UINT uCtrlID, BOOL *pfGotoPage,
  1217. UINT *puNextPage, BOOL *pfKeepHistory )
  1218. {
  1219. switch ( uCtrlID ) {
  1220. case IDC_RAD_YES_FINISHMSG:
  1221. EnableDlgItem( hDlg, IDC_EDIT_FINISHMSG, TRUE );
  1222. break;
  1223. case IDC_RAD_NO_FINISHMSG:
  1224. EnableDlgItem( hDlg, IDC_EDIT_FINISHMSG, FALSE );
  1225. break;
  1226. }
  1227. return TRUE;
  1228. }
  1229. //***************************************************************************
  1230. //* *
  1231. //* NAME: FinishMsgOK *
  1232. //* *
  1233. //* SYNOPSIS: Called when Next or Back btns pressed on this page. *
  1234. //* *
  1235. //* REQUIRES: hDlg: Dialog window *
  1236. //* fForward: TRUE if 'Next' was pressed, FALSE if 'Back' *
  1237. //* puNextPage: if 'Next' was pressed, proc can fill this *
  1238. //* in with next page to go to. This parameter *
  1239. //* is ingored if 'Back' was pressed. *
  1240. //* pfKeepHistory: Page will not be kept in history if proc *
  1241. //* fills this in with FALSE. *
  1242. //* *
  1243. //* RETURNS: BOOL: TRUE means turn to next page. FALSE to keep *
  1244. //* the current page. *
  1245. //* *
  1246. //***************************************************************************
  1247. BOOL FinishMsgOK( HWND hDlg, BOOL fForward, UINT *puNextPage,
  1248. BOOL *pfKeepHistory )
  1249. {
  1250. ASSERT( puNextPage );
  1251. GetDlgItemText( hDlg, IDC_EDIT_FINISHMSG, g_CDF.achFinishMsg,
  1252. sizeof(g_CDF.achFinishMsg) );
  1253. if ( IsDlgButtonChecked( hDlg, IDC_RAD_YES_FINISHMSG ) ) {
  1254. g_CDF.fFinishMsg = TRUE;
  1255. } else {
  1256. g_CDF.fFinishMsg = FALSE;
  1257. }
  1258. if ( fForward ) {
  1259. if ( IsDlgButtonChecked( hDlg, IDC_RAD_YES_FINISHMSG ) ) {
  1260. if ( lstrlen( g_CDF.achFinishMsg ) == 0 ) {
  1261. DisplayFieldErrorMsg( hDlg, IDC_EDIT_FINISHMSG,
  1262. IDS_ERR_NO_FINISHMSG );
  1263. return FALSE;
  1264. }
  1265. }
  1266. }
  1267. return TRUE;
  1268. }
  1269. //###########################################################################
  1270. //# ####################################################
  1271. //# TARGET PAGE ####################################################
  1272. //# ####################################################
  1273. //###########################################################################
  1274. //***************************************************************************
  1275. //* *
  1276. //* NAME: TargetInit *
  1277. //* *
  1278. //* SYNOPSIS: Called when this page is displayed. *
  1279. //* *
  1280. //* REQUIRES: hDlg: Dialog window *
  1281. //* fFirstInit: TRUE if this is the first time the dialog is *
  1282. //* initialized, FALSE if this InitProc has been *
  1283. //* called before (e.g. went past this page and *
  1284. //* backed up). *
  1285. //* *
  1286. //* RETURNS: BOOL: Always TRUE *
  1287. //* *
  1288. //***************************************************************************
  1289. BOOL TargetInit( HWND hDlg, BOOL fFirstInit )
  1290. {
  1291. SetFontForControl(hDlg, IDC_EDIT_TARGET);
  1292. SetDlgItemText( hDlg, IDC_EDIT_TARGET, g_CDF.achTarget );
  1293. if ( !(g_CDF.uExtractOpt & EXTRACTOPT_UI_NO) )
  1294. CheckDlgButton( hDlg, IDC_HIDEEXTRACTUI, FALSE );
  1295. else
  1296. CheckDlgButton( hDlg, IDC_HIDEEXTRACTUI, TRUE );
  1297. if ( g_CDF.uExtractOpt & EXTRACTOPT_LFN_YES )
  1298. CheckDlgButton( hDlg, IDC_USE_LFN, TRUE );
  1299. else
  1300. CheckDlgButton( hDlg, IDC_USE_LFN, FALSE );
  1301. return TRUE;
  1302. }
  1303. //***************************************************************************
  1304. //* *
  1305. //* NAME: TargetCmd *
  1306. //* *
  1307. //* SYNOPSIS: Called when dialog control pressed on page. *
  1308. //* *
  1309. //* REQUIRES: hDlg: Dialog window *
  1310. //* uCtrlID: Control ID of control that was touched *
  1311. //* pfGotoPage: If TRUE, goto the page puNextPage *
  1312. //* puNextPage: Proc can fill this with next page to go to *
  1313. //* pfKeepHistory: Page will not be kept in history if proc *
  1314. //* fills this in with FALSE. *
  1315. //* *
  1316. //* RETURNS: BOOL: *
  1317. //* *
  1318. //***************************************************************************
  1319. BOOL TargetCmd( HWND hDlg, UINT uCtrlID, BOOL *pfGotoPage, UINT *puNextPage,
  1320. BOOL *pfKeepHistory )
  1321. {
  1322. CHAR achFilename[MAX_PATH] = { '\0' };
  1323. BOOL fResult;
  1324. switch ( uCtrlID )
  1325. {
  1326. case IDC_BUT_BROWSE:
  1327. fResult = MySave( hDlg, IDS_FILTER_EXE,
  1328. achFilename, sizeof(achFilename), 0,
  1329. NULL, NULL, EXT_EXE_NODOT );
  1330. if ( fResult ) {
  1331. SetDlgItemText( hDlg, IDC_EDIT_TARGET, achFilename );
  1332. }
  1333. break;
  1334. case IDC_USE_LFN:
  1335. if ( IsDlgButtonChecked( hDlg, IDC_USE_LFN ) && (g_CDF.uPackPurpose != IDC_CMD_EXTRACT) )
  1336. {
  1337. if ( MsgBox( hDlg, IDS_WARN_USELFN, MB_ICONQUESTION, MB_YESNO) == IDNO )
  1338. {
  1339. CheckDlgButton( hDlg, IDC_USE_LFN, FALSE );
  1340. }
  1341. }
  1342. break;
  1343. }
  1344. return TRUE;
  1345. }
  1346. //***************************************************************************
  1347. //* *
  1348. //* NAME: TargetOK *
  1349. //* *
  1350. //* SYNOPSIS: Called when Next or Back btns pressed on this page. *
  1351. //* *
  1352. //* REQUIRES: hDlg: Dialog window *
  1353. //* fForward: TRUE if 'Next' was pressed, FALSE if 'Back' *
  1354. //* puNextPage: if 'Next' was pressed, proc can fill this *
  1355. //* in with next page to go to. This parameter *
  1356. //* is ingored if 'Back' was pressed. *
  1357. //* pfKeepHistory: Page will not be kept in history if proc *
  1358. //* fills this in with FALSE. *
  1359. //* *
  1360. //* RETURNS: BOOL: TRUE means turn to next page. FALSE to keep *
  1361. //* the current page. *
  1362. //* *
  1363. //***************************************************************************
  1364. BOOL TargetOK( HWND hDlg, BOOL fForward, UINT *puNextPage,
  1365. BOOL *pfKeepHistory )
  1366. {
  1367. LPSTR szTemp;
  1368. LPSTR szExt;
  1369. ASSERT( puNextPage );
  1370. GetDlgItemText( hDlg, IDC_EDIT_TARGET, g_CDF.achTarget,
  1371. sizeof(g_CDF.achTarget) );
  1372. RemoveBlanks( g_CDF.achTarget );
  1373. if ( fForward )
  1374. {
  1375. if ( lstrlen( g_CDF.achTarget ) == 0 )
  1376. {
  1377. DisplayFieldErrorMsg( hDlg, IDC_EDIT_TARGET, IDS_ERR_NO_TARGET );
  1378. return FALSE;
  1379. }
  1380. if ( !GetFullPathName( g_CDF.achTarget, sizeof(g_CDF.achTarget),
  1381. g_CDF.achTarget, &szTemp ) )
  1382. {
  1383. SysErrorMsg( hDlg );
  1384. return FALSE;
  1385. }
  1386. // make sure that the path exists
  1387. if ( !MakeDirectory( hDlg, g_CDF.achTarget, TRUE ) )
  1388. return FALSE;
  1389. if ( !(szExt = ANSIStrRChr(g_CDF.achTarget, '.')) || lstrcmpi( szExt, achExtEXE ) )
  1390. {
  1391. lstrcat( g_CDF.achTarget, achExtEXE );
  1392. }
  1393. // if goal is extract files only, no need for reboot page
  1394. if ( g_CDF.uPackPurpose == IDC_CMD_EXTRACT )
  1395. {
  1396. *puNextPage = ORD_PAGE_SAVE;
  1397. }
  1398. else
  1399. {
  1400. // if you are in TARGET page, you should always jump over TARGET_CAB page
  1401. *puNextPage = ORD_PAGE_REBOOT;
  1402. }
  1403. g_CDF.uExtractOpt &= ~(EXTRACTOPT_UI_NO | EXTRACTOPT_LFN_YES);
  1404. if ( IsDlgButtonChecked( hDlg, IDC_HIDEEXTRACTUI ) )
  1405. g_CDF.uExtractOpt |= EXTRACTOPT_UI_NO;
  1406. if ( IsDlgButtonChecked( hDlg, IDC_USE_LFN ) )
  1407. g_CDF.uExtractOpt |= EXTRACTOPT_LFN_YES;
  1408. MyProcessLFNCmd( g_CDF.achOrigiInstallCmd, g_CDF.achInstallCmd );
  1409. MyProcessLFNCmd( g_CDF.achOrigiPostInstCmd, g_CDF.achPostInstCmd );
  1410. }
  1411. return TRUE;
  1412. }
  1413. //###########################################################################
  1414. //# ####################################################
  1415. //# TARGET_CAB PAGE ####################################################
  1416. //# ####################################################
  1417. //###########################################################################
  1418. //***************************************************************************
  1419. //* *
  1420. //* NAME: TargetCABInit *
  1421. //* *
  1422. //* SYNOPSIS: Called when this page is displayed. *
  1423. //* *
  1424. //* REQUIRES: hDlg: Dialog window *
  1425. //* fFirstInit: TRUE if this is the first time the dialog is *
  1426. //* initialized, FALSE if this InitProc has been *
  1427. //* called before (e.g. went past this page and *
  1428. //* backed up). *
  1429. //* *
  1430. //* RETURNS: BOOL: Always TRUE *
  1431. //* *
  1432. //***************************************************************************
  1433. BOOL TargetCABInit( HWND hDlg, BOOL fFirstInit )
  1434. {
  1435. int i;
  1436. LRESULT nCurSel;
  1437. SetFontForControl(hDlg, IDC_EDIT_TARGET);
  1438. SetDlgItemText( hDlg, IDC_EDIT_TARGET, g_CDF.achTarget );
  1439. // init CB box
  1440. if ( !fFirstInit )
  1441. {
  1442. // cleanup old settings
  1443. SendDlgItemMessage( hDlg, IDC_CB_RESVCABSP, CB_RESETCONTENT, 0, 0 );
  1444. for ( i = 0; i<4; i++ )
  1445. {
  1446. nCurSel = SendDlgItemMessage( hDlg, IDC_CB_RESVCABSP, CB_ADDSTRING, 0, (LPARAM)pResvSizes[i] );
  1447. if ( (nCurSel == (LRESULT)CB_ERR) || (nCurSel == (LRESULT)CB_ERRSPACE) )
  1448. {
  1449. ErrorMsg( hDlg, IDS_ERR_NO_MEMORY );
  1450. return FALSE;
  1451. }
  1452. }
  1453. if ( g_CDF.uExtractOpt & CAB_RESVSP2K )
  1454. i = 1;
  1455. else if ( g_CDF.uExtractOpt & CAB_RESVSP4K )
  1456. i = 2;
  1457. else if ( g_CDF.uExtractOpt & CAB_RESVSP6K )
  1458. i = 3;
  1459. else
  1460. i = 0;
  1461. if ( SendDlgItemMessage( hDlg, IDC_CB_RESVCABSP, CB_SETCURSEL, (WPARAM)i, (LPARAM)0 ) == (LRESULT)CB_ERR )
  1462. {
  1463. SendDlgItemMessage( hDlg, IDC_CB_RESVCABSP, CB_SETCURSEL, (WPARAM)0,(LPARAM)0 );
  1464. }
  1465. }
  1466. // init Check boxes
  1467. if ( g_CDF.uExtractOpt & CAB_FIXEDSIZE )
  1468. CheckDlgButton( hDlg, IDC_MULTIPLE_CAB, TRUE );
  1469. else
  1470. CheckDlgButton( hDlg, IDC_MULTIPLE_CAB, FALSE );
  1471. if ( g_CDF.uExtractOpt & EXTRACTOPT_LFN_YES )
  1472. CheckDlgButton( hDlg, IDC_USE_LFN, TRUE );
  1473. else
  1474. CheckDlgButton( hDlg, IDC_USE_LFN, FALSE );
  1475. return TRUE;
  1476. }
  1477. //***************************************************************************
  1478. //* *
  1479. //* NAME: TargetCABCmd *
  1480. //* *
  1481. //* SYNOPSIS: Called when dialog control pressed on page. *
  1482. //* *
  1483. //* REQUIRES: hDlg: Dialog window *
  1484. //* uCtrlID: Control ID of control that was touched *
  1485. //* pfGotoPage: If TRUE, goto the page puNextPage *
  1486. //* puNextPage: Proc can fill this with next page to go to *
  1487. //* pfKeepHistory: Page will not be kept in history if proc *
  1488. //* fills this in with FALSE. *
  1489. //* *
  1490. //* RETURNS: BOOL: *
  1491. //* *
  1492. //***************************************************************************
  1493. BOOL TargetCABCmd( HWND hDlg, UINT uCtrlID, BOOL *pfGotoPage, UINT *puNextPage,
  1494. BOOL *pfKeepHistory )
  1495. {
  1496. CHAR achFilename[MAX_PATH] = { '\0' };
  1497. BOOL fResult;
  1498. switch ( uCtrlID )
  1499. {
  1500. case IDC_BUT_BROWSE:
  1501. fResult = MySave( hDlg, IDS_FILTER_CAB,
  1502. achFilename, sizeof(achFilename), 0,
  1503. NULL, NULL, EXT_CAB_NODOT );
  1504. if ( fResult ) {
  1505. SetDlgItemText( hDlg, IDC_EDIT_TARGET, achFilename );
  1506. }
  1507. break;
  1508. }
  1509. return TRUE;
  1510. }
  1511. //***************************************************************************
  1512. //* *
  1513. //* NAME: TargetCABOK *
  1514. //* *
  1515. //* SYNOPSIS: Called when Next or Back btns pressed on this page. *
  1516. //* *
  1517. //* REQUIRES: hDlg: Dialog window *
  1518. //* fForward: TRUE if 'Next' was pressed, FALSE if 'Back' *
  1519. //* puNextPage: if 'Next' was pressed, proc can fill this *
  1520. //* in with next page to go to. This parameter *
  1521. //* is ingored if 'Back' was pressed. *
  1522. //* pfKeepHistory: Page will not be kept in history if proc *
  1523. //* fills this in with FALSE. *
  1524. //* *
  1525. //* RETURNS: BOOL: TRUE means turn to next page. FALSE to keep *
  1526. //* the current page. *
  1527. //* *
  1528. //***************************************************************************
  1529. BOOL TargetCABOK( HWND hDlg, BOOL fForward, UINT *puNextPage,
  1530. BOOL *pfKeepHistory )
  1531. {
  1532. LPSTR szTemp;
  1533. LPSTR szExt;
  1534. LRESULT nCurSel;
  1535. ASSERT( puNextPage );
  1536. GetDlgItemText( hDlg, IDC_EDIT_TARGET, g_CDF.achTarget,
  1537. sizeof(g_CDF.achTarget) );
  1538. RemoveBlanks( g_CDF.achTarget );
  1539. if ( fForward )
  1540. {
  1541. if ( lstrlen( g_CDF.achTarget ) == 0 )
  1542. {
  1543. DisplayFieldErrorMsg( hDlg, IDC_EDIT_TARGET, IDS_ERR_NO_TARGET );
  1544. return FALSE;
  1545. }
  1546. // get the CAB format options
  1547. //
  1548. g_CDF.uExtractOpt &= ~(CAB_FIXEDSIZE | EXTRACTOPT_LFN_YES);
  1549. g_CDF.uExtractOpt &= ~(CAB_RESVSP2K | CAB_RESVSP4K | CAB_RESVSP6K );
  1550. nCurSel = SendDlgItemMessage( hDlg, IDC_CB_RESVCABSP, CB_GETCURSEL, (WPARAM)0,(LPARAM)0 );
  1551. if ( nCurSel != (LRESULT)CB_ERR )
  1552. {
  1553. switch( nCurSel )
  1554. {
  1555. case 1:
  1556. g_CDF.uExtractOpt |= CAB_RESVSP2K;
  1557. break;
  1558. case 2:
  1559. g_CDF.uExtractOpt |= CAB_RESVSP4K;
  1560. break;
  1561. case 3:
  1562. g_CDF.uExtractOpt |= CAB_RESVSP6K;
  1563. break;
  1564. }
  1565. }
  1566. if ( IsDlgButtonChecked( hDlg, IDC_MULTIPLE_CAB ) )
  1567. g_CDF.uExtractOpt |= CAB_FIXEDSIZE;
  1568. if ( IsDlgButtonChecked( hDlg, IDC_USE_LFN ) )
  1569. g_CDF.uExtractOpt |= EXTRACTOPT_LFN_YES;
  1570. // make sure CAB file name is 8.3 format
  1571. //
  1572. if ( !MakeCabName( hDlg, g_CDF.achTarget, g_CDF.achCABPath ) )
  1573. {
  1574. return FALSE;
  1575. }
  1576. if ( g_CDF.uExtractOpt & CAB_FIXEDSIZE )
  1577. {
  1578. // only user choose to get layout inf name and cab label
  1579. *puNextPage = ORD_PAGE_CABLABEL;
  1580. }
  1581. else
  1582. {
  1583. // only user choose to create CAB only get this page
  1584. // therefore, for sure no reboot page needed!
  1585. *puNextPage = ORD_PAGE_SAVE;
  1586. }
  1587. }
  1588. return TRUE;
  1589. }
  1590. //###########################################################################
  1591. //# ####################################################
  1592. //# CABLABEL PAGE ####################################################
  1593. //# ####################################################
  1594. //###########################################################################
  1595. //***************************************************************************
  1596. //* *
  1597. //* NAME: CABLABEL *
  1598. //* *
  1599. //* SYNOPSIS: Called when this page is displayed. *
  1600. //* *
  1601. //* REQUIRES: hDlg: Dialog window *
  1602. //* fFirstInit: TRUE if this is the first time the dialog is *
  1603. //* initialized, FALSE if this InitProc has been *
  1604. //* called before (e.g. went past this page and *
  1605. //* backed up). *
  1606. //* *
  1607. //* RETURNS: BOOL: Always TRUE *
  1608. //* *
  1609. //***************************************************************************
  1610. BOOL CabLabelInit( HWND hDlg, BOOL fFirstInit )
  1611. {
  1612. SetFontForControl(hDlg, IDC_EDIT_LAYOUTINF);
  1613. SetFontForControl(hDlg, IDC_EDIT_CABLABEL);
  1614. SendDlgItemMessage( hDlg, IDC_EDIT_LAYOUTINF, EM_LIMITTEXT, MAX_PATH-1, 0 );
  1615. SendDlgItemMessage( hDlg, IDC_EDIT_CABLABEL, EM_LIMITTEXT, MAX_PATH-1, 0 );
  1616. SetDlgItemText( hDlg, IDC_EDIT_LAYOUTINF, g_CDF.achINF );
  1617. SetDlgItemText( hDlg, IDC_EDIT_CABLABEL, g_CDF.szCabLabel );
  1618. return TRUE;
  1619. }
  1620. //***************************************************************************
  1621. //* *
  1622. //* NAME: CabLabelCmd *
  1623. //* *
  1624. //* SYNOPSIS: Called when dialog control pressed on page. *
  1625. //* *
  1626. //* REQUIRES: hDlg: Dialog window *
  1627. //* uCtrlID: Control ID of control that was touched *
  1628. //* pfGotoPage: If TRUE, goto the page puNextPage *
  1629. //* puNextPage: Proc can fill this with next page to go to *
  1630. //* pfKeepHistory: Page will not be kept in history if proc *
  1631. //* fills this in with FALSE. *
  1632. //* *
  1633. //* RETURNS: BOOL: *
  1634. //* *
  1635. //***************************************************************************
  1636. BOOL CabLabelCmd( HWND hDlg, UINT uCtrlID, BOOL *pfGotoPage, UINT *puNextPage,
  1637. BOOL *pfKeepHistory )
  1638. {
  1639. CHAR achFilename[MAX_PATH] = { '\0' };
  1640. BOOL fResult;
  1641. switch ( uCtrlID )
  1642. {
  1643. case IDC_BUT_BROWSE:
  1644. fResult = MySave( hDlg, IDS_FILTER_INF,
  1645. achFilename, sizeof(achFilename), 0,
  1646. NULL, NULL, EXT_INF_NODOT );
  1647. if ( fResult ) {
  1648. SetDlgItemText( hDlg, IDC_EDIT_LAYOUTINF, achFilename );
  1649. }
  1650. break;
  1651. }
  1652. return TRUE;
  1653. }
  1654. //***************************************************************************
  1655. //* *
  1656. //* NAME: CabLabelOK *
  1657. //* *
  1658. //* SYNOPSIS: Called when Next or Back btns pressed on this page. *
  1659. //* *
  1660. //* REQUIRES: hDlg: Dialog window *
  1661. //* fForward: TRUE if 'Next' was pressed, FALSE if 'Back' *
  1662. //* puNextPage: if 'Next' was pressed, proc can fill this *
  1663. //* in with next page to go to. This parameter *
  1664. //* is ingored if 'Back' was pressed. *
  1665. //* pfKeepHistory: Page will not be kept in history if proc *
  1666. //* fills this in with FALSE. *
  1667. //* *
  1668. //* RETURNS: BOOL: TRUE means turn to next page. FALSE to keep *
  1669. //* the current page. *
  1670. //* *
  1671. //***************************************************************************
  1672. BOOL CabLabelOK( HWND hDlg, BOOL fForward, UINT *puNextPage,BOOL *pfKeepHistory )
  1673. {
  1674. LPSTR szTemp;
  1675. LPSTR szExt;
  1676. ASSERT( puNextPage );
  1677. GetDlgItemText( hDlg, IDC_EDIT_LAYOUTINF, g_CDF.achINF,sizeof(g_CDF.achINF) );
  1678. GetDlgItemText( hDlg, IDC_EDIT_CABLABEL, g_CDF.szCabLabel,sizeof(g_CDF.szCabLabel) );
  1679. RemoveBlanks( g_CDF.achINF );
  1680. if ( fForward )
  1681. {
  1682. if ( lstrlen( g_CDF.achINF ) == 0 )
  1683. {
  1684. // use the default one
  1685. lstrcpy( g_CDF.achINF, CABPACK_INFFILE );
  1686. }
  1687. if ( !GetFullPathName( g_CDF.achINF, sizeof(g_CDF.achINF),
  1688. g_CDF.achINF, &szTemp ) )
  1689. {
  1690. SysErrorMsg( hDlg );
  1691. return FALSE;
  1692. }
  1693. if ( !(szExt = strchr(szTemp, '.')) )
  1694. {
  1695. lstrcat( szTemp, achExtINF );
  1696. }
  1697. else if ( lstrcmpi( szExt, achExtINF) )
  1698. {
  1699. lstrcpy( szExt, achExtINF );
  1700. }
  1701. *puNextPage = ORD_PAGE_SAVE;
  1702. }
  1703. return TRUE;
  1704. }
  1705. //###########################################################################
  1706. //# ####################################################
  1707. //# REBOOT PAGE ####################################################
  1708. //# ####################################################
  1709. //###########################################################################
  1710. //***************************************************************************
  1711. //* *
  1712. //* NAME: Reboot *
  1713. //* *
  1714. //* SYNOPSIS: Called when this page is displayed. *
  1715. //* *
  1716. //* REQUIRES: hDlg: Dialog window *
  1717. //* fFirstInit: TRUE if this is the first time the dialog is *
  1718. //* initialized, FALSE if this InitProc has been *
  1719. //* called before (e.g. went past this page and *
  1720. //* backed up). *
  1721. //* *
  1722. //* RETURNS: BOOL: Always TRUE *
  1723. //* *
  1724. //***************************************************************************
  1725. BOOL RebootInit( HWND hDlg, BOOL fFirstInit )
  1726. {
  1727. BOOL state;
  1728. if ( !(g_CDF.dwReboot & REBOOT_YES) )
  1729. {
  1730. CheckDlgButton( hDlg, IDC_REBOOT_NO, TRUE );
  1731. CheckDlgButton( hDlg, IDC_REBOOT_ALWAYS, FALSE );
  1732. CheckDlgButton( hDlg, IDC_REBOOT_IFNEED, FALSE );
  1733. state = FALSE;
  1734. }
  1735. else
  1736. {
  1737. CheckDlgButton( hDlg, IDC_REBOOT_NO, FALSE );
  1738. CheckDlgButton( hDlg, IDC_REBOOT_ALWAYS, (g_CDF.dwReboot & REBOOT_ALWAYS) );
  1739. CheckDlgButton( hDlg, IDC_REBOOT_IFNEED, !(g_CDF.dwReboot & REBOOT_ALWAYS) );
  1740. state = TRUE;
  1741. }
  1742. CheckDlgButton( hDlg, IDC_REBOOT_SILENT, (g_CDF.dwReboot & REBOOT_SILENT) );
  1743. EnableWindow( GetDlgItem(hDlg, IDC_REBOOT_SILENT), state );
  1744. return TRUE;
  1745. }
  1746. //***************************************************************************
  1747. //* *
  1748. //* NAME: RebootCmd *
  1749. //* *
  1750. //* SYNOPSIS: Called when dialog control pressed on page. *
  1751. //* *
  1752. //* REQUIRES: hDlg: Dialog window *
  1753. //* uCtrlID: Control ID of control that was touched *
  1754. //* pfGotoPage: If TRUE, goto the page puNextPage *
  1755. //* puNextPage: Proc can fill this with next page to go to *
  1756. //* pfKeepHistory: Page will not be kept in history if proc *
  1757. //* fills this in with FALSE. *
  1758. //* *
  1759. //* RETURNS: BOOL: *
  1760. //* *
  1761. //***************************************************************************
  1762. BOOL RebootCmd( HWND hDlg, UINT uCtrlID, BOOL *pfGotoPage, UINT *puNextPage,
  1763. BOOL *pfKeepHistory )
  1764. {
  1765. BOOL state;
  1766. state = IsDlgButtonChecked( hDlg, IDC_REBOOT_NO );
  1767. EnableWindow( GetDlgItem(hDlg, IDC_REBOOT_SILENT), !state );
  1768. return TRUE;
  1769. }
  1770. //***************************************************************************
  1771. //* *
  1772. //* NAME: RebootOK *
  1773. //* *
  1774. //* SYNOPSIS: Called when Next or Back btns pressed on this page. *
  1775. //* *
  1776. //* REQUIRES: hDlg: Dialog window *
  1777. //* fForward: TRUE if 'Next' was pressed, FALSE if 'Back' *
  1778. //* puNextPage: if 'Next' was pressed, proc can fill this *
  1779. //* in with next page to go to. This parameter *
  1780. //* is ingored if 'Back' was pressed. *
  1781. //* pfKeepHistory: Page will not be kept in history if proc *
  1782. //* fills this in with FALSE. *
  1783. //* *
  1784. //* RETURNS: BOOL: TRUE means turn to next page. FALSE to keep *
  1785. //* the current page. *
  1786. //* *
  1787. //***************************************************************************
  1788. BOOL RebootOK( HWND hDlg, BOOL fForward, UINT *puNextPage, BOOL *pfKeepHistory )
  1789. {
  1790. ASSERT( puNextPage );
  1791. g_CDF.dwReboot = 0;
  1792. if ( !IsDlgButtonChecked( hDlg, IDC_REBOOT_NO ) )
  1793. {
  1794. g_CDF.dwReboot |= REBOOT_YES;
  1795. if ( IsDlgButtonChecked( hDlg, IDC_REBOOT_ALWAYS ) )
  1796. g_CDF.dwReboot |= REBOOT_ALWAYS;
  1797. }
  1798. if ( IsDlgButtonChecked( hDlg, IDC_REBOOT_SILENT ) )
  1799. g_CDF.dwReboot |= REBOOT_SILENT;
  1800. return TRUE;
  1801. }
  1802. //###########################################################################
  1803. //# ####################################################
  1804. //# SAVE PAGE ####################################################
  1805. //# ####################################################
  1806. //###########################################################################
  1807. //***************************************************************************
  1808. //* *
  1809. //* NAME: SaveInit *
  1810. //* *
  1811. //* SYNOPSIS: Called when this page is displayed. *
  1812. //* *
  1813. //* REQUIRES: hDlg: Dialog window *
  1814. //* fFirstInit: TRUE if this is the first time the dialog is *
  1815. //* initialized, FALSE if this InitProc has been *
  1816. //* called before (e.g. went past this page and *
  1817. //* backed up). *
  1818. //* *
  1819. //* RETURNS: BOOL: Always TRUE *
  1820. //* *
  1821. //***************************************************************************
  1822. BOOL SaveInit( HWND hDlg, BOOL fFirstInit )
  1823. {
  1824. PSTR pszTmp;
  1825. char szPath[MAX_PATH];
  1826. SetFontForControl(hDlg, IDC_EDIT_SAVE_CDF);
  1827. if ( g_CDF.achFilename[0] == 0 )
  1828. {
  1829. char ch;
  1830. pszTmp = ANSIStrRChr( g_CDF.achTarget, '.' );
  1831. if ( pszTmp )
  1832. {
  1833. ch = *pszTmp;
  1834. *pszTmp = '\0';
  1835. lstrcpy( szPath, g_CDF.achTarget );
  1836. *pszTmp = ch;
  1837. lstrcat( szPath, EXT_SED );
  1838. pszTmp = szPath;
  1839. }
  1840. else
  1841. pszTmp = g_CDF.achTarget;
  1842. }
  1843. else
  1844. {
  1845. pszTmp = ANSIStrRChr( g_CDF.achFilename, '.' );
  1846. if ( pszTmp && !lstrcmpi( pszTmp, EXT_CDF ) )
  1847. lstrcpy( pszTmp, EXT_SED );
  1848. pszTmp = g_CDF.achFilename;
  1849. }
  1850. SetDlgItemText( hDlg, IDC_EDIT_SAVE_CDF, pszTmp );
  1851. if ( g_CDF.fSave ) {
  1852. CheckDlgButton( hDlg, IDC_RAD_YES_SAVE, TRUE );
  1853. CheckDlgButton( hDlg, IDC_RAD_NO_SAVE, FALSE );
  1854. EnableDlgItem( hDlg, IDC_EDIT_SAVE_CDF, TRUE );
  1855. EnableDlgItem( hDlg, IDC_BUT_BROWSE, TRUE );
  1856. } else {
  1857. CheckDlgButton( hDlg, IDC_RAD_YES_SAVE, FALSE );
  1858. CheckDlgButton( hDlg, IDC_RAD_NO_SAVE, TRUE );
  1859. EnableDlgItem( hDlg, IDC_EDIT_SAVE_CDF, FALSE );
  1860. EnableDlgItem( hDlg, IDC_BUT_BROWSE, FALSE );
  1861. }
  1862. return TRUE;
  1863. }
  1864. //***************************************************************************
  1865. //* *
  1866. //* NAME: SaveCmd *
  1867. //* *
  1868. //* SYNOPSIS: Called when dialog control pressed on page. *
  1869. //* *
  1870. //* REQUIRES: hDlg: Dialog window *
  1871. //* uCtrlID: Control ID of control that was touched *
  1872. //* pfGotoPage: If TRUE, goto the page puNextPage *
  1873. //* puNextPage: Proc can fill this with next page to go to *
  1874. //* pfKeepHistory: Page will not be kept in history if proc *
  1875. //* fills this in with FALSE. *
  1876. //* *
  1877. //* RETURNS: BOOL: *
  1878. //* *
  1879. //***************************************************************************
  1880. BOOL SaveCmd( HWND hDlg, UINT uCtrlID, BOOL *pfGotoPage, UINT *puNextPage,
  1881. BOOL *pfKeepHistory )
  1882. {
  1883. CHAR achFilename[MAX_PATH] = { '\0' };
  1884. BOOL fResult;
  1885. switch ( uCtrlID ) {
  1886. case IDC_RAD_YES_SAVE:
  1887. EnableDlgItem( hDlg, IDC_EDIT_SAVE_CDF, TRUE );
  1888. EnableDlgItem( hDlg, IDC_BUT_BROWSE, TRUE );
  1889. break;
  1890. case IDC_RAD_NO_SAVE:
  1891. EnableDlgItem( hDlg, IDC_EDIT_SAVE_CDF, FALSE );
  1892. EnableDlgItem( hDlg, IDC_BUT_BROWSE, FALSE );
  1893. break;
  1894. case IDC_BUT_BROWSE:
  1895. fResult = MySave( hDlg, IDS_FILTER_CDF,
  1896. achFilename, sizeof(achFilename), 0,
  1897. NULL, NULL, EXT_SED_NODOT );
  1898. if ( fResult ) {
  1899. SetDlgItemText( hDlg, IDC_EDIT_SAVE_CDF, achFilename );
  1900. }
  1901. break;
  1902. }
  1903. return TRUE;
  1904. }
  1905. //***************************************************************************
  1906. //* *
  1907. //* NAME: SaveOK *
  1908. //* *
  1909. //* SYNOPSIS: Called when Next or Back btns pressed on this page. *
  1910. //* *
  1911. //* REQUIRES: hDlg: Dialog window *
  1912. //* fForward: TRUE if 'Next' was pressed, FALSE if 'Back' *
  1913. //* puNextPage: if 'Next' was pressed, proc can fill this *
  1914. //* in with next page to go to. This parameter *
  1915. //* is ingored if 'Back' was pressed. *
  1916. //* pfKeepHistory: Page will not be kept in history if proc *
  1917. //* fills this in with FALSE. *
  1918. //* *
  1919. //* RETURNS: BOOL: TRUE means turn to next page. FALSE to keep *
  1920. //* the current page. *
  1921. //* *
  1922. //***************************************************************************
  1923. BOOL SaveOK( HWND hDlg, BOOL fForward, UINT *puNextPage,
  1924. BOOL *pfKeepHistory )
  1925. {
  1926. LPSTR szTemp;
  1927. LPSTR szExt;
  1928. CHAR szCDF[MAX_PATH];
  1929. ASSERT( puNextPage );
  1930. GetDlgItemText( hDlg, IDC_EDIT_SAVE_CDF, szCDF, sizeof(szCDF) );
  1931. if ( fForward )
  1932. {
  1933. if ( IsDlgButtonChecked( hDlg, IDC_RAD_YES_SAVE ) )
  1934. {
  1935. if ( lstrlen( szCDF ) == 0 )
  1936. {
  1937. DisplayFieldErrorMsg( hDlg, IDC_EDIT_SAVE_CDF,
  1938. IDS_ERR_NO_SAVE_FILENAME );
  1939. return FALSE;
  1940. }
  1941. szExt = ANSIStrRChr( szCDF, '.' );
  1942. if ( !szExt || lstrcmpi( szExt, EXT_SED ) ) // not given extension
  1943. {
  1944. lstrcat( szCDF, EXT_SED );
  1945. }
  1946. if ( ! GetFullPathName( szCDF, sizeof(szCDF), szCDF, &szTemp ) )
  1947. {
  1948. SysErrorMsg( hDlg );
  1949. return FALSE;
  1950. }
  1951. // if there is existing CDF and is different name, copy it to new CDF first
  1952. if ( lstrlen(g_CDF.achFilename) && lstrcmpi( szCDF, g_CDF.achFilename) )
  1953. {
  1954. if ( FileExists(szCDF) && MsgBox1Param( NULL, IDS_WARN_OVERIDECDF, szCDF, MB_ICONQUESTION, MB_YESNO ) == IDNO )
  1955. return FALSE;
  1956. CopyFile( g_CDF.achFilename, szCDF, FALSE );
  1957. }
  1958. lstrcpy( g_CDF.achFilename, szCDF );
  1959. g_CDF.fSave = TRUE;
  1960. // make sure that the path exists
  1961. if ( !MakeDirectory( hDlg, g_CDF.achFilename, TRUE ) )
  1962. return FALSE;
  1963. }
  1964. else
  1965. g_CDF.fSave = FALSE;
  1966. }
  1967. else
  1968. {
  1969. // back, means that the filelist may change. Clean flag to prepare for next CDF out
  1970. CleanFileListWriteFlag();
  1971. }
  1972. return TRUE;
  1973. }
  1974. //###########################################################################
  1975. //# ####################################################
  1976. //# CREATE PAGE ####################################################
  1977. //# ####################################################
  1978. //###########################################################################
  1979. //***************************************************************************
  1980. //* *
  1981. //* NAME: CreateInit *
  1982. //* *
  1983. //* SYNOPSIS: Called when this page is displayed. *
  1984. //* *
  1985. //* REQUIRES: hDlg: Dialog window *
  1986. //* fFirstInit: TRUE if this is the first time the dialog is *
  1987. //* initialized, FALSE if this InitProc has been *
  1988. //* called before (e.g. went past this page and *
  1989. //* backed up). *
  1990. //* *
  1991. //* RETURNS: BOOL: Always TRUE *
  1992. //* *
  1993. //***************************************************************************
  1994. BOOL CreateInit( HWND hDlg, BOOL fFirstInit )
  1995. {
  1996. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_BACK | PSWIZB_NEXT );
  1997. SetFontForControl(hDlg, IDC_MEDIT_STATUS);
  1998. SetDlgItemText( hDlg, IDC_MEDIT_STATUS, "" );
  1999. if ( fFirstInit ) {
  2000. MEditSubClassWnd( GetDlgItem( hDlg, IDC_MEDIT_STATUS ),
  2001. (FARPROC) MEditSubProc );
  2002. }
  2003. ShowWindow( GetDlgItem( hDlg, IDC_TEXT_CREATE1 ), SW_SHOW );
  2004. ShowWindow( GetDlgItem( hDlg, IDC_TEXT_CREATE2 ), SW_HIDE );
  2005. ShowWindow( GetDlgItem( hDlg, IDC_TEXT_STATUS ), SW_HIDE );
  2006. ShowWindow( GetDlgItem( hDlg, IDC_MEDIT_STATUS ), SW_HIDE );
  2007. g_fFinish = FALSE;
  2008. return TRUE;
  2009. }
  2010. //***************************************************************************
  2011. //* *
  2012. //* NAME: CreateOK *
  2013. //* *
  2014. //* SYNOPSIS: Called when Next or Back btns pressed on this page. *
  2015. //* *
  2016. //* REQUIRES: hDlg: Dialog window *
  2017. //* fForward: TRUE if 'Next' was pressed, FALSE if 'Back' *
  2018. //* puNextPage: if 'Next' was pressed, proc can fill this *
  2019. //* in with next page to go to. This parameter *
  2020. //* is ingored if 'Back' was pressed. *
  2021. //* pfKeepHistory: Page will not be kept in history if proc *
  2022. //* fills this in with FALSE. *
  2023. //* *
  2024. //* RETURNS: BOOL: TRUE means turn to next page. FALSE to keep *
  2025. //* the current page. *
  2026. //* *
  2027. //***************************************************************************
  2028. BOOL CreateOK( HWND hDlg, BOOL fForward, UINT *puNextPage,
  2029. BOOL *pfKeepHistory )
  2030. {
  2031. ASSERT( puNextPage );
  2032. *pfKeepHistory = FALSE;
  2033. // fForward in this case indicates a click on the Finish button
  2034. if ( fForward ) {
  2035. if ( g_fFinish ) {
  2036. DeleteAllItems();
  2037. return TRUE;
  2038. }
  2039. PropSheet_SetWizButtons( GetParent( hDlg ), 0 );
  2040. EnableWindow(GetDlgItem(GetParent(hDlg), IDCANCEL), FALSE);
  2041. SetDlgItemText( hDlg, IDC_MEDIT_STATUS, "" );
  2042. ShowWindow( GetDlgItem( hDlg, IDC_TEXT_STATUS ), SW_SHOW );
  2043. ShowWindow( GetDlgItem( hDlg, IDC_MEDIT_STATUS ), SW_SHOW );
  2044. if ( ! MakePackage( hDlg ) ) {
  2045. EnableWindow(GetDlgItem(GetParent(hDlg), IDCANCEL), TRUE);
  2046. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_BACK | PSWIZB_NEXT );
  2047. return FALSE;
  2048. }
  2049. EnableWindow(GetDlgItem(GetParent(hDlg), IDCANCEL), TRUE);
  2050. if ( ! g_fFinish ) {
  2051. g_fFinish = TRUE;
  2052. ShowWindow( GetDlgItem( hDlg, IDC_TEXT_CREATE1 ), SW_HIDE );
  2053. ShowWindow( GetDlgItem( hDlg, IDC_TEXT_CREATE2 ), SW_SHOW );
  2054. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_BACK | PSWIZB_FINISH );
  2055. return FALSE;
  2056. }
  2057. }
  2058. return TRUE;
  2059. }
  2060. BOOL SetCurrSelect( HWND hDlg, UINT ctlId, LPSTR lpSelect )
  2061. {
  2062. LRESULT nCurSel;
  2063. BOOL fRet = FALSE;
  2064. if ( *lpSelect )
  2065. {
  2066. // Select the file that was last selected
  2067. nCurSel = SendDlgItemMessage( hDlg, ctlId, CB_FINDSTRINGEXACT, (WPARAM) -1,
  2068. (LPARAM) lpSelect );
  2069. if ( nCurSel != (LRESULT)CB_ERR )
  2070. {
  2071. SendDlgItemMessage( hDlg, ctlId, CB_SETCURSEL, (WPARAM)nCurSel, 0 );
  2072. fRet = TRUE;
  2073. }
  2074. else
  2075. {
  2076. fRet = SetDlgItemText( hDlg, ctlId, lpSelect );
  2077. }
  2078. }
  2079. return fRet;
  2080. }
  2081. void RemoveBlanks( LPSTR lpData )
  2082. {
  2083. CHAR achBuf[MAX_PATH];
  2084. int i = 0;
  2085. if ( !lpData || *lpData == 0)
  2086. {
  2087. return;
  2088. }
  2089. lstrcpy( achBuf, lpData );
  2090. while ( achBuf[i] && achBuf[i] == ' ' )
  2091. i++;
  2092. lstrcpy( lpData, achBuf+i );
  2093. }
  2094. // returns start of next field (or null if null), sets start to begining of the first field,
  2095. // with fields separated by separaters and nulls first separater after the first field
  2096. CHAR* ExtractField( CHAR **pstart, CHAR * separaters)
  2097. {
  2098. LPSTR start = *pstart;
  2099. int x = 0;
  2100. while(strchr(separaters, *start)) {
  2101. if(*start == 0)
  2102. return(NULL);
  2103. start++;
  2104. }
  2105. *pstart = start;
  2106. while(!strchr(separaters, start[x]) && (start[x] != 0))
  2107. x++;
  2108. if(start[x] == 0)
  2109. return(start + x);
  2110. start[x] = 0;
  2111. return(start + x + 1);
  2112. }
  2113. BOOL GetFileFromList( LPSTR lpFile, LPSTR lpFullPath )
  2114. {
  2115. PMYITEM pMyItem;
  2116. pMyItem = GetFirstItem();
  2117. while ( ! LastItem( pMyItem ) )
  2118. {
  2119. if ( !lstrcmpi( lpFile, GetItemSz( pMyItem, 0 ) ) )
  2120. {
  2121. lstrcpy( lpFullPath, GetItemSz( pMyItem, 1 ) );
  2122. lstrcat( lpFullPath, GetItemSz( pMyItem, 0 ) );
  2123. return TRUE;
  2124. }
  2125. pMyItem = GetNextItem( pMyItem );
  2126. }
  2127. return FALSE;
  2128. }
  2129. BOOL SetAdvDLLBit( LPSTR szInfFile )
  2130. {
  2131. CHAR szTempFile[MAX_PATH];
  2132. CHAR szBuf[SMALL_BUF_LEN];
  2133. szTempFile[0] = 0;
  2134. // you are here, we expects the file is from the package
  2135. if ( !GetFileFromList( szInfFile, szTempFile ) )
  2136. {
  2137. ErrorMsg( NULL, IDS_ERR_NO_CUSTOM );
  2138. return FALSE;
  2139. }
  2140. // If the key "AdvancedInf" is defined, then we set the ADVDLL bit.
  2141. // We don't care what the key is defined as -- we only care that it exists.
  2142. if ( GetPrivateProfileString( SEC_VERSION, KEY_ADVINF, "", szBuf, sizeof(szBuf), szTempFile )
  2143. > 0 )
  2144. {
  2145. g_CDF.uExtractOpt |= EXTRACTOPT_ADVDLL;
  2146. }
  2147. return TRUE;
  2148. }
  2149. BOOL SetCmdFromListWithCorrectForm( LPSTR szFile, LPSTR szOutCmd )
  2150. {
  2151. CHAR szTempFile[MAX_PATH];
  2152. LPSTR szShortFile;
  2153. // you are here, we expects the file is from the package
  2154. if ( GetFileFromList( szFile, szTempFile ) )
  2155. {
  2156. if ( !(g_CDF.uExtractOpt & EXTRACTOPT_LFN_YES) )
  2157. {
  2158. GetShortPathName( szTempFile, szTempFile, sizeof(szTempFile) );
  2159. szShortFile = ANSIStrRChr( szTempFile, '\\' );
  2160. lstrcpy( szOutCmd, szShortFile+1 );
  2161. }
  2162. else
  2163. {
  2164. lstrcpy( szTempFile, "\"" );
  2165. lstrcat( szTempFile, szFile );
  2166. lstrcat( szTempFile, "\"" );
  2167. lstrcpy( szOutCmd, szTempFile );
  2168. }
  2169. return TRUE;
  2170. }
  2171. return FALSE;
  2172. }
  2173. void MyProcessLFNCmd( LPSTR szOrigiCmd, LPSTR szOutCmd )
  2174. {
  2175. LPSTR szFirstField, szNextField;
  2176. CHAR szBuf[MAX_PATH];
  2177. // store the original form first
  2178. lstrcpy( szOutCmd, szOrigiCmd );
  2179. // Three cases for LFN command or its params:
  2180. // 1) Command has no params and is one of the files in the list;
  2181. // we make sure the command name is consistant with file in the CAB.
  2182. // 2) Command has params and is one of the files in the list;
  2183. // user has to put "..." around the LFN to get processed correctly.
  2184. // 3) Command is not one of the files in the list;
  2185. // user responsible to make sure the command in valid COMMAND-LINE format.
  2186. //
  2187. if ( SetCmdFromListWithCorrectForm( szOrigiCmd, szOutCmd ) )
  2188. {
  2189. // case 1)
  2190. return;
  2191. }
  2192. lstrcpy( szBuf, szOrigiCmd );
  2193. if ( szBuf[0] == '"' )
  2194. {
  2195. szFirstField = szBuf+1;
  2196. szNextField = ExtractField( &szFirstField, "\"" );
  2197. if ( szNextField && (*szNextField == '"') )
  2198. {
  2199. // special case for skipping the end of double quotes around the cmd
  2200. szNextField = CharNext( szNextField );
  2201. }
  2202. }
  2203. else
  2204. {
  2205. szFirstField = szBuf;
  2206. szNextField = ExtractField( &szFirstField, " " );
  2207. }
  2208. if ( SetCmdFromListWithCorrectForm( szFirstField, szOutCmd ) )
  2209. {
  2210. // case 2)
  2211. if ( szNextField && *szNextField )
  2212. {
  2213. lstrcat( szOutCmd, " " );
  2214. lstrcat( szOutCmd, szNextField );
  2215. }
  2216. }
  2217. // case 3) command is outside the package, you are on your own.
  2218. return;
  2219. }
  2220. BOOL CheckAdvBit( LPSTR szOrigiCommand )
  2221. {
  2222. CHAR szTmp[MAX_PATH];
  2223. LPSTR szNextField, szCurrField, szExt;
  2224. lstrcpy( szTmp, szOrigiCommand );
  2225. // check if the command is LFN name
  2226. if ( szTmp[0] == '"' )
  2227. {
  2228. szCurrField = &szTmp[1];
  2229. szNextField = ExtractField( &szCurrField, "\"" );
  2230. }
  2231. else
  2232. {
  2233. szCurrField = szTmp;
  2234. szNextField = ExtractField( &szCurrField, " " );
  2235. }
  2236. // check if this is a INF file command
  2237. if ( ((szExt = ANSIStrRChr( szCurrField, '.' )) != NULL) && !lstrcmpi( szExt, achExtINF ) )
  2238. {
  2239. if ( !SetAdvDLLBit( szCurrField ) )
  2240. return FALSE;
  2241. }
  2242. return TRUE;
  2243. }
  2244. void SysErrorMsg( HWND hWnd )
  2245. {
  2246. LPVOID lpMsg;
  2247. DWORD dwErr;
  2248. dwErr = GetLastError();
  2249. if ( FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER,
  2250. NULL, dwErr,
  2251. MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ),
  2252. (LPSTR)&lpMsg, 0, NULL ) )
  2253. {
  2254. MessageBox( hWnd, (LPSTR)lpMsg, g_CDF.achTitle, MB_ICONERROR|MB_OK
  2255. |((RunningOnWin95BiDiLoc() && IsBiDiLocalizedBinary(g_hInst,RT_VERSION, MAKEINTRESOURCE(VS_VERSION_INFO))) ? (MB_RIGHT | MB_RTLREADING) : 0));
  2256. LocalFree( lpMsg );
  2257. }
  2258. else
  2259. {
  2260. char szError[SMALL_BUF_LEN];
  2261. // should never be here, if so, post the original Win32 error code
  2262. ErrorMsg1Param( hWnd, IDS_ERR_SYSERROR, _itoa(dwErr, szError, 10) );
  2263. }
  2264. return;
  2265. }
  2266. void SetFontForControl(HWND hwnd, UINT uiID)
  2267. {
  2268. if (g_hFont)
  2269. {
  2270. SendDlgItemMessage(hwnd, uiID, WM_SETFONT, (WPARAM)g_hFont ,0L);
  2271. }
  2272. }
  2273. void CleanFileListWriteFlag()
  2274. {
  2275. PMYITEM pMyItem;
  2276. pMyItem = GetFirstItem();
  2277. while (!LastItem( pMyItem ) )
  2278. {
  2279. pMyItem->fWroteOut = FALSE;
  2280. pMyItem = GetNextItem( pMyItem );
  2281. }
  2282. }
  2283. BOOL MakeCabName( HWND hwnd, PSTR pszTarget, PSTR pszCab )
  2284. {
  2285. PSTR szTemp, szTemp1, szExt;
  2286. if ( !GetFullPathName( pszTarget, MAX_PATH, pszTarget, &szTemp1 ) )
  2287. {
  2288. SysErrorMsg( hwnd );
  2289. return FALSE;
  2290. }
  2291. // make sure that the path exists
  2292. if ( !MakeDirectory( hwnd, pszTarget, TRUE) )
  2293. return FALSE;
  2294. lstrcpy( pszCab, pszTarget );
  2295. szTemp = pszCab + lstrlen(pszCab) - lstrlen(szTemp1);
  2296. // make sure CAB file name is 8.3 format
  2297. //
  2298. szExt = strchr( szTemp, '.' );
  2299. if ( szExt )
  2300. {
  2301. *szExt = '\0';
  2302. }
  2303. if ( g_CDF.uExtractOpt & CAB_FIXEDSIZE )
  2304. {
  2305. // possible multiple CABs, so only take first 5 characters
  2306. //
  2307. if ( lstrlen( szTemp ) > 8 )
  2308. {
  2309. *(szTemp+8) = '\0' ;
  2310. if ( !strchr(szTemp, '*') )
  2311. lstrcpy( (szTemp+5), "_*" );
  2312. }
  2313. else if ( !strchr(szTemp, '*') )
  2314. {
  2315. if ( lstrlen( szTemp) > 5 )
  2316. {
  2317. lstrcpy( (szTemp+5), "_*" );
  2318. }
  2319. else
  2320. lstrcat( szTemp, "_*" );
  2321. }
  2322. }
  2323. else if ( lstrlen( szTemp ) > 8 )
  2324. {
  2325. DisplayFieldErrorMsg( hwnd, IDC_EDIT_TARGET, IDS_ERR_CABNAME );
  2326. return FALSE;
  2327. }
  2328. // add .CAB extension in
  2329. //
  2330. lstrcat( szTemp, ".CAB" );
  2331. return TRUE;
  2332. }