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.

276 lines
7.9 KiB

  1. /****************************************************************************\
  2. BTITLE.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. 4/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. [Branding]
  22. ...
  23. Window_Title_CN=Smoothie Joe
  24. Window_Title=Microsoft Internet Explorer provided by Smoothie Joe
  25. Toolbar Bitmap=C:\WINDOWS\Waves.bmp
  26. [Internet_Mail]
  27. Window_Title=Outlook Express provided by Smoothie Joe
  28. */
  29. //
  30. // Internal Defines
  31. //
  32. #define INI_KEY_WINDOW_TITLECN _T("Window_Title_CN")
  33. #define INI_KEY_WINDOW_TITLE _T("Window_Title")
  34. #define INI_KEY_TOOLBAR_BM _T("Toolbar Bitmap")
  35. #define INI_SEC_IEMAIL _T("Internet_Mail")
  36. //
  37. // Internal Globals
  38. //
  39. BOOL g_fGrayTitle = TRUE, g_fGrayToolbarBm = TRUE;
  40. TCHAR g_szTitle[MAX_PATH] = NULLSTR, g_szToolbarBm[MAX_PATH] = NULLSTR;
  41. //
  42. // Internal Function Prototype(s):
  43. //
  44. static BOOL OnInit(HWND, HWND, LPARAM);
  45. static void OnCommand(HWND, INT, HWND, UINT);
  46. static BOOL FSaveData(HWND);
  47. static void EnableControls(HWND, UINT, BOOL);
  48. void SaveBTitle();
  49. //
  50. // External Function(s):
  51. //
  52. LRESULT CALLBACK BrandTitleDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  53. {
  54. switch (uMsg)
  55. {
  56. HANDLE_MSG(hwnd, WM_INITDIALOG, OnInit);
  57. HANDLE_MSG(hwnd, WM_COMMAND, OnCommand);
  58. case WM_NOTIFY:
  59. switch ( ((NMHDR FAR *) lParam)->code )
  60. {
  61. case PSN_KILLACTIVE:
  62. case PSN_RESET:
  63. case PSN_WIZBACK:
  64. case PSN_WIZFINISH:
  65. break;
  66. case PSN_WIZNEXT:
  67. if (!FSaveData(hwnd))
  68. WIZ_FAIL(hwnd);
  69. else
  70. SaveBTitle();
  71. break;
  72. case PSN_QUERYCANCEL:
  73. WIZ_CANCEL(hwnd);
  74. break;
  75. case PSN_HELP:
  76. WIZ_HELP();
  77. break;
  78. case PSN_SETACTIVE:
  79. g_App.dwCurrentHelp = IDH_BTITLE;
  80. if (g_App.szManufacturer[0] && !g_szTitle[0])
  81. lstrcpyn(g_szTitle, g_App.szManufacturer, AS(g_szTitle));
  82. SetWindowText(GetDlgItem(hwnd, IDE_TITLE), g_szTitle);
  83. WIZ_BUTTONS(hwnd, PSWIZB_BACK | PSWIZB_NEXT);
  84. // Press next if the user is in auto mode
  85. //
  86. WIZ_NEXTONAUTO(hwnd, PSBTN_NEXT);
  87. break;
  88. default:
  89. return FALSE;
  90. }
  91. break;
  92. default:
  93. return FALSE;
  94. }
  95. return TRUE;
  96. }
  97. //
  98. // Internal Function(s):
  99. //
  100. static BOOL OnInit(HWND hwnd, HWND hwndFocus, LPARAM lParam)
  101. {
  102. TCHAR szKey[MAX_PATH] = NULLSTR;
  103. TCHAR szHoldDir[MAX_PATH];
  104. // Load the ins file sections to initialize items
  105. //
  106. ReadInstallInsKey(INI_SEC_BRANDING, INI_KEY_WINDOW_TITLECN, g_szTitle, STRSIZE(g_szTitle),
  107. GET_FLAG(OPK_BATCHMODE) ? g_App.szOpkWizIniFile : g_App.szInstallInsFile, &g_fGrayTitle);
  108. ReadInstallInsKey(INI_SEC_BRANDING, INI_KEY_TOOLBAR_BM, g_szToolbarBm, STRSIZE(g_szToolbarBm),
  109. GET_FLAG(OPK_BATCHMODE) ? g_App.szOpkWizIniFile : g_App.szInstallInsFile, &g_fGrayToolbarBm);
  110. // Set the window text
  111. //
  112. SendDlgItemMessage(hwnd, IDE_TITLE , EM_LIMITTEXT, STRSIZE(g_szTitle) - 1, 0L);
  113. SetWindowText(GetDlgItem(hwnd, IDE_TITLE), g_szTitle);
  114. EnableControls(hwnd, IDC_TITLE, !g_fGrayTitle);
  115. SendDlgItemMessage(hwnd, IDE_TOOLBARBMP , EM_LIMITTEXT, STRSIZE(g_szToolbarBm) - 1, 0L);
  116. SetWindowText(GetDlgItem(hwnd, IDE_TOOLBARBMP), g_szToolbarBm);
  117. EnableControls(hwnd, IDC_TOOLBARBMP, !g_fGrayToolbarBm);
  118. // Create the IEAK holding place directories (these get deleted in save.c)
  119. //
  120. lstrcpyn(szHoldDir, g_App.szTempDir,AS(szHoldDir));
  121. AddPathN(szHoldDir, DIR_IESIGNUP,AS(szHoldDir));
  122. CreatePath(szHoldDir);
  123. // Always return false to WM_INITDIALOG.
  124. //
  125. return FALSE;
  126. }
  127. static void OnCommand(HWND hwnd, INT id, HWND hwndCtl, UINT codeNotify)
  128. {
  129. TCHAR szFileName[MAX_PATH];
  130. switch ( id )
  131. {
  132. case IDC_TITLE:
  133. EnableControls(hwnd, IDC_TITLE, g_fGrayTitle);
  134. g_fGrayTitle = !g_fGrayTitle ;
  135. break;
  136. case IDC_TOOLBARBMP:
  137. EnableControls(hwnd, IDC_TOOLBARBMP, g_fGrayToolbarBm);
  138. g_fGrayToolbarBm = !g_fGrayToolbarBm ;
  139. break;
  140. case IDC_BROWSETBB:
  141. // Now get the filename
  142. //
  143. GetDlgItemText(hwnd, IDE_TOOLBARBMP, szFileName, STRSIZE(szFileName));
  144. if ( BrowseForFile(hwnd, IDS_BROWSE, IDS_BMPFILTER, IDS_BMP, szFileName,
  145. STRSIZE(szFileName), g_App.szOpkDir, 0) )
  146. SetDlgItemText(hwnd, IDE_TOOLBARBMP, szFileName);
  147. break;
  148. }
  149. }
  150. // The actual copying of the bitmap file happens in save.c. Here we just save
  151. // to the install.ins
  152. //
  153. static BOOL FSaveData(HWND hwnd)
  154. {
  155. TCHAR szBuffer[MAX_PATH], szTemp[MAX_PATH];
  156. HRESULT hrPrintf;
  157. // Get the new values
  158. //
  159. GetWindowText(GetDlgItem(hwnd, IDE_TITLE), g_szTitle, STRSIZE(g_szTitle));
  160. GetWindowText(GetDlgItem(hwnd, IDE_TOOLBARBMP), g_szToolbarBm, STRSIZE(g_szToolbarBm));
  161. // Save the window_title_cn
  162. //
  163. WriteInstallInsKey(INI_SEC_BRANDING, INI_KEY_WINDOW_TITLECN, g_szTitle, g_App.szInstallInsFile, g_fGrayTitle);
  164. // Save the toolbar bitmap
  165. //
  166. if (!g_fGrayToolbarBm && !FileExists(g_szToolbarBm)) {
  167. MsgBox(hwnd, lstrlen(g_szToolbarBm) ? IDS_NOFILE : IDS_BLANKFILE, IDS_APPNAME, MB_ERRORBOX, g_szToolbarBm);
  168. SetFocus(GetDlgItem(hwnd, IDE_TOOLBARBMP));
  169. return FALSE;
  170. }
  171. WriteInstallInsKey(INI_SEC_BRANDING, INI_KEY_TOOLBAR_BM, g_szToolbarBm, g_App.szInstallInsFile, g_fGrayToolbarBm);
  172. // Save the window_title
  173. //
  174. LoadString(g_App.hInstance, IDS_TITLE_PREFIX, szTemp, STRSIZE(szTemp));
  175. hrPrintf=StringCchPrintf(szBuffer, AS(szBuffer), szTemp, g_szTitle);
  176. WriteInstallInsKey(INI_SEC_BRANDING, INI_KEY_WINDOW_TITLE, szBuffer, g_App.szInstallInsFile, g_fGrayTitle);
  177. // Save the internet_mail
  178. //
  179. LoadString(g_App.hInstance, IDS_OETITLE_PREFIX, szTemp, STRSIZE(szTemp));
  180. hrPrintf=StringCchPrintf(szBuffer, AS(szBuffer), szTemp, g_szTitle);
  181. WriteInstallInsKey(INI_SEC_IEMAIL, INI_KEY_WINDOW_TITLE, szBuffer, g_App.szInstallInsFile, g_fGrayTitle);
  182. return TRUE;
  183. }
  184. static void EnableControls(HWND hwnd, UINT uId, BOOL fEnable)
  185. {
  186. switch ( uId )
  187. {
  188. case IDC_TITLE:
  189. EnableWindow(GetDlgItem(hwnd, IDC_TITLE_TXT), fEnable);
  190. EnableWindow(GetDlgItem(hwnd, IDE_TITLE), fEnable);
  191. CheckDlgButton(hwnd, IDC_TITLE, fEnable ? BST_CHECKED : BST_UNCHECKED);
  192. break;
  193. case IDC_TOOLBARBMP:
  194. EnableWindow(GetDlgItem(hwnd, IDC_TOOLBARBMP_TXT), fEnable);
  195. EnableWindow(GetDlgItem(hwnd, IDE_TOOLBARBMP), fEnable);
  196. EnableWindow(GetDlgItem(hwnd, IDC_BROWSETBB), fEnable);
  197. CheckDlgButton(hwnd, IDC_TOOLBARBMP, fEnable ? BST_CHECKED : BST_UNCHECKED);
  198. break;
  199. }
  200. }
  201. void SaveBTitle()
  202. {
  203. TCHAR szBmpFile[MAX_PATH] = NULLSTR;
  204. // Copy the Bitmap file if not grayed
  205. //
  206. if (!g_fGrayToolbarBm) {
  207. lstrcpyn(szBmpFile, g_App.szTempDir,AS(szBmpFile));
  208. AddPathN(szBmpFile, DIR_IESIGNUP,AS(szBmpFile));
  209. AddPathN(szBmpFile, PathFindFileName(g_szToolbarBm),AS(szBmpFile));
  210. CopyFile(g_szToolbarBm, szBmpFile, FALSE);
  211. }
  212. }