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.

132 lines
4.3 KiB

  1. //-----------------------------------------------------------------------------
  2. // File: flexwnd.h
  3. //
  4. // Desc: CFlexWnd is a generic class that encapsulates the functionalities
  5. // of a window. All other window classes are derived from CFlexWnd.
  6. //
  7. // Child classes can have different behavior by overriding the
  8. // overridable message handlers (OnXXX members).
  9. //
  10. // Copyright (C) 1999-2000 Microsoft Corporation. All Rights Reserved.
  11. //-----------------------------------------------------------------------------
  12. #ifndef __FLEXWND_H__
  13. #define __FLEXWND_H__
  14. #include "flexmsg.h"
  15. class CFlexToolTip;
  16. class CFlexWnd
  17. {
  18. public:
  19. CFlexWnd();
  20. ~CFlexWnd();
  21. // class registration
  22. static void RegisterWndClass(HINSTANCE hInst);
  23. static void UnregisterWndClass(HINSTANCE hInst);
  24. // Unhighlight callouts when a click is made elsewhere besides the callouts
  25. static HWND s_CurrPageHwnd;
  26. // Tooltip
  27. static CFlexToolTip s_ToolTip; // Shared tooltip window object
  28. static DWORD s_dwLastMouseMove; // Last GetTickCount() that we have a WM_MOUSEMOVE
  29. static HWND s_hWndLastMouseMove; // Last window handle of WM_MOUSEMOVE
  30. static LPARAM s_PointLastMouseMove; // Last point of WM_MOUSEMOVE
  31. // public read-only access to hwnd
  32. const HWND &m_hWnd;
  33. // creation
  34. int DoModal(HWND hParent, int nTemplate, HINSTANCE hInst = NULL);
  35. int DoModal(HWND hParent, LPCTSTR lpTemplate, HINSTANCE hInst = NULL);
  36. HWND DoModeless(HWND hParent, int nTemplate, HINSTANCE hInst = NULL);
  37. HWND DoModeless(HWND hParent, LPCTSTR lpTemplate, HINSTANCE hInst = NULL);
  38. HWND Create(HWND hParent, LPCTSTR tszName, DWORD dwExStyle, DWORD dwStyle, const RECT &rect, HMENU hMenu = NULL);
  39. HWND Create(HWND hParent, const RECT &rect, BOOL bVisible);
  40. // destruction
  41. void Destroy();
  42. // operations
  43. void RenderInto(HDC hDC, int x = 0, int y = 0);
  44. void Invalidate();
  45. // information
  46. SIZE GetClientSize() const;
  47. void GetClientRect(LPRECT) const;
  48. static CFlexWnd *GetFlexWnd(HWND hWnd);
  49. BOOL HasWnd() {return m_hWnd != NULL;}
  50. static LPCTSTR GetDefaultClassName();
  51. BOOL IsDialog();
  52. BOOL InRenderMode();
  53. void SetReadOnly(BOOL bReadOnly) { m_bReadOnly = bReadOnly; }
  54. BOOL GetReadOnly() { return m_bReadOnly; }
  55. // mouse capture
  56. void SetCapture();
  57. void ReleaseCapture();
  58. protected:
  59. // derived operations
  60. void SetRenderMode(BOOL bRender = TRUE);
  61. BOOL EndDialog(int);
  62. // overridable message handlers
  63. virtual void OnInit() {}
  64. virtual LRESULT OnCreate(LPCREATESTRUCT lpCreateStruct) {return 0;}
  65. virtual BOOL OnInitDialog() {return TRUE;}
  66. virtual void OnTimer(UINT uID) {}
  67. virtual BOOL OnEraseBkgnd(HDC hDC);
  68. virtual void OnPaint(HDC hDC) {}
  69. virtual void OnRender(BOOL bInternalCall = FALSE);
  70. virtual LRESULT OnCommand(WORD wNotifyCode, WORD wID, HWND hWnd) {return 0;}
  71. virtual LRESULT OnNotify(WPARAM wParam, LPARAM lParam) {return 0;}
  72. virtual void OnMouseOver(POINT point, WPARAM fwKeys) {}
  73. virtual void OnClick(POINT point, WPARAM fwKeys, BOOL bLeft) {}
  74. virtual void OnWheel(POINT point, WPARAM wParam) {}
  75. virtual void OnDoubleClick(POINT point, WPARAM fwKeys, BOOL bLeft) {}
  76. virtual LRESULT WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
  77. virtual void OnDestroy() {}
  78. private:
  79. // implementation...
  80. // information and initialization
  81. int m_nID;
  82. HWND m_privhWnd;
  83. BOOL m_bIsDialog;
  84. BOOL m_bReadOnly; // Whether this window is read-only (disabled).
  85. void SetHWND(HWND hWnd);
  86. void InitFlexWnd();
  87. // paint helper (for inserting debug painting)
  88. virtual void DoOnPaint(HDC hDC);
  89. // render mode
  90. BOOL m_bRender;
  91. HDC m_hRenderInto;
  92. BOOL RenderIntoClipChild(HWND hChild);
  93. BOOL RenderIntoRenderChild(HWND hChild);
  94. friend static BOOL CALLBACK RenderIntoClipChild(HWND hWnd, LPARAM lParam);
  95. friend static BOOL CALLBACK RenderIntoRenderChild(HWND hWnd, LPARAM lParam);
  96. // class information
  97. static void FillWndClass(HINSTANCE hInst);
  98. static BOOL sm_bWndClassRegistered;
  99. static WNDCLASSEX sm_WndClass;
  100. static LPCTSTR sm_tszWndClassName;
  101. static HINSTANCE sm_hInstance;
  102. friend LRESULT CALLBACK __BaseFlexWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
  103. friend INT_PTR CALLBACK __BaseFlexWndDialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
  104. };
  105. #endif //__FLEXWND_H__