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.

192 lines
6.9 KiB

  1. #include "pch.h"
  2. HRESULT BToolbarsFinalCopy(LPCTSTR pcszDestDir, DWORD dwFlags, LPDWORD pdwCabState)
  3. {
  4. TCHAR szBToolbarWork[MAX_PATH];
  5. PathCombine(szBToolbarWork, g_szWorkDir, TEXT("btoolbar.wrk"));
  6. if (HasFlag(dwFlags, PM_CHECK) && pdwCabState != NULL && !PathIsEmptyPath(szBToolbarWork, FILES_ONLY))
  7. SetFlag(pdwCabState, CAB_TYPE_CONFIG);
  8. if (HasFlag(dwFlags, PM_COPY))
  9. CopyFileToDir(szBToolbarWork, pcszDestDir);
  10. if (HasFlag(dwFlags, PM_CLEAR))
  11. PathRemovePath(szBToolbarWork);
  12. return S_OK;
  13. }
  14. INT_PTR CALLBACK BToolbarProc(
  15. HWND hDlg,
  16. UINT message,
  17. WPARAM wParam,
  18. LPARAM lParam)
  19. {
  20. TCHAR szBToolbarWork[MAX_PATH];
  21. TCHAR szToolbarBmp[MAX_PATH];
  22. TCHAR szTemp[MAX_PATH];
  23. BOOL fToolbarBmp;
  24. INT iBackground = 0;
  25. switch (message)
  26. {
  27. case WM_INITDIALOG:
  28. g_hDlg = hDlg;
  29. // --------- Toolbar background -----------------------------------------
  30. EnableDBCSChars(hDlg, IDE_TOOLBARBMP);
  31. Edit_LimitText(GetDlgItem(hDlg, IDE_TOOLBARBMP), countof(szToolbarBmp) - 1);
  32. // --------- Toolbar buttons --------------------------------------------
  33. EnableDBCSChars(hDlg, IDC_BTOOLBARLIST);
  34. // --------- Toolbar background -----------------------------------------
  35. // import INS clean-up -- delete bitmap from the temp location
  36. InsGetString(IS_BRANDING, TOOLBAR_BMP, szToolbarBmp, countof(szToolbarBmp),
  37. g_szInsFile, NULL, &fToolbarBmp);
  38. if (fToolbarBmp)
  39. DeleteFileInDir(szToolbarBmp, g_szWorkDir);
  40. if (fToolbarBmp)
  41. {
  42. CheckRadioButton(hDlg, IDC_BGIE6, IDC_BG_CUSTOM, IDC_BG_CUSTOM);
  43. }
  44. else
  45. {
  46. CheckRadioButton(hDlg, IDC_BGIE6, IDC_BG_CUSTOM, IDC_BGIE6);
  47. }
  48. SetDlgItemTextTriState(hDlg, IDE_TOOLBARBMP, IDC_BG_CUSTOM, szToolbarBmp, fToolbarBmp);
  49. EnableDlgItem2(hDlg, IDE_TOOLBARBMP, fToolbarBmp);
  50. EnableDlgItem2(hDlg, IDC_BROWSETBB, fToolbarBmp);
  51. // --------- Toolbar buttons --------------------------------------------
  52. // import INS clean-up -- delete keys that are not relevant
  53. InsDeleteKey(IS_BTOOLBARS, IK_BTDELETE, g_szInsFile);
  54. PathCombine(szBToolbarWork, g_szWorkDir, TEXT("btoolbar.wrk"));
  55. PathCreatePath(szBToolbarWork);
  56. if (0 == BToolbar_Init(GetDlgItem(hDlg, IDC_BTOOLBARLIST), g_szInsFile, g_szWorkDir, szBToolbarWork))
  57. {
  58. EnsureDialogFocus(hDlg, IDC_REMOVEBTOOLBAR, IDC_ADDBTOOLBAR);
  59. EnsureDialogFocus(hDlg, IDC_EDITBTOOLBAR, IDC_ADDBTOOLBAR);
  60. EnableWindow(GetDlgItem(hDlg, IDC_EDITBTOOLBAR), FALSE);
  61. EnableWindow(GetDlgItem(hDlg, IDC_REMOVEBTOOLBAR), FALSE);
  62. }
  63. else
  64. ListBox_SetCurSel(GetDlgItem(hDlg, IDC_BTOOLBARLIST), (WPARAM) 0);
  65. CheckDlgButton(hDlg, IDC_DELETEBTOOLBARS,
  66. GetPrivateProfileInt(IS_BTOOLBARS, IK_BTDELETE, 0, g_szInsFile) ? BST_CHECKED : BST_UNCHECKED);
  67. break;
  68. case WM_COMMAND:
  69. switch(HIWORD(wParam))
  70. {
  71. case BN_CLICKED:
  72. switch (LOWORD(wParam))
  73. {
  74. case IDC_ADDBTOOLBAR:
  75. BToolbar_Edit(GetDlgItem(hDlg, IDC_BTOOLBARLIST), TRUE);
  76. SetFocus(GetDlgItem(hDlg, IDC_ADDBTOOLBAR));
  77. g_fInsDirty = TRUE;
  78. break;
  79. case IDC_REMOVEBTOOLBAR:
  80. BToolbar_Remove(GetDlgItem(hDlg, IDC_BTOOLBARLIST));
  81. g_fInsDirty = TRUE;
  82. break;
  83. case IDC_EDITBTOOLBAR:
  84. BToolbar_Edit(GetDlgItem(hDlg, IDC_BTOOLBARLIST), FALSE);
  85. SetFocus(GetDlgItem(hDlg, IDC_EDITBTOOLBAR));
  86. g_fInsDirty = TRUE;
  87. break;
  88. case IDC_BGIE6:
  89. case IDC_BG_CUSTOM:
  90. fToolbarBmp = (GET_WM_COMMAND_ID(wParam, lParam)==IDC_BG_CUSTOM);
  91. EnableDlgItem2(hDlg, IDE_TOOLBARBMP, fToolbarBmp);
  92. EnableDlgItem2(hDlg, IDC_BROWSETBB, fToolbarBmp);
  93. break;
  94. case IDC_BROWSETBB:
  95. GetDlgItemText(hDlg, IDE_TOOLBARBMP, szToolbarBmp, countof(szToolbarBmp));
  96. if (BrowseForFile(hDlg, szToolbarBmp, countof(szToolbarBmp), GFN_BMP))
  97. SetDlgItemText(hDlg, IDE_TOOLBARBMP, szToolbarBmp);
  98. SetFocus(GetDlgItem(hDlg, IDC_BROWSETBB));
  99. break;
  100. default:
  101. return FALSE;
  102. }
  103. break;
  104. }
  105. break;
  106. case UM_SAVE:
  107. {
  108. BOOL fDeleteBToolbars;
  109. BOOL fCheckDirtyOnly = (BOOL) lParam;
  110. if (!fCheckDirtyOnly)
  111. {
  112. // --------- Toolbar background -----------------------------------------
  113. //----- Validate the path for a bitmap -----
  114. iBackground = IsDlgButtonChecked(hDlg, IDC_BGIE6) ? 0 : 2;
  115. fToolbarBmp = GetDlgItemTextTriState(hDlg, IDE_TOOLBARBMP, IDC_BG_CUSTOM, szToolbarBmp, countof(szToolbarBmp));
  116. if ((iBackground==2) && !IsBitmapFileValid(hDlg, IDE_TOOLBARBMP, szToolbarBmp, NULL, 0, 0, 0, 0))
  117. {
  118. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  119. break;
  120. }
  121. // toolbar bitmap
  122. // delete the old bitmap file
  123. if (InsGetString(IS_BRANDING, TOOLBAR_BMP, szTemp, countof(szTemp), g_szInsFile))
  124. DeleteFileInDir(szTemp, g_szWorkDir);
  125. // copy the new bitmap file
  126. if (fToolbarBmp && *szToolbarBmp)
  127. CopyFileToDir(szToolbarBmp, g_szWorkDir);
  128. InsWriteString(IS_BRANDING, TOOLBAR_BMP, szToolbarBmp, g_szInsFile, fToolbarBmp, NULL, INSIO_TRISTATE);
  129. // --------- Toolbar buttons --------------------------------------------
  130. PathCombine(szBToolbarWork, g_szWorkDir, TEXT("btoolbar.wrk"));
  131. BToolbar_Save(GetDlgItem(hDlg, IDC_BTOOLBARLIST), g_szInsFile, szBToolbarWork, IEM_PROFMGR);
  132. }
  133. fDeleteBToolbars = (IsDlgButtonChecked(hDlg, IDC_DELETEBTOOLBARS) == BST_CHECKED);
  134. if (!g_fInsDirty)
  135. {
  136. BOOL fTemp;
  137. fTemp = (GetPrivateProfileInt(IS_BTOOLBARS, IK_BTDELETE, 0, g_szInsFile) != 0);
  138. if (fTemp != fDeleteBToolbars)
  139. g_fInsDirty = TRUE;
  140. }
  141. WritePrivateProfileString(IS_BTOOLBARS, IK_BTDELETE,
  142. fDeleteBToolbars ? TEXT("1") : NULL, g_szInsFile);
  143. }
  144. *((LPBOOL)wParam) = TRUE;
  145. break;
  146. case WM_CLOSE:
  147. DestroyWindow(hDlg);
  148. break;
  149. default:
  150. return FALSE;
  151. }
  152. return TRUE;
  153. }