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.

154 lines
4.3 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1995 - 1999
  3. All rights reserved.
  4. Module Name:
  5. spllibex.hxx
  6. Abstract:
  7. spllib extentions
  8. Author:
  9. Lazar Ivanov (LazarI) 29-Mar-2000
  10. Revision History:
  11. --*/
  12. #ifndef _SPLLIBEX_HXX
  13. #define _SPLLIBEX_HXX
  14. ////////////////////////////////////////////////
  15. //
  16. // class CMsgBoxCounter
  17. //
  18. // global message box counter based on TLS cookies
  19. //
  20. class CMsgBoxCounter
  21. {
  22. public:
  23. enum { INVALID_COUNT = -1 };
  24. CMsgBoxCounter(UINT uFlags = MB_ICONHAND);
  25. ~CMsgBoxCounter();
  26. static BOOL Initialize();
  27. static BOOL Uninitialize();
  28. static UINT GetCount();
  29. static BOOL IsInitialized();
  30. static void LogMessage(UINT uFlags);
  31. // override the the last error message
  32. // based on the context where the error
  33. // occured.
  34. static void SetMsg(UINT uMsgID);
  35. static UINT GetMsg();
  36. private:
  37. UINT m_uCount;
  38. UINT m_uFlags;
  39. UINT m_uMsgID;
  40. };
  41. /////////////////////////////////////////////////////
  42. // interface - IPrinterChangeCallback
  43. //
  44. #undef INTERFACE
  45. #define INTERFACE IPrinterChangeCallback
  46. DECLARE_INTERFACE_(IPrinterChangeCallback, IUnknown)
  47. {
  48. //////////////////
  49. // IUnknown
  50. //
  51. STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  52. STDMETHOD_(ULONG,AddRef)(THIS) PURE;
  53. STDMETHOD_(ULONG,Release)(THIS) PURE;
  54. ///////////////////////////
  55. // IPrinterChangeCallback
  56. //
  57. STDMETHOD(PrinterChange)(ULONG_PTR uCookie, DWORD dwChange, const PRINTER_NOTIFY_INFO *pInfo) PURE;
  58. };
  59. ////////////////////////////////////////////////
  60. //
  61. // class CPrintNotify
  62. //
  63. // printer notifications listener
  64. //
  65. class CPrintNotify: public MNotifyWork
  66. {
  67. public:
  68. typedef HRESULT (*PFN_PrinterChange)(LPVOID lpCookie, ULONG_PTR uCookie, DWORD dwChange, const PRINTER_NOTIFY_INFO *pInfo);
  69. CPrintNotify(
  70. IPrinterChangeCallback *pClient,
  71. DWORD dwCount,
  72. const PPRINTER_NOTIFY_OPTIONS_TYPE arrNotifications,
  73. DWORD dwFlags
  74. );
  75. ~CPrintNotify();
  76. HRESULT Initialize(LPCTSTR pszPrinter); // the printer to listen, can be NULL for the server case
  77. HRESULT Uninitialize(); // stop listen & shutdown
  78. HRESULT Refresh(LPVOID lpCookie, PFN_PrinterChange pfn); // refresh all
  79. HRESULT StartListen(); // start listening for notifications
  80. HRESULT StopListen(); // stop listening and close the handles
  81. HRESULT SetCookie(ULONG_PTR uCookie); // set a cookie to be passed back in the callbacks
  82. LPCTSTR GetPrinter() const; // return the current printer, NULL if not initialized
  83. HANDLE GetPrinterHandle() const; // return the current printer handle
  84. private:
  85. HRESULT _NotifyRegister(BOOL bRegister);
  86. // MNotifyWork impl.
  87. virtual HANDLE hEvent() const;
  88. virtual void vProcessNotifyWork(TNotify *pNotify);
  89. // members
  90. DWORD m_dwCount;
  91. const PPRINTER_NOTIFY_OPTIONS_TYPE m_arrNotifications;
  92. BOOL m_bRegistered;
  93. ULONG_PTR m_uCookie;
  94. DWORD m_dwFlags;
  95. CAutoHandlePrinterNotify m_shNotify;
  96. CAutoHandlePrinter m_shPrinter;
  97. CRefPtrCOM<IPrinterChangeCallback> m_spClient;
  98. TString m_strPrinter;
  99. TRefLock<TPrintLib> m_pPrintLib;
  100. // !!MT NOTES!!
  101. // all the functions of this object besides hEvent, vProcessNotifyWork
  102. // and GetPrinter should never be used from multiple threads simultaneously!
  103. // they can only be called from the tray UI thread (i.e. from within the
  104. // wndproc of the hidden tray window).
  105. SINGLETHREAD_VAR(TrayUIThread)
  106. };
  107. ///////////////////////////////////////////////////////////////
  108. // CMultilineEditBug - edit control subclass
  109. //
  110. // there is a bug in the multiline edit control which now
  111. // is considered a "feature" since it's been there forever.
  112. // the bug is that the edit contol is eating the VK_RETURN
  113. // even if it doesn't have the ES_WANTRETURN style which is
  114. // preventing the dialog from closing.
  115. //
  116. class CMultilineEditBug: public CSimpleWndSubclass<CMultilineEditBug>
  117. {
  118. public:
  119. CMultilineEditBug() { }
  120. // default subclass proc
  121. LRESULT WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  122. };
  123. #endif // ndef _SPLLIBEX_HXX