类重复定义了vc98mfcincludeafxwin.h(3703) : error C2011: 'CScrollView' : 'class' type redefinitio
afxwin.h 应当含在 StdAfx.h 里,不要在别处另外定义。
CxxxView.cpp 里 #include "stdafx.h" 放在第一个。
CxxxView.cpp 里 用到 CScrollView 例如:
IMPLEMENT_DYNCREATE(CXxxView, CScrollView)
BEGIN_MESSAGE_MAP(CXxxView, CScrollView)
ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint)
...
END_MESSAGE_MAP()MFC实现和windows画图工具
我只会写简单的操作,给你做个参考吧
// DrawView.cpp : implementation of the CDrawView class
//
#include "stdafx.h"
#include "Draw.h"
#include "DrawDoc.h"
#include "DrawView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDrawView
IMPLEMENT_DYNCREATE(CDrawView, CView)
BEGIN_MESSAGE_MAP(CDrawView, CView)
//{{AFX_MSG_MAP(CDrawView)
ON_WM_CREATE()
ON_COMMAND(ID_DRAW_LINECOLOR, OnDrawLinecolor)
ON_COMMAND(ID_DRAW_FILLCOLOR, OnDrawFillcolor)
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDOWN()
ON_WM_SETCURSOR()
//}}AFX_MSG_MAP
ON_COMMAND_RANGE(ID_DRAW_LINE,ID_DRAW_FILL, OnSelectDrawType)
ON_UPDATE_COMMAND_UI_RANGE(ID_DRAW_LINE,ID_DRAW_FILL, OnUpdateSelectDrawType)
ON_COMMAND_RANGE(ID_DRAW_LINEWIDTH_ONE,ID_DRAW_LINEWIDTH_FIVE, OnDrawLineWidth)
ON_UPDATE_COMMAND_UI_RANGE(ID_DRAW_LINEWIDTH_ONE,ID_DRAW_LINEWIDTH_FIVE,OnUpdateDrawLineWidth)
// Standard mands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDrawView construction/destruction
CDrawView::CDrawView()
{
// TODO: add construction code here
m_pMemDC = new CDC;
m_pBitmap = new CBitmap;
m_nDrawType = -1;
m_nLineWidth = 1;
m_cLineColor = RGB(0,0,0);
m_cFillColor = RGB(0,0,255);
m_bDrawing = false;
}
CDrawView::~CDrawView()
{
delete m_pMemDC;
delete m_pBitmap;
}
BOOL CDrawView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CDrawView drawing
void CDrawView::OnDraw(CDC* pDC)
{
CDrawDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CBitmap * pOldBitmap = m_pMemDC->SelectObject(m_pBitmap);
pDC->BitBlt(0,0,m_nMaxX, m_nMaxY, m_pMemDC, 0,0, SRCCOPY);
m_pMemDC->SelectObject(pOldBitmap);
}
/////////////////////////////////////////////////////////////////////////////
// CDrawView printing
BOOL CDrawView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CDrawView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CDrawView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CDrawView diagnostics
#ifdef _DEBUG
void CDrawView::AssertValid() const
{
CView::AssertValid();
}
void CDrawView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CDrawDoc* CDrawView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDrawDoc)));
return (CDrawDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CDrawView message handlers
int CDrawView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
m_nMaxX = GetSystemMetrics(SM_CXSCREEN);
m_nMaxY = GetSystemMetrics(SM_CYSCREEN);
CDC * pDC = GetDC();
m_pMemDC->CreateCompatibleDC(pDC);
m_pBitmap->CreateCompatibleBitmap(pDC, m_nMaxX, m_nMaxY);
CBitmap * pOldBitmap = m_pMemDC->SelectObject(m_pBitmap);
CBrush brush;
brush.CreateStockObject(WHITE_BRUSH);
CRect rect(-1,-1,m_nMaxX, m_nMaxY);
m_pMemDC->FillRect(rect,&brush);
m_pMemDC->SelectObject(pOldBitmap);
ReleaseDC(pDC);
return 0;
}
void CDrawView::OnSelectDrawType(UINT nID)
{
m_nDrawType = nID - ID_DRAW_LINE;
}
void CDrawView::OnUpdateSelectDrawType(CCmdUI * pCmdUI)
{
int nID = pCmdUI->m_nID - ID_DRAW_LINE;
if(nID == m_nDrawType)
pCmdUI->SetCheck(true);
else
pCmdUI->SetCheck(false);
}
void CDrawView::OnDrawLineWidth(UINT nID)
{
m_nLineWidth = nID - ID_DRAW_LINEWIDTH_ONE + 1;
}
void CDrawView::OnUpdateDrawLineWidth(CCmdUI * pCmdUI)
{
int nID = pCmdUI->m_nID - ID_DRAW_LINEWIDTH_ONE + 1;
if(nID == m_nLineWidth)
pCmdUI->SetCheck(true);
else
pCmdUI->SetCheck(false);
}
void CDrawView::OnDrawLinecolor()
{
// TODO: Add mand handler code here
CColorDialog dlg;
.Flags |= CC_PREVENTFULLOPEN | CC_RGBINIT;
.rgbResult = m_cLineColor;
if(dlg.DoModal() == IDOK)
{
m_cLineColor = dlg.GetColor();
}
}
void CDrawView::OnDrawFillcolor()
{
// TODO: Add mand handler code here
CColorDialog dlg;
.Flags |= CC_PREVENTFULLOPEN | CC_RGBINIT;
.rgbResult = m_cFillColor;
if(dlg.DoModal() == IDOK)
{
m_cFillColor = dlg.GetColor();
}
}
void CDrawView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
SetCapture();
m_bDrawing = true;
m_ptStart = point;
m_ptOld = point;
if(m_nDrawType == 3)
{
CBrush * pOldBrush;
CBitmap * pOldBitmap;
CBrush brFill;
brFill.CreateSolidBrush(m_cFillColor);
pOldBrush = m_pMemDC->SelectObject(&brFill);
pOldBitmap = m_pMemDC->SelectObject(m_pBitmap);
m_pMemDC->ExtFloodFill(point.x,point.y, m_pMemDC->GetPixel(point), FLOODFILLSURFACE);
Invalidate(false);
m_pMemDC->SelectObject(pOldBrush);
m_pMemDC->SelectObject(pOldBitmap);
m_bDrawing = false;
}
CView::OnLButtonDown(nFlags, point);
}
void CDrawView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(m_bDrawing)
{
CDC * pDC = GetDC();
CBitmap * pOldBitmap = m_pMemDC->SelectObject(m_pBitmap);
CPen pen;
pen.CreatePen(PS_SOLID, m_nLineWidth, m_cLineColor);
CPen * pOldPen = pDC->SelectObject(&pen);
CBrush * pOldBrush = (CBrush *) pDC->SelectStockObject(NULL_BRUSH);
CRect rectOld(m_ptStart, m_ptOld);
rectOld.NormalizeRect();
rectOld.InflateRect(m_nLineWidth, m_nLineWidth);
pDC->BitBlt(rectOld.left, , rectOld.Width(), rectOld.Height(),m_pMemDC, rectOld.left, , SRCCOPY);
CRect rectNew(m_ptStart,point);
switch(m_nDrawType)
{
case 0:
pDC->MoveTo(m_ptStart);
pDC->LineTo(point);
break;
case 1:
pDC->Rectangle(rectNew);
break;
case 2:
pDC->Ellipse(rectNew);
break;
default:
break;
}
m_pMemDC->SelectObject(pOldBitmap);
pDC->SelectObject(pOldPen);
pDC->SelectObject(pOldBrush);
ReleaseDC(pDC);
m_ptOld = point;
}
CView::OnMouseMove(nFlags, point);
}
void CDrawView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(m_bDrawing)
{
m_bDrawing = false;
CBitmap * pOldBitmap = m_pMemDC->SelectObject(m_pBitmap);
CPen pen;
pen.CreatePen(PS_SOLID, m_nLineWidth, m_cLineColor);
CPen * pOldPen = m_pMemDC->SelectObject(&pen);
CBrush * pOldBrush = (CBrush *) m_pMemDC->SelectStockObject(NULL_BRUSH);
CRect rectNew(m_ptStart,point);
switch(m_nDrawType)
{
case 0:
m_pMemDC->MoveTo(m_ptStart);
m_pMemDC->LineTo(point);
break;
case 1:
m_pMemDC->Rectangle(rectNew);
break;
case 2:
m_pMemDC->Ellipse(rectNew);
break;
default:
break;
}
Invalidate(false);
m_pMemDC->SelectObject(pOldBitmap);
m_pMemDC->SelectObject(pOldPen);
m_pMemDC->SelectObject(pOldBrush);
}
ReleaseCapture();
CView::OnLButtonUp(nFlags, point);
}
BOOL CDrawView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
// TODO: Add your message handler code here and/or call default
switch(m_nDrawType)
{
case 0:
case 1:
case 2:
::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS));
break;
case 3:
::SetCursor(AfxGetApp()->LoadCursor(ID_CURSOR_FILL));
break;
default:
::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
break;
}
return CView::OnSetCursor(pWnd, nHitTest, message);
}
好久以前的了,要的话留下邮箱,我发给你~
我可以帮助你,你先设置我最佳答案后,我百度Hii教你。
IMPLEMENT_RUNTIMECLASS
这些参数都是宏参数,他们都是为了去定义一个类型为CRuntimeClass的叫class##class_name的静态结构体实例,而这个静态的结构体实例是在DELCARE_DYNACREATE中被声明的。
而该结构体类型是这样的:
struct CRuntimeClass
{
LPCSTR m_lpszClassName;
int m_ClassSize;
UINT mWSchema;
CObject *(PASCAL *m_lpfunCreateObject)();
CRuntimeClass *m_pBaseClass;
CObject *CreateObject();
static CRuntimeClass * PASCAL Load();
static CRuntimeClass *pFirstClass();
CRuntimeClass *m_pNextClass();
};
而在_IMPLEMENT_RUNTIMECLASS中class_name中其被用作char _lpsz##class_name[]=#class_name;
而_lpsz##class_name用于对CRuntimeClass中的m_lpszClassName进行赋值。
用途:一般用于动态创建中字符串的比对。
base_class_name其用作RUNTIME_ClASS(base_class_name)对CRuntimeClass中的m_pBaseClass进行赋值。
用途:一般用于获取父类的静态CRuntimeClass变量:class##base_class_name;
OxFFFF其用于对CRuntimeClass中的m_WSChema进行赋值。
用途:用于文档版本号。
在序列化中有用,在动态创建中可以不管它,就这么写就可以。
class_name::CreateObject是一个函数指针,该函数就是你自己都在问题中写了一遍,其对CRuntimeClass中的m_pfunCreateObject进行赋值。
用途:你自己也写了,用于在heap内存中创建new一个该类的对象,是最终目的。
MFC是如何创建窗口的?
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CFSDDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CFSDView));
AddDocTemplate(pDocTemplate);
// mand line for standard mands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// mands specified on mand line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
真正建立窗口的是ProcessShellCommand(cmdInfo)函数调用。
。
可以一步步跟踪。
使用c预言实现jpeg 图像格式的读取与写入
// 00Doc.cpp : implementation of the CMy00Doc class
//#include "stdafx.h"
#include "00.h"#include "00Doc.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/////////////////////////////////////////////////////////////////////////////
// CMy00DocIMPLEMENT_DYNCREATE(CMy00Doc, CDocument)BEGIN_MESSAGE_MAP(CMy00Doc, CDocument)
//{{AFX_MSG_MAP(CMy00Doc)<br> // NOTE - the ClassWizard will add and remove mapping macros here.<br> // DO NOT EDIT what you see in these blocks of generated code!<br> //}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CMy00Doc construction/destructionCMy00Doc::CMy00Doc()
{
// TODO: add one-time construction code here
m_pImage = new CImageX;}CMy00Doc::~CMy00Doc()
{
delete m_pImage;
}BOOL CMy00Doc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE; // TODO: add reinitialization code here
// (SDI documents will reuse this document) return TRUE;
} /////////////////////////////////////////////////////////////////////////////
// CMy00Doc serializationvoid CMy00Doc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}/////////////////////////////////////////////////////////////////////////////
// CMy00Doc diagnostics#ifdef _DEBUG
void CMy00Doc::AssertValid() const
{
CDocument::AssertValid();
}void CMy00Doc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG/////////////////////////////////////////////////////////////////////////////
// mands
BOOL CMy00Doc::OnOpenDocument(LPCTSTR lpszPathName)
{
if (!CDocument::OnOpenDocument(lpszPathName))
return FALSE;
// TODO: Add your specialized creation code here
m_strFileName = lpszPathName;//ZWS 20040317
return m_pImage->Load( CString(lpszPathName) );
// return TRUE;
}BOOL CMy00Doc::OnSaveDocument(LPCTSTR lpszPathName)
{
// TODO: Add your specialized code here and/or call the base class
return m_pImage->Save( CString(lpszPathName) );
// return CDocument::OnSaveDocument(lpszPathName);
}
感恩一年有你!免费领取2核4G套餐!2核4G轻量应用服务器2核 CPU 4GB内存 60G SSD云硬盘 6Mbps带宽领取地址:https://cloud.tencent.com/act/pro/lighthousethankyou活动规则活动时间2021年9月23日 ~ 2021年10月23日活动对象腾讯云官网已注册且完成实名认证的国内站用户(协作者与子用户账号除外),且符合以下活动条件:账号...
RAKsmart 商家我们肯定不算陌生,目前主要的营销客户群肯定是我们。于是在去年的时候有新增很多很多的机房,比如也有测试过的日本、香港、美国机房,这不今年有新增韩国机房(记得去年是不是也有增加过)。且如果没有记错的话,之前VPS主机也有一次磁盘故障的问题。
这不今天有看到商家新增韩国服务器产品,当然目前我还不清楚商家韩国服务器的线路和速度情况,后面我搞一台测试机进行...
华纳云(HNCloud Limited)是一家专业的全球数据中心基础服务提供商,总部在香港,隶属于香港联合通讯国际有限公司,拥有香港政府颁发的商业登记证明,保证用户的安全性和合规性。 华纳云是APNIC 和 ARIN 会员单位。主要提供香港和美国机房的VPS云服务器和独立服务器。商家支持支付宝、网银、Paypal付款。华纳云主要面向国内用户群,所以线路质量还是不错的,客户使用体验总体反响还是比较好...
implement_dyncreate为你推荐
youtube创始人李开复的创新工场是做什么的啊???漏洞查询如何查找漏洞 从那做起pps官网pps软件下载中心 pps影视软件下载手机软件开发工具手机app一般用什么 软件开发上行宽带上行宽带和下行宽带代表什么?腾讯合作伙伴大会从微信同程旅行买的机票怎么打印电子发票?防火墙技术应用防火墙的应用与研究论文erp系统教程如何使用ERP系统操作?东兴证券网站东兴证券超强版下载在线沟通网络沟通的问题有哪些
域名申请 宿迁服务器租用 花生壳域名贝锐 老左 vpsio 512m内存 windows2003iso 湖南服务器托管 好看qq空间 宁波服务器 php空间推荐 135邮箱 双十一秒杀 1g内存 国外免费asp空间 paypal注册教程 网站加速软件 中国电信网络测速 空间申请 闪讯网 更多