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.

397 lines
13 KiB

  1. #pragma once
  2. #ifndef __UTIL_H__
  3. #define __UTIL_H__
  4. ////////////////////////////////////////////////////////
  5. // Depends on....
  6. typedef struct tagOPTPAGES OPTPAGES;
  7. typedef struct tagOPTINFO OPTINFO;
  8. typedef struct INETSERVER __RPC_FAR *LPINETSERVER;
  9. interface IMimeMessage;
  10. typedef IMimeMessage *LPMIMEMESSAGE;
  11. interface IExplorerToolbar;
  12. interface IMsgContainer;
  13. ////////////////////////////////////////////////////////
  14. // Begin
  15. VOID DoReadme(HWND hwndOwner);
  16. typedef VOID (*PVOIDFN)(VOID);
  17. #define DoAboutAthena(hwnd, idIcon) \
  18. DialogBoxParam(g_hLocRes, MAKEINTRESOURCE(iddVersion), hwnd, AboutAthena, (LPARAM) idIcon);
  19. INT_PTR CALLBACK AboutAthena(HWND hdlg, UINT msg, WPARAM wp, LPARAM lp);
  20. #define TOOLBAR_BKGDCLR RGB(0xff, 0, 0xff)
  21. #define __TOOLBAR_SEP__ {0,0,TBSTATE_ENABLED,TBSTYLE_SEP,{0,0},0,0}
  22. #define BUTTONCOUNT(tb) (sizeof(tb) / sizeof(TBBUTTON))
  23. UINT RegGetKeyNumbers(HKEY hkRegDataBase, const TCHAR *szRegSection);
  24. BOOL RegGetKeyNameFromIndex(HKEY hkRegDataBase, const TCHAR *szRegSection, UINT Index,
  25. TCHAR * szBuffer, DWORD *pcbBuffer);
  26. #ifdef TIMING
  27. void ResetTimingInfo();
  28. void OutputTimingInfo(LPTSTR szOutputText);
  29. #else
  30. #define ResetTimingInfo()
  31. #define OutputTimingInfo(x)
  32. #endif //TIMING
  33. #define SPLITBAR_THICKNESS 6
  34. #define IDS_IMAGEMASK 0x80000000
  35. BOOL SetupLVColumns(HWND, UINT, const int *, const int *, const int *);
  36. ULONG CbPidl(LPCITEMIDLIST pidl);
  37. LPVOID PidlAlloc(ULONG cb);
  38. VOID PidlFree(LPVOID pv);
  39. LPITEMIDLIST PidlDupIdList(LPCITEMIDLIST pidl, LPDWORD pcbPidl=NULL);
  40. LPITEMIDLIST PidlDupFirstId(LPCITEMIDLIST pidl);
  41. LPITEMIDLIST PidlDupParentIdList(LPCITEMIDLIST pidl);
  42. LPITEMIDLIST PidlCombineIdLists(LPCITEMIDLIST pidlRoot, LPCITEMIDLIST pidlLeaf);
  43. #ifdef DEBUG
  44. LPITEMIDLIST NEXTID_C(LPCITEMIDLIST pidl);
  45. void DumpPidl(LPCITEMIDLIST pidl, LPSTR szComment);
  46. #else
  47. #define DumpPidl(x,y)
  48. #endif
  49. #define AthMessageBox(hwnd, pszT, psz1, psz2, fu) MessageBoxInst(g_hLocRes, hwnd, pszT, psz1, psz2, fu)
  50. #define AthMessageBoxW(hwnd, pwszT, pwsz1, pwsz2, fu) MessageBoxInstW(g_hLocRes, hwnd, pwszT, pwsz1, pwsz2, fu, LoadStringWrapW, MessageBoxWrapW)
  51. void AthErrorMessage(HWND hwnd, LPTSTR pszTitle, LPTSTR pszError, HRESULT hrDetail);
  52. void AthErrorMessageW(HWND hwnd, LPWSTR pwszTitle, LPWSTR pwszError, HRESULT hrDetail);
  53. #define AthFileTimeToDateTimeW(pft, wszDateTime, cch, dwFlags) \
  54. CchFileTimeToDateTimeW(pft, wszDateTime, cch, dwFlags, \
  55. GetDateFormatWrapW, GetTimeFormatWrapW, GetLocaleInfoWrapW)
  56. //
  57. // string resource crap
  58. //
  59. int LoadStringReplaceSpecial(UINT id, LPTSTR sz, int cch);
  60. int LoadStringReplaceSpecialW(UINT id, LPWSTR wsz, int cch);
  61. LPTSTR AthLoadString(UINT id, LPTSTR lpBuffer, int nBufferMax);
  62. LPWSTR AthLoadStringW(UINT id, LPWSTR sz, int cch);
  63. #ifdef YST
  64. #undef LoadString
  65. #define LoadString(_hinst, _id, _sz, _cch) _LoadString(_id, _sz, _cch)
  66. int _LoadString(UINT id, LPTSTR lpBuffer, int nBufferMax);
  67. #undef DialogBox
  68. #define DialogBox(_hinst, _sz, _hwnd, _func) _DialogBox(_sz, _hwnd, _func)
  69. int _DialogBox(LPCTSTR lpTemplate, HWND hwnd, DLGPROC func);
  70. #undef DialogBoxIndirect
  71. #define DialogBoxIndirect(_hinst, lpTemplate, hWndParent, lpDialogFunc) _DialogBoxIndirect(lpTemplate, hWndParent, lpDialogFunc)
  72. int _DialogBoxIndirect(LPCTSTR lpTemplate, HWND hwnd, DLGPROC lpDialogFunc);
  73. #undef DialogBoxIndirectParam
  74. #define DialogBoxIndirectParam(_hinst, lpTemplate, hWndParent, lpDialogFunc, dwParam) _DialogBoxIndirectParam(lpTemplate, hWndParent, lpDialogFunc, dwParam)
  75. int _DialogBoxIndirectParam(LPCTSTR lpTemplate, HWND hwnd, DLGPROC lpDialogFunc, LPARAM dwParam);
  76. #undef DialogBoxParam
  77. #define DialogBoxParam(x, y, z, m, n) _DialogBoxParam(y, z, m, n)
  78. int _DialogBoxParam(LPCTSTR lpTemplate, HWND hwnd, DLGPROC func, LPARAM lParam);
  79. #undef CreateDialog
  80. #define CreateDialog(_hinst, _sz, _hwnd, _func) _CreateDialog(_sz, _hwnd, _func)
  81. HWND _CreateDialog(LPCTSTR lpTemplate, HWND hwnd, DLGPROC func);
  82. #undef CreateDialogIndirect
  83. #undef CreateDialogIndirectParam
  84. #undef CreateDialogParam
  85. #define CreateDialogParam(_hinst, _sz, _hwnd, _func, _param) _CreateDialogParam(_sz, _hwnd, _func, _param)
  86. HWND _CreateDialogParam(LPCTSTR lpTemplate, HWND hwnd, DLGPROC func, LPARAM lParam);
  87. #undef LoadMenu
  88. #define LoadMenu(_hinst, _sz) _LoadMenu(_sz)
  89. HMENU _LoadMenu(LPCTSTR lpMenuName);
  90. #undef LoadAccelerators
  91. #define LoadAccelerators(hInst, y) _LoadAccelerators(y)
  92. HACCEL _LoadAccelerators(LPCTSTR lpTableName);
  93. #undef ImageList_LoadImage
  94. #define ImageList_LoadImage(hi, lpbmp, cx, cGrow, crMask, uType, uFlags) _ImageList_LoadImage(lpbmp, cx, cGrow, crMask, uType, uFlags)
  95. HIMAGELIST _ImageList_LoadImage(LPCTSTR lpbmp, int cx, int cGrow, COLORREF crMask, UINT uType, UINT uFlags);
  96. #endif // YST
  97. HBITMAP FAR PASCAL CreateDitherBitmap(COLORREF crFG, COLORREF crBG);
  98. HBRUSH FAR PASCAL CreateDitherBrush(COLORREF crFG, COLORREF crBG);
  99. LRESULT DoDontShowMeAgainDlg(HWND hwndOwner, LPCSTR pszRegString, LPTSTR pszTitle, LPTSTR pszMessage, UINT uType);
  100. DWORD DwGetDontShowAgain (LPCSTR pszRegString);
  101. VOID SetDontShowAgain (DWORD dwDontShow, LPCSTR pszRegString);
  102. void nyi(LPSTR lpsz);
  103. BOOL FNewMessage(HWND hwnd, BOOL fModal, BOOL fNoStationery, BOOL fNews, FOLDERID folderID, IUnknown *pUnkPump);
  104. // Context-sensitive Help utility.
  105. typedef struct _tagHELPMAP
  106. {
  107. DWORD id;
  108. DWORD hid;
  109. } HELPMAP, *LPHELPMAP;
  110. BOOL OnContextHelp(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, HELPMAP const * rgCtxMap);
  111. enum
  112. {
  113. iLeft = 0,
  114. iTop,
  115. iRight,
  116. iBottom
  117. };
  118. // from athena file macros, used when saving files, dragdrop etc.
  119. #define FIsDirectory(szFile) PathIsDirectoryA(szFile)
  120. #define MAX_CHARS_FOR_NUM 20
  121. // ********* WARNING THESE ARE NOT READY FOR PRIME TIME USE *********//
  122. HRESULT CreateLink(LPWSTR pwszPathObj, LPWSTR pwszPathLink, LPWSTR pwszDesc);
  123. void GetDisplayNameForFile(LPWSTR pwszPathName, LPWSTR pwszDisplayName, ULONG cchDisplayName);
  124. HRESULT CreateNewShortCut(LPWSTR pwszPathName, LPWSTR pwszLinkPath, DWORD cchLink);
  125. HRESULT ScGetTempFileName(LPTSTR szOrgName, LPTSTR szTempName, BOOL fPrompt, BOOL fLink);
  126. LPTSTR SzFileNameFromPathName( LPTSTR szPathName );
  127. void AddWelcomeMessage(IMessageFolder *pFolder);
  128. HRESULT HrSaveMessageToFile(HWND hwnd, LPMIMEMESSAGE pMsg, LPMIMEMESSAGE pSecMsg, BOOL fNews, BOOL fCanBeDirty);
  129. BOOL FIsSubDir(LPCSTR szOld, LPCSTR szNew);
  130. VOID OnHelpGoto(HWND hwnd, UINT idh);
  131. VOID OnMailGoto(HWND);
  132. VOID OnNewsGoto(HWND);
  133. VOID OpenClient(HWND, LPCTSTR);
  134. VOID OnBrowserGoto(HWND hwnd, LPCTSTR szRegPage, UINT idDefault);
  135. BOOL GetClientCmdLine(LPCTSTR szClient, LPTSTR szCmdLine, int cch);
  136. //////////////////////////////////////////////////////////////////////////////
  137. // Shell Toolbar Integration Stuff
  138. //
  139. // The arrays of buttons that we can integrate with the shell are defined in
  140. // cbarrays.cpp and are exported here. The views call Util_MergeToolbarButtons()
  141. // to merge the correct array of buttons onto the shell's toolbar.
  142. //
  143. #if 0
  144. //
  145. // TOOLBARARRAYINFO - Contains the various arrays of default and extra toolbar
  146. // buttons along with the array of strings for those buttons.
  147. typedef struct tagTOOLBARARRAYINFO {
  148. const TBBUTTON *rgDefButtons;
  149. DWORD cDefButtons;
  150. const TBBUTTON *rgExtraButtons;
  151. DWORD cExtraButtons;
  152. const DWORD *rgidsButtons;
  153. DWORD cidsButtons;
  154. LPCTSTR pszRegKey;
  155. LPCTSTR pszRegValue;
  156. } TOOLBARARRAYINFO, *PTOOLBARARRAYINFO;
  157. extern const TOOLBARARRAYINFO g_rgToolbarArrayInfo[];
  158. extern const TOOLBARARRAYINFO g_rgNoteToolbarArrayInfo[];
  159. extern const TOOLBARARRAYINFO g_rgRulesToolbarArray;
  160. #endif
  161. //These values should be greater than
  162. #define MailReadNoteType 0
  163. #define MailSendNoteType 1
  164. #define NewsReadNoteType 2
  165. #define NewsSendNoteType 3
  166. #define NOTETYPES_MAX 4
  167. #ifdef DEAD
  168. HRESULT Util_MergeToolbarButtons(IExplorerToolbar* pET, FOLDER_TYPE ftType,
  169. const GUID *cguid, LPTBBUTTON *ppTBButtons,
  170. DWORD *pcButtons);
  171. #endif
  172. interface IImnAccount;
  173. typedef struct tagGETSIGINFO
  174. {
  175. LPCSTR szSigID;
  176. IImnAccount *pAcct;
  177. HWND hwnd;
  178. BOOL fHtmlOk;
  179. BOOL fMail;
  180. UINT uCodePage;
  181. } GETSIGINFO;
  182. HRESULT HrGetMailNewsSignature(GETSIGINFO *pSigInfo, LPDWORD pdwSigOptions, BSTR *pbstrSig);
  183. HRESULT HrLoadStreamFileFromResource(LPCSTR lpszResourceName, LPSTREAM *ppstm);
  184. void ConvertTabsToSpaces(LPSTR lpsz);
  185. void ConvertTabsToSpacesW(LPWSTR lpsz);
  186. void CombineFilters(int *rgidsFilter, int nFilters, LPSTR pszFilter);
  187. void CombineFiltersW(int *rgidsFilter, int nFilters, LPWSTR pwszFilter);
  188. void AthFormatSizeK(DWORD dw, LPTSTR szOut, UINT uiBufSize);
  189. void GetDigitalIDs(IImnAccount *pCertAccount);
  190. INT_PTR CALLBACK ErrSecurityNoSigningCertDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  191. BOOL FGetSelectedCachedMsg(IMsgContainer *pIMC, HWND hwndList, BOOL fSecure, LPMIMEMESSAGE *ppMsg);
  192. BOOL FileExists(TCHAR *szFile, BOOL fNew);
  193. //---------------------------------------------------------------------------
  194. // Cached Password Support
  195. //---------------------------------------------------------------------------
  196. HRESULT SavePassword(DWORD dwPort, LPSTR pszServer, LPSTR pszUsername, LPSTR pszPassword);
  197. HRESULT GetPassword(DWORD dwPort, LPSTR pszServer, LPSTR pszUsername, LPSTR pszPassword,
  198. DWORD dwSizeOfPassword);
  199. void DestroyPasswordList(void);
  200. //------------------------------
  201. // Drag Drop utils
  202. //------------------------------
  203. HRESULT CALLBACK FreeAthenaDataObj(PDATAOBJINFO pDataObjInfo, DWORD celt);
  204. HRESULT _IsSameObject(IUnknown* punk1, IUnknown* punk2);
  205. // These macros are from \\trango\slmro\proj\win\src\shell\ccshell\inc\ccstock.h
  206. #define SetFlag(f) do {m_dwState |= (f);} while (0)
  207. #define ToggleFlag(f) do {m_dwState ^= (f);} while (0)
  208. #define ClearFlag(f) do {m_dwState &= ~(f);} while (0)
  209. #define IsFlagSet(f) (BOOL)(((m_dwState) & (f)) == (f))
  210. #define IsFlagClear(f) (BOOL)(((m_dwState) & (f)) != (f))
  211. // From wndutil.*
  212. /*
  213. * tabbing, parents etc
  214. */
  215. HWND GetTopMostParent(HWND hwndChild);
  216. void GetChildRect(HWND hwndDlg, HWND hwndChild, RECT *prc);
  217. void SaveFocus(BOOL fActive, HWND *phwnd);
  218. void EnableThreadWindows(BOOL fEnable);
  219. /*
  220. * toobar helpers
  221. */
  222. void DoToolbarDropdown(HWND hwnd, LPNMHDR lpnmh, HMENU hmenu);
  223. /*
  224. * paint blocker
  225. */
  226. HWND HwndStartBlockingPaints(HWND hwnd);
  227. void StopBlockingPaints(HWND hwndBlock);
  228. /*
  229. * edit control helpers
  230. */
  231. #define FReadOnlyEdit(hwndEdit) (BOOL)(GetWindowLong(hwndEdit, GWL_STYLE)&ES_READONLY)
  232. //Enable/Disable flags for edit menu etc
  233. enum
  234. {
  235. edfEditFocus =0x00000001,
  236. edfUndo =0x00000002,
  237. edfEditHasSel =0x00000004,
  238. edfEditHasSelAndIsRW=0x00000010,
  239. edfPaste =0x00000020
  240. };
  241. void GetEditDisableFlags(HWND hwndEdit, DWORD *pdwFlags);
  242. void EnableDisableEditMenu(HMENU hmenuEdit, DWORD dwFlags);
  243. void EnableDisableEditToolbar(HWND hwndToolbar, DWORD dwFlags);
  244. /*
  245. * dialog helpers
  246. */
  247. BOOL AllocStringFromDlg(HWND hwnd, UINT id, LPTSTR * lplpsz);
  248. /*
  249. * general
  250. */
  251. HCURSOR HourGlass();
  252. class CEmptyList
  253. {
  254. public:
  255. CEmptyList()
  256. {
  257. m_hwndList = NULL;
  258. m_hwndBlocker = NULL;
  259. m_hwndHeader = NULL;
  260. m_pszString = NULL;
  261. m_pfnWndProc = NULL;
  262. m_hbrBack = NULL;
  263. }
  264. ~CEmptyList()
  265. {
  266. if (IsWindow(m_hwndBlocker))
  267. DestroyWindow(m_hwndBlocker);
  268. SafeMemFree(m_pszString);
  269. if (NULL != m_hbrBack)
  270. DeleteObject(m_hbrBack);
  271. }
  272. HRESULT Show(HWND hwndList, LPTSTR pszString);
  273. HRESULT Hide(void);
  274. static LRESULT SubclassWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  275. private:
  276. HWND m_hwndList;
  277. HWND m_hwndBlocker;
  278. HWND m_hwndHeader;
  279. LPTSTR m_pszString;
  280. WNDPROC m_pfnWndProc;
  281. HBRUSH m_hbrBack;
  282. };
  283. HWND FindModalOwner();
  284. void FreeMessageInfo(LPMESSAGEINFO pMsgInfo);
  285. LPWSTR Util_EnumFiles(LPCWSTR pwszDir, LPCWSTR pwszMatch);
  286. HRESULT GetDefaultNewsServer(LPTSTR pszServerId, DWORD cchMax);
  287. #define ETW_OE_WINDOWS_ONLY 0x0001
  288. typedef struct _HWNDLIST
  289. {
  290. DWORD dwFlags;
  291. HWND *rgHwnd;
  292. int cAlloc;
  293. int cHwnd;
  294. } HWNDLIST;
  295. HRESULT EnableThreadWindows(HWNDLIST *pHwndList, BOOL fEnable, DWORD dwFlags, HWND hwndExcept);
  296. HRESULT GetOEUserName(BSTR *pbstr);
  297. HRESULT CloseThreadWindows(HWND hwndExcept, DWORD dwThreadId);
  298. void ActivatePopupWindow(HWND hwnd);
  299. BOOL HideHotmail(void);
  300. BOOL FIsIMAPOrHTTPAvailable(VOID);
  301. BOOL IsBiDiCalendar(void);
  302. LPSTR PszAllocResUrl(LPSTR pszRelative);
  303. BOOL GetTextExtentPoint32AthW(HDC hdc, LPCWSTR lpwString, int cchString, LPSIZE lpSize, DWORD dwFlags);
  304. #endif // __UTIL_H__