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.

123 lines
3.2 KiB

  1. //util.h - header file for utiltity functions
  2. #ifndef _UTIL_H_
  3. #define _UTIL_H_
  4. #include <atlwin.h>
  5. #include <atlctrls.h>
  6. // Extended listview control class
  7. // This class adds the feature of setting focus to the listview window
  8. // on a left mouse button down event.
  9. class CListViewEx : public CWindowImpl<CListViewEx, CListViewCtrl>
  10. {
  11. BEGIN_MSG_MAP(CListViewEx)
  12. MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
  13. END_MSG_MAP()
  14. LRESULT OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  15. {
  16. SetFocus();
  17. bHandled = 0;
  18. return TRUE;
  19. }
  20. };
  21. HBITMAP GetBitmapFromStrip(HBITMAP hbmStrip, int nPos, int cSize);
  22. void ConfigSingleColumnListView(HWND hwndListView);
  23. BOOL ModifyStyleEx(HWND hWnd, DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0);
  24. void EnableDlgItem(HWND hwndDialog, int iCtrlID, BOOL bEnable);
  25. void GetItemText(HWND hwnd, tstring& strText);
  26. void RemoveSpaces(LPWSTR pszBuf);
  27. VARIANT GetDomainPath(LPCTSTR lpServer);
  28. HRESULT ExpandDCWildCard(tstring& str);
  29. void EscapeSlashes(LPCWSTR pszIn, tstring& strOut);
  30. HRESULT ExpandEnvironmentParams(tstring& strIn, tstring& strOut);
  31. tstring StrLoadString( UINT nID );
  32. //
  33. // Parameter substitution function
  34. //
  35. // CParamLookup - function object for looking up parameter values
  36. //
  37. // Looks up parameter replacement string value, returning a BOOL to
  38. // indicate iwhether a value was found.
  39. class CParamLookup
  40. {
  41. public:
  42. virtual BOOL operator()(tstring& strParm, tstring& strValue) = 0;
  43. };
  44. HRESULT ReplaceParameters(tstring& str, CParamLookup& lookup, BOOL bRetainMarkers);
  45. //
  46. // MMC String table helpers
  47. //
  48. HRESULT StringTableWrite(IStringTable* pStringTable, LPCWSTR psz, MMC_STRING_ID* pID);
  49. HRESULT StringTableRead(IStringTable* pStringTable, MMC_STRING_ID ID, tstring& str);
  50. //
  51. // File/Directory validation functions
  52. //
  53. HRESULT ValidateFile(tstring& strFilePath);
  54. HRESULT ValidateDirectory(tstring& strDir);
  55. //
  56. // Message box helper
  57. //
  58. int DisplayMessageBox(HWND hWnd, UINT uTitleID, UINT uMsgID, UINT uStyle = MB_OK | MB_ICONEXCLAMATION,
  59. LPCWSTR pszP1 = NULL, LPCWSTR pszP2 = NULL);
  60. //
  61. // Event triggered callback
  62. //
  63. // CEventCallback - function object that performs a callback
  64. //
  65. // client who wants a callback derives a class from CEventCallback
  66. // and passes an instance of it to CallbackOnEvent
  67. class CEventCallback
  68. {
  69. public:
  70. virtual void Execute() = 0;
  71. };
  72. HRESULT CallbackOnEvent(HANDLE handle, CEventCallback* pCallback);
  73. //
  74. // Helper class to register and create hidden message windows
  75. //
  76. class CMsgWindowClass
  77. {
  78. public:
  79. CMsgWindowClass(LPCWSTR pszClassName, WNDPROC pWndProc)
  80. : m_pszName(pszClassName), m_pWndProc(pWndProc), m_atom(NULL), m_hWnd(NULL)
  81. {
  82. }
  83. virtual ~CMsgWindowClass()
  84. {
  85. if( m_hWnd )
  86. DestroyWindow(m_hWnd);
  87. if( m_atom )
  88. UnregisterClass(m_pszName, _Module.GetModuleInstance());
  89. }
  90. HWND Window();
  91. private:
  92. LPCWSTR m_pszName;
  93. WNDPROC m_pWndProc;
  94. ATOM m_atom;
  95. HWND m_hWnd;
  96. };
  97. #endif // _UTIL_H_