我收到此错误“错误 2 错误 LNK2005:“公共:虚拟 __thiscall CMemDC::~CMemDC(void)”(??1CMemDC@@UAE@XZ) 已在 SkinHeaderCtrl.obj C:\Users\anthonyd\Desktop\ 中定义ASPX\STP\nafxcwd.lib(afxglobals.obj) STP"
我已经阅读了许多类似的问题,但找不到合适的问题。有人可以帮忙吗?
// SkinHeaderCtrl.cpp : implementation file
//
#include "stdafx.h"
#include "STP.h"
#include "SkinHeaderCtrl.h"
#include "memdc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define BACKGROUND RGB(218,218,218)// was 218,218,218
#define HEIGHT 16
/////////////////////////////////////////////////////////////////////////////
// CSkinHeaderCtrl
CSkinHeaderCtrl::CSkinHeaderCtrl()
{
}
CSkinHeaderCtrl::~CSkinHeaderCtrl()
{
}
BEGIN_MESSAGE_MAP(CSkinHeaderCtrl, CHeaderCtrl)
//{{AFX_MSG_MAP(CSkinHeaderCtrl)
ON_WM_PAINT()
ON_WM_ERASEBKGND()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSkinHeaderCtrl message handlers
void CSkinHeaderCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
}
void CSkinHeaderCtrl::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rect, rectItem, clientRect;
GetClientRect(&rect);
GetClientRect(&clientRect);
CMemDC memDC(&dc, rect);
CDC bitmapDC;
bitmapDC.CreateCompatibleDC(&dc);
// memDC.FillSolidRect(&rect, RGB(76,85,118));
memDC.FillSolidRect(&rect, BACKGROUND);
CBitmap bitmapSpan;
bitmapSpan.LoadBitmap(IDB_COLUMNHEADER_SPAN);
CBitmap* pOldBitmapSpan = bitmapDC.SelectObject(&bitmapSpan);
// memDC.StretchBlt(rect.left+2, 0, rect.Width(), 12, &bitmapDC, 0, 0, 1, 12, SRCCOPY);
memDC.StretchBlt(rect.left+2, 0, rect.Width(), HEIGHT, &bitmapDC, 0, 0, 1, 12, SRCCOPY);
bitmapDC.SelectObject(pOldBitmapSpan);
bitmapSpan.DeleteObject();
int nItems = GetItemCount();
CBitmap bitmap;
CBitmap bitmap2;
CBitmap bitmap3;
这是 skinheaderctrl.h
#if !defined(AFX_SKINHEADERCTRL_H__8B0847B1_B4E6_4372_A62D_038582FFEA5C__INCLUDED_)
#define AFX_SKINHEADERCTRL_H__8B0847B1_B4E6_4372_A62D_038582FFEA5C__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// SkinHeaderCtrl.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CSkinHeaderCtrl window
class CSkinHeaderCtrl : public CHeaderCtrl
{
// Construction
public:
CSkinHeaderCtrl();
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSkinHeaderCtrl)
//}}AFX_VIRTUAL
// Implementation
public:
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
virtual ~CSkinHeaderCtrl();
// Generated message map functions
protected:
//{{AFX_MSG(CSkinHeaderCtrl)
afx_msg void OnPaint();
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SKINHEADERCTRL_H__8B0847B1_B4E6_4372_A62D_038582FFEA5C__INCLUDED_)
更新
在 skinheaderctrl.cpp 我有一个包含 #include "memdc.h" 我想将它更新到 CMemDC 吗?