GraphWnd.h
资源名称:GGBT.rar [点击查看]
上传用户:lds876
上传日期:2013-05-25
资源大小:567k
文件大小:5k
源码类别:
P2P编程
开发平台:
Visual C++
- #if !defined(AFX_GRAPHWND_H__F0ED8D7D_618F_4CB4_8DD9_FF9A6C5563C2__INCLUDED_)
- #define AFX_GRAPHWND_H__F0ED8D7D_618F_4CB4_8DD9_FF9A6C5563C2__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- // GraphWnd.h : header file
- //
- class CFileDBItem;
- class CMonitorWnd;
- /////////////////////////////////////////////////////////////////////////////
- // CGraphWnd window
- class CGraphWnd : public CWnd
- {
- // Construction
- public:
- CGraphWnd();
- // Attributes
- public:
- // Operations
- public:
- void Monitor(CFileDBItem* pFileDBItem);
- void ShowGraph(bool bRefreshInfo);
- void SetContent(vector<long> vItems);
- // Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CGraphWnd)
- public:
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- //}}AFX_VIRTUAL
- // Implementation
- public:
- BOOL CreateEx(CWnd* pParent, CRect rc, long lID, long lParam, CMonitorWnd* pMonitorWnd);
- virtual ~CGraphWnd();
- // Generated message map functions
- protected:
- //{{AFX_MSG(CGraphWnd)
- afx_msg void OnPaint();
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
- afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
- afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
- afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
- //}}AFX_MSG
- afx_msg void OnMenuitemMonitorSub(UINT uID);
- DECLARE_MESSAGE_MAP()
- private:
- void Refresh();
- void SetSubItem(long lSubitemInx, long lVal, CDC *pDC);
- void OnSizeChanged(int cx, int cy);
- void DrawItem(CDC* pDC = NULL);
- void DrawSubItem(CDC* pDC, long lSubitemInx);
- COLORREF m_clrBackground; // Control background color
- CBitmap m_bmp;
- const CSize m_size;
- long m_lGridCountV;
- long m_lGridCountH;
- long m_lBeginInx;
- long m_lLineCount;
- vector<long> m_vItems;
- vector<long> m_vGrids;
- CFileDBItem* m_pFileDBItem;
- CMonitorWnd* m_pMonitorWnd;
- class CMemDC : public CDC {
- private:
- CBitmap m_bitmap; // Offscreen bitmap
- CBitmap* m_oldBitmap; // bitmap originally found in CMemDC
- CDC* m_pDC; // Saves CDC passed in constructor
- CRect m_rect; // Rectangle of drawing area.
- BOOL m_bMemDC; // TRUE if CDC really is a Memory DC.
- public:
- CMemDC(CDC* pDC, const CRect* pRect = NULL) : CDC()
- {
- ASSERT(pDC != NULL);
- // Some initialization
- m_pDC = pDC;
- m_oldBitmap = NULL;
- m_bMemDC = !pDC->IsPrinting();
- // Get the rectangle to draw
- if (pRect == NULL) {
- pDC->GetClipBox(&m_rect);
- } else {
- m_rect = *pRect;
- }
- if (m_bMemDC) {
- // Create a Memory DC
- CreateCompatibleDC(pDC);
- pDC->LPtoDP(&m_rect);
- m_bitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height());
- m_oldBitmap = SelectObject(&m_bitmap);
- SetMapMode(pDC->GetMapMode());
- pDC->DPtoLP(&m_rect);
- SetWindowOrg(m_rect.left, m_rect.top);
- } else {
- // Make a copy of the relevent parts of the current DC for printing
- m_bPrinting = pDC->m_bPrinting;
- m_hDC = pDC->m_hDC;
- m_hAttribDC = pDC->m_hAttribDC;
- }
- // Fill background
- FillSolidRect(m_rect, pDC->GetBkColor());
- }
- ~CMemDC()
- {
- if (m_bMemDC) {
- // Copy the offscreen bitmap onto the screen.
- m_pDC->BitBlt(m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(),
- this, m_rect.left, m_rect.top, SRCCOPY);
- //Swap back the original bitmap.
- SelectObject(m_oldBitmap);
- } else {
- // All we need to do is replace the DC with an illegal value,
- // this keeps us from accidently deleting the handles associated with
- // the CDC that was passed to the constructor.
- m_hDC = m_hAttribDC = NULL;
- }
- }
- // Allow usage as a pointer
- CMemDC* operator->()
- {
- return this;
- }
- // Allow usage as a pointer
- operator CMemDC*()
- {
- return this;
- }
- };
- };
- /////////////////////////////////////////////////////////////////////////////
- //{{AFX_INSERT_LOCATION}}
- // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
- #endif // !defined(AFX_GRAPHWND_H__F0ED8D7D_618F_4CB4_8DD9_FF9A6C5563C2__INCLUDED_)