PCWnd.h
上传用户:xajzjg
上传日期:2007-01-01
资源大小:277k
文件大小:3k
源码类别:

Windows编程

开发平台:

Visual C++

  1. #if !defined(AFX_PCWND_H__F811DE85_4497_11D1_80AD_080009CC78D8__INCLUDED_)
  2. #define AFX_PCWND_H__F811DE85_4497_11D1_80AD_080009CC78D8__INCLUDED_
  3. #if _MSC_VER >= 1000
  4. #pragma once
  5. #endif // _MSC_VER >= 1000
  6. // PCWnd.h : header file
  7. //
  8. /////////////////////////////////////////////////////////////////////
  9. // Class CPopChildWnd encapsulates a child-popup window, that can be dragged
  10. // in or out of a parent-owner window to make itself instantly a
  11. // child or popup.
  12. // To use CPopChildWnd:
  13. // 1. Embed a CPopChildWnd in the parent-owner class.
  14. // 2. Call CPopChildWnd's Create function when the parent-owner is created.
  15. // 3. Call CPopChildWnd's Destroy function when the parent-owner is 
  16. //      destroyed.
  17. //
  18. // Normally you want to derive a class from CPopChildWnd and override its OnDraw
  19. // member function.
  20. //
  21. class CPopChildWnd;
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CPCWnd window
  24. class CPCWnd : public CWnd
  25. {
  26. // Construction
  27. public:
  28. CPCWnd();
  29. BOOL Create(CPopChildWnd* pOuter, DWORD dwStyle, const RECT& rect, 
  30.                               HWND hParentWnd, UINT nID);
  31. // Attributes
  32. public:
  33. // Operations
  34. public:
  35. CPoint GetOffPoint() { return m_point; }
  36. // Overrides
  37. // ClassWizard generated virtual function overrides
  38. //{{AFX_VIRTUAL(CPCWnd)
  39. //}}AFX_VIRTUAL
  40. // Implementation
  41. public:
  42. virtual ~CPCWnd();
  43. // Generated message map functions
  44. protected:
  45. //{{AFX_MSG(CPCWnd)
  46. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  47. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  48. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  49. afx_msg void OnPaint();
  50. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  51. afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); 
  52. //}}AFX_MSG
  53. DECLARE_MESSAGE_MAP()
  54. void Draw(CDC* pDC);
  55. CPoint m_point;
  56. CPopChildWnd* m_pOuter;
  57. };
  58. class CPopChildWnd
  59. {
  60. public:
  61. CPopChildWnd();
  62. ~CPopChildWnd();
  63. void Create(HWND hParentOwnerWnd, CRect& rect, BOOL bChildFirst);
  64. void Destroy();
  65. void SetBkColor(COLORREF color=RGB(129, 129, 129)) 
  66. { m_BkColor = color; }
  67. void SetPos(CRect& rect, BOOL bChildOnly=TRUE);
  68. void Switch();
  69. protected:
  70. // overridable
  71. virtual void OnDraw(CDC* pDC, CPCWnd* pWnd);
  72. virtual BOOL OnMouseMove(CPCWnd* pWnd);
  73. virtual BOOL OnLButtonDown(CPCWnd* pWnd, CPoint point);
  74. virtual BOOL OnLButtonUp(CPCWnd* pWnd);
  75. COLORREF OnGetBkColor() { return m_BkColor; }
  76. virtual BOOL OnSetCursor(CPCWnd* pWnd, UINT nHitTest, UINT message);
  77. BOOL Captured();
  78. friend class CPCWnd;
  79. enum { TOUCH, INSIDE, OUTSIDE };
  80. int RectRect(CRect rc1, CRect rc2);
  81. BOOL OnChange(CPCWnd* pWnd);
  82. CPCWnd m_ChildWnd;
  83. CPCWnd m_PopupWnd;
  84. COLORREF m_BkColor;
  85. HWND m_hParentOwner;
  86. CPoint m_offPt;
  87. };
  88. /////////////////////////////////////////////////////////////////////////////
  89. //{{AFX_INSERT_LOCATION}}
  90. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  91. #endif // !defined(AFX_PCWND_H__F811DE85_4497_11D1_80AD_080009CC78D8__INCLUDED_)