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.

694 lines
22 KiB

  1. /****************************************************************************\
  2. BTOOLBAR.C / OPK Wizard (OPKWIZ.EXE)
  3. Microsoft Confidential
  4. Copyright (c) Microsoft Corporation 1998
  5. All rights reserved
  6. Source file for the OPK Wizard that contains the external and internal
  7. functions used by the "IE Customize" wizard page.
  8. 10/99 - Brian Ku (BRIANK)
  9. Added this new source file for the IEAK integration as part of the
  10. Millennium rewrite.
  11. 09/2000 - Stephen Lodwick (STELO)
  12. Ported OPK Wizard to Whistler
  13. \****************************************************************************/
  14. //
  15. // Include File(s):
  16. //
  17. #include "pch.h"
  18. #include "wizard.h"
  19. #include "resource.h"
  20. /* Example:
  21. [BrowserToolbars]
  22. Caption0=Solitaire
  23. Action0=c:\windows\sol.exe
  24. Icon0=H:\iecust\icons\G.ico
  25. HotIcon0=H:\iecust\icons\C.ico
  26. Show0=1
  27. Caption1=Calc
  28. Action1=c:\windows\calc.exe
  29. Icon1=\\Opksrv\tools\iecust\icons\G.ICO
  30. HotIcon1=\\Opksrv\tools\iecust\icons\C.ICO
  31. Show1=1
  32. */
  33. //
  34. // Internal Defined Value(s):
  35. //
  36. #define INI_KEY_CAPTION0 _T("Caption%d")
  37. #define INI_KEY_ACTION0 _T("Action%d")
  38. #define INI_KEY_ICON0 _T("Icon%d")
  39. #define INI_KEY_HOTICON0 _T("HotIcon%d")
  40. #define INI_KEY_SHOW0 _T("Show%d")
  41. #define MAX_NAME 11
  42. //
  43. // Browser Toolbar Info
  44. //
  45. typedef struct _BTOOLBAR_BUTTON_INFO {
  46. TCHAR szCaption[MAX_NAME];
  47. TCHAR szAction[MAX_PATH];
  48. TCHAR szIconColor[MAX_PATH];
  49. TCHAR szIconGray[MAX_PATH];
  50. BOOL fShow;
  51. }BTOOLBAR_BUTTON_INFO, *PBTOOLBAR_BUTTON_INFO;
  52. //
  53. // Internal Globals
  54. //
  55. PGENERIC_LIST g_pgTbbiList; // Generic list of BTOOLBAR_INFO items
  56. PGENERIC_LIST* g_ppgTbbiNew = &g_pgTbbiList; // Pointer to next unallocated item in list
  57. PBTOOLBAR_BUTTON_INFO g_pbtbbiNew; // Browser Toolbar Popup Info item
  58. //
  59. // Internal Function Prototype(s):
  60. //
  61. static BOOL OnInitTb(HWND, HWND, LPARAM);
  62. static void OnCommandTb(HWND, INT, HWND, UINT);
  63. static void InitToolbarButtonList(HWND);
  64. static BOOL OnInitTbPopup(HWND, HWND, LPARAM);
  65. static void OnCommandTbPopup(HWND, INT, HWND, UINT);
  66. static void OnAddToolbar(HWND);
  67. static void OnEditToolbar(HWND);
  68. static void OnRemoveToolbar(HWND);
  69. static void SaveData(PGENERIC_LIST);
  70. static BOOL FSaveBToolbarButtonInfo(HWND hwnd, PBTOOLBAR_BUTTON_INFO pbtbbi);
  71. static void DisableButtons(HWND hwnd);
  72. void SaveBToolbar();
  73. LRESULT CALLBACK ToolbarPopupDlgProc(HWND, UINT, WPARAM, LPARAM);
  74. //
  75. // External Function(s):
  76. //
  77. LRESULT CALLBACK BToolbarsDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  78. {
  79. switch (uMsg)
  80. {
  81. HANDLE_MSG(hwnd, WM_INITDIALOG, OnInitTb);
  82. HANDLE_MSG(hwnd, WM_COMMAND, OnCommandTb);
  83. case WM_NOTIFY:
  84. switch ( ((NMHDR FAR *) lParam)->code )
  85. {
  86. case PSN_KILLACTIVE:
  87. case PSN_RESET:
  88. case PSN_WIZBACK:
  89. case PSN_WIZFINISH:
  90. break;
  91. case PSN_WIZNEXT:
  92. SaveBToolbar();
  93. break;
  94. case PSN_QUERYCANCEL:
  95. WIZ_CANCEL(hwnd);
  96. break;
  97. case PSN_HELP:
  98. WIZ_HELP();
  99. break;
  100. case PSN_SETACTIVE:
  101. g_App.dwCurrentHelp = IDH_BTOOLBAR;
  102. WIZ_BUTTONS(hwnd, PSWIZB_BACK | PSWIZB_NEXT);
  103. // Press next if the user is in auto mode
  104. //
  105. WIZ_NEXTONAUTO(hwnd, PSBTN_NEXT);
  106. break;
  107. default:
  108. return FALSE;
  109. }
  110. break;
  111. case WM_DESTROY:
  112. FreeList(g_pgTbbiList);
  113. g_ppgTbbiNew = &g_pgTbbiList;
  114. break;
  115. default:
  116. return FALSE;
  117. }
  118. return TRUE;
  119. }
  120. //
  121. // Internal Function(s):
  122. //
  123. static BOOL OnInitTb(HWND hwnd, HWND hwndFocus, LPARAM lParam)
  124. {
  125. TCHAR szHoldDir[MAX_PATH];
  126. // Load the list of toolbars from install.ins
  127. //
  128. InitToolbarButtonList(hwnd);
  129. // Determine whether to show or hide edit/remove button at init
  130. //
  131. DisableButtons(hwnd);
  132. #ifndef BRANDTITLE
  133. // Create the IEAK holding place directories (these get deleted in save.c)
  134. //
  135. lstrcpyn(szHoldDir, g_App.szTempDir,AS(szHoldDir));
  136. AddPathN(szHoldDir, DIR_IESIGNUP,AS(szHoldDir));
  137. CreatePath(szHoldDir);
  138. #endif //BRANDTITLE
  139. // Always return false to WM_INITDIALOG.
  140. //
  141. return FALSE;
  142. }
  143. static void OnCommandTb(HWND hwnd, INT id, HWND hwndCtl, UINT codeNotify)
  144. {
  145. // Controls
  146. //
  147. switch ( id )
  148. {
  149. case IDC_ADDBTOOLBAR:
  150. OnAddToolbar(hwnd);
  151. break;
  152. case IDC_EDITBTOOLBAR:
  153. OnEditToolbar(hwnd);
  154. DisableButtons(hwnd);
  155. break;
  156. case IDC_REMOVEBTOOLBAR:
  157. OnRemoveToolbar(hwnd);
  158. DisableButtons(hwnd);
  159. break;
  160. }
  161. // Notifications
  162. //
  163. switch (codeNotify)
  164. {
  165. case LBN_DBLCLK:
  166. OnEditToolbar(hwnd);
  167. break;
  168. case LBN_SELCHANGE:
  169. case LBN_SETFOCUS:
  170. DisableButtons(hwnd);
  171. break;
  172. }
  173. }
  174. void OnAddToolbar(HWND hwnd)
  175. {
  176. PBTOOLBAR_BUTTON_INFO pbtbbiNew;
  177. HWND hwndList;
  178. if (NULL == (pbtbbiNew = (PBTOOLBAR_BUTTON_INFO)MALLOC(sizeof(BTOOLBAR_BUTTON_INFO)))) {
  179. MsgBox(GetParent(hwnd), IDS_OUTOFMEM, IDS_APPNAME, MB_ERRORBOX);
  180. WIZ_EXIT(hwnd);
  181. return;
  182. }
  183. ZeroMemory(pbtbbiNew, sizeof(BTOOLBAR_BUTTON_INFO));
  184. hwndList = GetDlgItem(hwnd, IDC_BTOOLBARLIST);
  185. if (IDOK == DialogBoxParam(g_App.hInstance,
  186. MAKEINTRESOURCE(IDD_BRTOOLBAR),
  187. hwnd,
  188. ToolbarPopupDlgProc,
  189. (LPARAM)pbtbbiNew)) {
  190. // Make sure we're not adding duplicates
  191. //
  192. if (LB_ERR == ListBox_FindString(hwndList, -1, pbtbbiNew->szCaption)) {
  193. INT iItem = -1;
  194. // Add the toolbar button info to the list
  195. //
  196. FAddListItem(&g_pgTbbiList, &g_ppgTbbiNew, pbtbbiNew);
  197. iItem = ListBox_AddString(hwndList, pbtbbiNew->szCaption);
  198. ListBox_SetItemData(hwndList, iItem, pbtbbiNew);
  199. }
  200. else {
  201. FREE(pbtbbiNew);
  202. MsgBox(hwnd, IDS_ERR_DUP, IDS_APPNAME, MB_OK);
  203. }
  204. }
  205. else
  206. FREE(pbtbbiNew);
  207. }
  208. void OnEditToolbar(HWND hwnd)
  209. {
  210. PBTOOLBAR_BUTTON_INFO pbtbbi;
  211. HWND hwndList;
  212. INT iItem;
  213. hwndList = GetDlgItem(hwnd, IDC_BTOOLBARLIST);
  214. iItem = ListBox_GetCurSel(hwndList);
  215. if (iItem != -1) {
  216. pbtbbi = (PBTOOLBAR_BUTTON_INFO) ListBox_GetItemData(hwndList, iItem);
  217. if (IDOK == DialogBoxParam(g_App.hInstance,
  218. MAKEINTRESOURCE(IDD_BRTOOLBAR),
  219. hwnd,
  220. ToolbarPopupDlgProc,
  221. (LPARAM)pbtbbi)) {
  222. // Remove old item and add modified item
  223. ListBox_DeleteString(hwndList, iItem);
  224. iItem = ListBox_AddString(hwndList, pbtbbi->szCaption);
  225. ListBox_SetItemData(hwndList, iItem, pbtbbi);
  226. }
  227. }
  228. }
  229. void OnRemoveToolbar(HWND hwnd)
  230. {
  231. BOOL fFound = FALSE;
  232. HWND hwndList = GetDlgItem(hwnd, IDC_BTOOLBARLIST);
  233. INT iItem = ListBox_GetCurSel(hwndList);
  234. // Loop until we find what we want to delete
  235. //
  236. PGENERIC_LIST pglItem = g_pgTbbiList;
  237. while ((iItem != -1) && !fFound && pglItem) {
  238. PBTOOLBAR_BUTTON_INFO pbDelete = (PBTOOLBAR_BUTTON_INFO)ListBox_GetItemData(hwndList, iItem);
  239. // Remove item from list
  240. //
  241. if (pglItem->pNext && pglItem->pNext->pvItem == pbDelete) {
  242. PGENERIC_LIST pTemp = pglItem->pNext;
  243. pglItem->pNext = pTemp->pNext;
  244. // Reset the g_ppglNew if last item
  245. //
  246. if (&pTemp->pNext == g_ppgTbbiNew)
  247. g_ppgTbbiNew = &pglItem->pNext;
  248. FREE(pTemp->pvItem);
  249. FREE(pTemp);
  250. fFound = TRUE;
  251. }
  252. else if (g_pgTbbiList && g_pgTbbiList->pvItem == pbDelete) {
  253. PGENERIC_LIST pTemp = g_pgTbbiList;
  254. g_pgTbbiList = g_pgTbbiList->pNext;
  255. // Reset the g_ppglNew if last item
  256. //
  257. if (&pTemp->pNext == g_ppgTbbiNew)
  258. g_ppgTbbiNew = NULL;
  259. FREE(pTemp->pvItem);
  260. FREE(pTemp);
  261. fFound = TRUE;
  262. }
  263. pglItem = pglItem ? pglItem->pNext : NULL;
  264. }
  265. ListBox_DeleteString(hwndList, iItem);
  266. }
  267. static void DisableButtons(HWND hwnd)
  268. {
  269. HWND hwndList = GetDlgItem(hwnd, IDC_BTOOLBARLIST);
  270. INT iSel = ListBox_GetCurSel(hwndList);
  271. if ((iSel != -1) && ListBox_GetCount(hwndList)) {
  272. EnableWindow(GetDlgItem(hwnd, IDC_EDITBTOOLBAR), TRUE);
  273. EnableWindow(GetDlgItem(hwnd, IDC_REMOVEBTOOLBAR), TRUE);
  274. }
  275. else {
  276. EnableWindow(GetDlgItem(hwnd, IDC_EDITBTOOLBAR), FALSE);
  277. EnableWindow(GetDlgItem(hwnd, IDC_REMOVEBTOOLBAR), FALSE);
  278. }
  279. }
  280. static void InitToolbarButtonList(HWND hwnd)
  281. {
  282. LPTSTR lpszTbSection = NULL;
  283. TCHAR* pszItem = NULL;
  284. HWND hwndList = GetDlgItem(hwnd, IDC_BTOOLBARLIST);
  285. INT iItem = -1;
  286. // Allocate the section buffer...
  287. //
  288. lpszTbSection = MALLOC(MAX_SECTION * sizeof(TCHAR));
  289. if (lpszTbSection && OpkGetPrivateProfileSection(INI_SEC_TOOLBAR, lpszTbSection, MAX_SECTION, g_App.szInstallInsFile)) {
  290. PBTOOLBAR_BUTTON_INFO pbtbbiNew = NULL;
  291. pszItem = lpszTbSection;
  292. while (pszItem && *pszItem != NULLCHR) {
  293. TCHAR *pszTemp = NULL;
  294. // NOTE: This order is very important!
  295. // The 'Caption' must be first and 'Show' must be last.
  296. //
  297. if (!_tcsncmp(pszItem, INI_KEY_CAPTION0, lstrlen(INI_KEY_CAPTION0)-2)) {
  298. pszTemp = StrStr(pszItem, STR_EQUAL);
  299. if (NULL == (pbtbbiNew = (PBTOOLBAR_BUTTON_INFO)MALLOC(sizeof(BTOOLBAR_BUTTON_INFO)))) {
  300. MsgBox(GetParent(hwnd), IDS_OUTOFMEM, IDS_APPNAME, MB_ERRORBOX);
  301. WIZ_EXIT(hwnd);
  302. return;
  303. }
  304. lstrcpyn(pbtbbiNew->szCaption, pszTemp+1, MAX_NAME);
  305. }
  306. else if (!_tcsncmp(pszItem, INI_KEY_ACTION0, lstrlen(INI_KEY_ACTION0)-2)) {
  307. pszTemp = StrStr(pszItem, STR_EQUAL);
  308. lstrcpyn(pbtbbiNew->szAction, pszTemp+1, AS(pbtbbiNew->szAction));
  309. }
  310. else if (!_tcsncmp(pszItem, INI_KEY_ICON0, lstrlen(INI_KEY_ICON0)-2)) {
  311. pszTemp = StrStr(pszItem, STR_EQUAL);
  312. lstrcpyn(pbtbbiNew->szIconGray, pszTemp+1, AS(pbtbbiNew->szIconGray));
  313. }
  314. else if (!_tcsncmp(pszItem, INI_KEY_HOTICON0, lstrlen(INI_KEY_HOTICON0)-2)) {
  315. pszTemp = StrStr(pszItem, STR_EQUAL);
  316. lstrcpyn(pbtbbiNew->szIconColor, pszTemp+1, AS(pbtbbiNew->szIconColor));
  317. }
  318. else if (!_tcsncmp(pszItem, INI_KEY_SHOW0, lstrlen(INI_KEY_SHOW0)-2)) {
  319. pszTemp = StrStr(pszItem, STR_EQUAL);
  320. pbtbbiNew->fShow = (_tcsicmp((pszTemp+1),_T("1")) ? FALSE : TRUE);
  321. // Add the toolbar button info to the list
  322. //
  323. FAddListItem(&g_pgTbbiList, &g_ppgTbbiNew, pbtbbiNew);
  324. // Add to the listbox
  325. //
  326. iItem = ListBox_AddString(hwndList, pbtbbiNew->szCaption);
  327. ListBox_SetItemData(hwndList, iItem, pbtbbiNew);
  328. }
  329. // Move to end
  330. //
  331. while (*pszItem != NULLCHR)
  332. pszItem++;
  333. pszItem++;
  334. }
  335. }
  336. // Free the section buffer...
  337. //
  338. if ( lpszTbSection )
  339. FREE( lpszTbSection );
  340. // Make sure a selection is made
  341. //
  342. ListBox_SetSel(hwndList, TRUE, iItem);
  343. }
  344. // ToolbarPopupDlgProc used for gathering the toolbar button information
  345. //
  346. LRESULT CALLBACK ToolbarPopupDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  347. {
  348. switch (uMsg)
  349. {
  350. HANDLE_MSG(hwnd, WM_INITDIALOG, OnInitTbPopup);
  351. HANDLE_MSG(hwnd, WM_COMMAND, OnCommandTbPopup);
  352. }
  353. return FALSE;
  354. }
  355. static BOOL OnInitTbPopup(HWND hwnd, HWND hwndFocus, LPARAM lParam)
  356. {
  357. g_pbtbbiNew = (PBTOOLBAR_BUTTON_INFO)lParam;
  358. if (g_pbtbbiNew) {
  359. CheckDlgButton(hwnd, IDC_BUTTONSTATE, BST_CHECKED);
  360. SendDlgItemMessage(hwnd, IDC_NAME , EM_LIMITTEXT, STRSIZE(g_pbtbbiNew->szCaption) - 1, 0L);
  361. SetWindowText(GetDlgItem(hwnd, IDC_NAME), g_pbtbbiNew->szCaption);
  362. SendDlgItemMessage(hwnd, IDC_URL , EM_LIMITTEXT, STRSIZE(g_pbtbbiNew->szAction) - 1, 0L);
  363. SetWindowText(GetDlgItem(hwnd, IDC_URL), g_pbtbbiNew->szAction);
  364. SendDlgItemMessage(hwnd, IDC_DICON , EM_LIMITTEXT, STRSIZE(g_pbtbbiNew->szIconColor) - 1, 0L);
  365. SetWindowText(GetDlgItem(hwnd, IDC_DICON), g_pbtbbiNew->szIconColor);
  366. SendDlgItemMessage(hwnd, IDC_GRAYSCALE , IDC_GRAYSCALE, STRSIZE(g_pbtbbiNew->szIconGray) - 1, 0L);
  367. SetWindowText(GetDlgItem(hwnd, IDC_GRAYSCALE), g_pbtbbiNew->szIconGray);
  368. }
  369. return TRUE;
  370. }
  371. static void OnCommandTbPopup(HWND hwnd, INT id, HWND hwndCtl, UINT codeNotify)
  372. {
  373. TCHAR szFileName[MAX_PATH] = NULLSTR;
  374. switch ( id )
  375. {
  376. case IDC_BROWSE1:
  377. case IDC_BROWSE2:
  378. case IDC_BROWSE3:
  379. if (id == IDC_BROWSE1)
  380. GetDlgItemText(hwnd, IDC_URL, szFileName, STRSIZE(szFileName));
  381. else if (id == IDC_BROWSE2)
  382. GetDlgItemText(hwnd, IDC_DICON, szFileName, STRSIZE(szFileName));
  383. else if (id == IDC_BROWSE3)
  384. GetDlgItemText(hwnd, IDC_GRAYSCALE, szFileName, STRSIZE(szFileName));
  385. if ( BrowseForFile(hwnd, IDS_BROWSE, id == IDC_BROWSE1 ? IDS_EXEFILES : IDS_ICONFILES, id == IDC_BROWSE1 ? IDS_EXE : IDS_ICO, szFileName, STRSIZE(szFileName),
  386. g_App.szOpkDir, 0) ) {
  387. if (id == IDC_BROWSE1)
  388. SetDlgItemText(hwnd, IDC_URL, szFileName);
  389. else
  390. SetDlgItemText(hwnd, id == IDC_BROWSE2 ? IDC_DICON : IDC_GRAYSCALE, szFileName);
  391. }
  392. break;
  393. case IDOK:
  394. if (FSaveBToolbarButtonInfo(hwnd, g_pbtbbiNew))
  395. EndDialog(hwnd, 1);
  396. break;
  397. case IDCANCEL:
  398. EndDialog(hwnd, 0);
  399. break;
  400. }
  401. }
  402. static BOOL FSaveBToolbarButtonInfo(HWND hwnd, PBTOOLBAR_BUTTON_INFO pbtbbi)
  403. {
  404. TCHAR szTemp[MAX_URL] = NULLSTR;
  405. UINT fButton = BST_CHECKED;
  406. if (!pbtbbi)
  407. return FALSE;
  408. // Save the caption to the INS file.
  409. //
  410. szTemp[0] = NULLCHR;
  411. GetDlgItemText(hwnd, IDC_NAME, szTemp, STRSIZE(szTemp));
  412. lstrcpyn(pbtbbi->szCaption, szTemp,AS(pbtbbi->szCaption));
  413. if (!lstrlen(szTemp)) {
  414. MsgBox(GetParent(hwnd), IDS_MUST, IDS_APPNAME, MB_ERRORBOX, pbtbbi->szIconGray);
  415. SetFocus(GetDlgItem(hwnd, IDC_NAME));
  416. return FALSE;
  417. }
  418. // Save the action to the INS file.
  419. //
  420. szTemp[0] = NULLCHR;
  421. GetDlgItemText(hwnd, IDC_URL, szTemp, STRSIZE(szTemp));
  422. lstrcpyn(pbtbbi->szAction, szTemp, AS(pbtbbi->szAction));
  423. if (!lstrlen(szTemp)) {
  424. MsgBox(GetParent(hwnd), IDS_MUST, IDS_APPNAME, MB_ERRORBOX, pbtbbi->szIconGray);
  425. SetFocus(GetDlgItem(hwnd, IDC_URL));
  426. return FALSE;
  427. }
  428. // Verify the source of the hot icon file.
  429. //
  430. szTemp[0] = NULLCHR;
  431. GetDlgItemText(hwnd, IDC_DICON, szTemp, STRSIZE(szTemp));
  432. lstrcpyn(pbtbbi->szIconColor, szTemp, AS(pbtbbi->szIconColor));
  433. if (!FileExists(pbtbbi->szIconColor)) {
  434. MsgBox(GetParent(hwnd), lstrlen(pbtbbi->szIconColor) ? IDS_NOFILE : IDS_BLANKFILE,
  435. IDS_APPNAME, MB_ERRORBOX, pbtbbi->szIconColor);
  436. SetFocus(GetDlgItem(hwnd, IDC_DICON));
  437. return FALSE;
  438. }
  439. // Verify the source of the icon file.
  440. //
  441. szTemp[0] = NULLCHR;
  442. GetDlgItemText(hwnd, IDC_GRAYSCALE, szTemp, STRSIZE(szTemp));
  443. lstrcpyn(pbtbbi->szIconGray, szTemp, AS(pbtbbi->szIconGray));
  444. if (!FileExists(pbtbbi->szIconGray)) {
  445. MsgBox(GetParent(hwnd), lstrlen(pbtbbi->szIconGray) ? IDS_NOFILE : IDS_BLANKFILE,
  446. IDS_APPNAME, MB_ERRORBOX, pbtbbi->szIconGray);
  447. SetFocus(GetDlgItem(hwnd, IDC_GRAYSCALE));
  448. return FALSE;
  449. }
  450. // Save the button state of the button.
  451. //
  452. szTemp[0] = NULLCHR;
  453. fButton = IsDlgButtonChecked(hwnd, IDC_BUTTONSTATE);
  454. if (fButton == BST_CHECKED) {
  455. pbtbbi->fShow = TRUE;
  456. }
  457. else {
  458. pbtbbi->fShow = FALSE;
  459. }
  460. return TRUE;
  461. }
  462. static void SaveData(PGENERIC_LIST pList)
  463. {
  464. TCHAR szTemp[MAX_URL],
  465. szFullPath[MAX_PATH],
  466. szCopyFile[MAX_PATH],
  467. szTempKey[MAX_PATH];
  468. LPTSTR lpFilePart,
  469. lpIePath;
  470. UINT fButton = BST_CHECKED;
  471. INT iItem = 0;
  472. HRESULT hrPrintf;
  473. // Get the path to the IE directory.
  474. //
  475. lpIePath = AllocateString(NULL, IDS_IEDESTDIR);
  476. // Clear the section [BrowserToolbars]
  477. //
  478. OpkWritePrivateProfileSection(INI_SEC_TOOLBAR, NULL, g_App.szInstallInsFile);
  479. while (pList) {
  480. PBTOOLBAR_BUTTON_INFO pbtbbi = (PBTOOLBAR_BUTTON_INFO)pList->pvItem;
  481. if (pbtbbi) {
  482. // Save the caption to the INS file.
  483. //
  484. szTemp[0] = NULLCHR;
  485. lstrcpyn(szTemp, pbtbbi->szCaption,AS(szTemp));
  486. hrPrintf=StringCchPrintf(szTempKey, AS(szTempKey), INI_KEY_CAPTION0, iItem);
  487. OpkWritePrivateProfileString(INI_SEC_TOOLBAR, szTempKey, szTemp, g_App.szInstallInsFile);
  488. // Save the action to the INS file.
  489. //
  490. szTemp[0] = NULLCHR;
  491. lstrcpyn(szTemp, pbtbbi->szAction, AS(szTemp));
  492. hrPrintf=StringCchPrintf(szTempKey, AS(szTempKey), INI_KEY_ACTION0, iItem);
  493. OpkWritePrivateProfileString(INI_SEC_TOOLBAR, szTempKey, szTemp, g_App.szInstallInsFile);
  494. // Save the source of the icon to the wizard INF because it is
  495. // the only one that needs to know it.
  496. //
  497. szTemp[0] = NULLCHR;
  498. lstrcpyn(szTemp, pbtbbi->szIconGray,AS(szTemp));
  499. hrPrintf=StringCchPrintf(szTempKey, AS(szTempKey), INI_KEY_ICON0, iItem);
  500. OpkWritePrivateProfileString(INI_SEC_TOOLBAR, szTempKey, szTemp, g_App.szOpkWizIniFile);
  501. // Add the icon source file name onto the IE destination path to
  502. // write to the INS file.
  503. //
  504. if ( GetFullPathName(szTemp, STRSIZE(szFullPath), szFullPath, &lpFilePart) && lpFilePart )
  505. {
  506. /* NOTE: Why are we doing this? This makes the file c:\windows\internet explorer\signup\*.ico
  507. However talking to Pritvi they don't really care about the path, they always assume the
  508. file will be in c:\windows\internet explorer\signup.
  509. lstrcpyn(szTemp, lpIePath,AS(szTemp));
  510. AddPathN(szTemp, lpFilePart,AS(szTemp));
  511. */
  512. hrPrintf=StringCchPrintf(szTempKey, AS(szTempKey), INI_KEY_ICON0, iItem);
  513. OpkWritePrivateProfileString(INI_SEC_TOOLBAR, szTempKey, szTemp, g_App.szInstallInsFile);
  514. }
  515. // Save the source of the hot icon to the wizard INF because it is
  516. // the only one that needs to know it.
  517. //
  518. szTemp[0] = NULLCHR;
  519. lstrcpyn(szTemp, pbtbbi->szIconColor,AS(szTemp));
  520. hrPrintf=StringCchPrintf(szTempKey, AS(szTempKey), INI_KEY_HOTICON0, iItem);
  521. OpkWritePrivateProfileString(INI_SEC_TOOLBAR, szTempKey, szTemp, g_App.szOpkWizIniFile);
  522. // Add the hot icon source file name onto the IE destination path to
  523. // write to the INS file.
  524. //
  525. if ( GetFullPathName(szTemp, STRSIZE(szFullPath), szFullPath, &lpFilePart) && lpFilePart )
  526. {
  527. /* NOTE: Why are we doing this? This makes the file c:\windows\internet explorer\signup\*.ico
  528. However talking to Pritvi they don't really care about the path, they always assume the
  529. file will be in c:\windows\internet explorer\signup.
  530. lstrcpyn(szTemp, lpIePath,AS(szTemp));
  531. AddPathN(szTemp, lpFilePart,AS(szTemp));
  532. */
  533. hrPrintf=StringCchPrintf(szTempKey, AS(szTempKey), INI_KEY_HOTICON0, iItem);
  534. OpkWritePrivateProfileString(INI_SEC_TOOLBAR, szTempKey, szTemp, g_App.szInstallInsFile);
  535. }
  536. // Copy item files
  537. //
  538. lstrcpyn(szCopyFile, g_App.szTempDir,AS(szCopyFile));
  539. AddPathN(szCopyFile, DIR_IESIGNUP,AS(szCopyFile));
  540. AddPathN(szCopyFile, PathFindFileName(pbtbbi->szIconColor),AS(szCopyFile));
  541. CopyFile(pbtbbi->szIconColor, szCopyFile, FALSE);
  542. lstrcpyn(szCopyFile, g_App.szTempDir,AS(szCopyFile));
  543. AddPathN(szCopyFile, DIR_IESIGNUP,AS(szCopyFile));
  544. AddPathN(szCopyFile, PathFindFileName(pbtbbi->szIconGray),AS(szCopyFile));
  545. CopyFile(pbtbbi->szIconGray, szCopyFile, FALSE);
  546. // Save the button state of the button to the INS.
  547. //
  548. szTemp[0] = NULLCHR;
  549. fButton = pbtbbi->fShow;
  550. hrPrintf=StringCchPrintf(szTempKey, AS(szTempKey), INI_KEY_SHOW0, iItem);
  551. if (fButton == BST_CHECKED) {
  552. OpkWritePrivateProfileString(INI_SEC_TOOLBAR, szTempKey, _T("1"), g_App.szInstallInsFile);
  553. pbtbbi->fShow = TRUE;
  554. }
  555. else {
  556. OpkWritePrivateProfileString(INI_SEC_TOOLBAR, szTempKey, _T("0"), g_App.szInstallInsFile);
  557. pbtbbi->fShow = FALSE;
  558. }
  559. }
  560. // Next item
  561. //
  562. pList = pList ? pList->pNext : NULL;
  563. iItem++;
  564. }
  565. // Free the IE destination.
  566. //
  567. FREE(lpIePath);
  568. }
  569. void SaveBToolbar()
  570. {
  571. SaveData(g_pgTbbiList);
  572. }