loginPopup.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #ifndef NULLSOFT_AUTH_LOGINPOPUP_HEADER
  2. #define NULLSOFT_AUTH_LOGINPOPUP_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include <wtypes.h>
  7. // messages
  8. #define NLPOPUP_FIRST (WM_APP + 100)
  9. #define NLPOPUP_UPDATEWNDPOS (NLPOPUP_FIRST + 0) // wParam - (WPARAM)(const RECT*)clientRect, lParam = (LPARAM)(RECT*)popupRectOut; Return TRUE if you set controlRect;
  10. #define LoginPopup_UpdateWindowPos(/*HWND*/ __hwnd, /*const RECT* */__clientRect, /*RECT* */__popupRectOut)\
  11. ((BOOL)SNDMSG((__hwnd), NLPOPUP_UPDATEWNDPOS, (WPARAM)(__clientRect), (LPARAM)(__popupRectOut)))
  12. #define NLPOPUP_PLAYBEEP (NLPOPUP_FIRST + 1) // wParam - not used, lParam - not used; Return ignored
  13. #define LoginPopup_PlayBeep(/*HWND*/ __hwnd)\
  14. (SNDMSG((__hwnd), NLPOPUP_PLAYBEEP, 0, 0L))
  15. // notifications
  16. #define NLPOPUPN_FIRST (100)
  17. typedef struct __NLPNRESULT
  18. {
  19. NMHDR hdr;
  20. INT_PTR exitCode;
  21. } NLPNRESULT;
  22. #define NLPN_RESULT (NLPOPUPN_FIRST + 0)
  23. class __declspec(novtable) LoginPopup
  24. {
  25. public:
  26. typedef HRESULT (CALLBACK *Creator)(HWND /*hwnd*/, LPARAM /*param*/, LoginPopup** /*instance*/);
  27. typedef BOOL (CALLBACK *Enumerator)(HWND /*hwnd*/, LPARAM /*param*/);
  28. protected:
  29. LoginPopup(HWND hwnd, UINT popupType, LPCWSTR pszTitle);
  30. virtual ~LoginPopup();
  31. protected:
  32. static HWND CreatePopup(LPCWSTR pszTemplate, HWND hParent, LPARAM param, Creator fnCreator);
  33. public:
  34. static BOOL RegisterPopup(HWND hwnd, BOOL fRegister);
  35. static BOOL EnumeratePopups(HWND hHost, Enumerator callback, LPARAM param);
  36. static BOOL AnyPopup(HWND hHost);
  37. protected:
  38. virtual void UpdateLayout(BOOL fRedraw);
  39. virtual void Paint(HDC hdc, const RECT *prcPaint, BOOL fErase);
  40. virtual void EndDialog(INT_PTR code);
  41. virtual void UpdateMargins();
  42. virtual void SetTitle(UINT type, LPCWSTR title);
  43. virtual void SetAlert(UINT type, LPCWSTR message);
  44. virtual void RemoveAlert();
  45. virtual void UpdateTitle(BOOL playBeep);
  46. BOOL GetInfoRect(RECT *rect);
  47. BOOL CalculateWindowRect(LONG infoWidth, LONG infoHeight, const INT *buttonList, UINT buttonCount, BOOL includeTitle, RECT *rect);
  48. HDWP LayoutButtons(HDWP hdwp, const INT *buttonList, UINT buttonCount, BOOL redraw, RECT *rectOut);
  49. LRESULT SendNotification(UINT code, NMHDR *pnmh);
  50. BOOL GetTextSize(HWND hText, LONG width, SIZE *size);
  51. protected:
  52. virtual BOOL OnInitDialog(HWND hFocus, LPARAM param);
  53. virtual void OnDestroy();
  54. virtual void OnCommand(UINT commandId, UINT eventType, HWND hControl);
  55. virtual LRESULT OnNotify(UINT controlId, const NMHDR *pnmh);
  56. virtual HBRUSH OnGetStaticColor(HDC hdc, HWND hControl);
  57. virtual void OnParentNotify(UINT eventId, UINT wParam, LPARAM lParam);
  58. void OnPaint();
  59. void OnWindowPosChanged(const WINDOWPOS *pwp);
  60. void OnPrintClient(HDC hdc, UINT options);
  61. void OnSetFont(HFONT font, BOOL redraw);
  62. virtual BOOL OnUpdateWindowPos(const RECT* clientRect, RECT *rectOut);
  63. virtual void OnPlayBeep();
  64. virtual INT_PTR DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
  65. private:
  66. friend static INT_PTR CALLBACK LoginPopup_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  67. friend static LRESULT CALLBACK LoginPopup_MessageFilter(INT code, WPARAM wParam, LPARAM lParam);
  68. protected:
  69. HWND hwnd;
  70. SIZE idealSize;
  71. RECT clientMargins;
  72. RECT infoMargins;
  73. LONG buttonHeight;
  74. LONG buttonSpace;
  75. UINT popupType;
  76. UINT alertType;
  77. LPWSTR alertMessage;
  78. };
  79. #endif //NULLSOFT_AUTH_LOGINPOPUP_HEADER