Popup.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #pragma once
  2. /*------------------------------------------------------------------*\
  3. CPopup - a tooltip that pops up manually (when Show is called).
  4. - technique learned from codeproject "ToolTipZen" by "Zarembo Maxim"
  5. \*------------------------------------------------------------------*/
  6. void InitToolInfo( TOOLINFO& ti ); // initializes toolinfo with uid 0
  7. class CPopup
  8. {
  9. public:
  10. bool m_bOwnTT;
  11. HWND m_hTTWnd; // handle to the ToolTip control
  12. TOOLINFO m_TI; // struct specifying info about tool in ToolTip control
  13. bool m_bIsShowing;
  14. bool m_bTop; // true if m_Pos.x is the top, false if the bottom
  15. bool m_bLeft; // true if m_Pos.y is the left, false if the right
  16. bool m_bCenterY; // true if m_Pos is the y center, false if corner
  17. bool m_bCenterX; // true if m_Pos is the x center, false if corner
  18. HWND m_hWndPosRelativeTo;
  19. CPoint m_Pos;
  20. int m_ScreenMaxX;
  21. int m_ScreenMaxY;
  22. HWND m_hWndInsertAfter;
  23. bool m_bAllowShow; // used by SafeShow to determine whether to show or not
  24. CString m_csToolTipText;
  25. CPopup();
  26. CPopup( int x, int y, HWND hWndPosRelativeTo = NULL, HWND hWndInsertAfter = HWND_TOP );
  27. ~CPopup();
  28. void Init();
  29. void SetTTWnd( HWND hTTWnd = NULL, TOOLINFO* pTI = NULL );
  30. void CreateToolTip();
  31. void SetTimeout( int timeout );
  32. void AdjustPos( CPoint& pos );
  33. void SetPos( CPoint& pos );
  34. void SetPosInfo( bool bTop, bool bCenterY, bool bLeft, bool bCenterX );
  35. void SendToolTipText( CString text );
  36. void Show( CString text, CPoint pos, bool bAdjustPos = true );
  37. void Show( CString text );
  38. void AllowShow( CString text ); // only shows if m_bAllowShow is true
  39. void Hide();
  40. };