CPrintInfo中的m_rectDraw代表了什么?

maquanwei 2004-03-24 11:36:24
我在做自己的View的打印功能。

我的View是从CScrollVieW派生的,里面显示的内容是我自定义的对象。

我现在要完成打印这些自定义对象的功能,可是我对MFC的打印功能不熟。
结果出问题了,我想在OnPrint函数中根据CPrintInfo中的m_rectDraw输出我的自定义对象。可是,这个m_rectDraw的大小位置我比较困惑,第一页和第二页是完全相同的。这是为什么?

谢谢
...全文
180 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
koko1998 2004-03-24
  • 打赏
  • 举报
回复
就是你要打印的纸张的大小了。(说的太白了)
xuyun11141 2004-03-24
  • 打赏
  • 举报
回复
Specifies the usable drawing area of the page in logical coordinates. You may want to refer to this in your override of CView::OnPrint. You can use this member to keep track of what area remains usable after you print headers, footers, and so on. The m_rectDraw member is a public variable of type CRect.

QunKangLi 2004-03-24
  • 打赏
  • 举报
回复
纸张的可打印范围.对同样的纸张设置,这个值当然是相同的.
不过,可在程序中对它进行修改以达到某些特别的页面效果.
名牌大灰狼 2004-03-24
  • 打赏
  • 举报
回复
规定你在页面中逻辑坐标所用的打印范围.
// MyPaintView.cpp : implementation of the CMyPaintView class // #include "stdafx.h" #include "MyPaint.h" #include "Mainfrm.h" #include "MyPaintDoc.h" #include "MyPaintView.h" #include "MyImage.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMyPaintView IMPLEMENT_DYNCREATE(CMyPaintView, CView) BEGIN_MESSAGE_MAP(CMyPaintView, CView) //{{AFX_MSG_MAP(CMyPaintView) ON_UPDATE_COMMAND_UI(ID_BUTTON_IRREG_SEL, OnUpdateButtonIrregSel) ON_UPDATE_COMMAND_UI(ID_BUTTON_RECT_SEL, OnUpdateButtonRectSel) ON_UPDATE_COMMAND_UI(ID_BUTTON_ERASER, OnUpdateButtonEraser) ON_UPDATE_COMMAND_UI(ID_BUTTON_FILL, OnUpdateButtonFill) ON_UPDATE_COMMAND_UI(ID_BUTTON_MAGNIFY, OnUpdateButtonMagnify) ON_UPDATE_COMMAND_UI(ID_BUTTON_PEN, OnUpdateButtonPen) ON_UPDATE_COMMAND_UI(ID_BUTTON_BRUSH, OnUpdateButtonBrush) ON_UPDATE_COMMAND_UI(ID_BUTTON_AIRBRUSH, OnUpdateButtonAirbrush) ON_UPDATE_COMMAND_UI(ID_BUTTON_SELCOLOR, OnUpdateButtonSelcolor) ON_UPDATE_COMMAND_UI(ID_BUTTON_TEXT, OnUpdateButtonText) ON_COMMAND(ID_BUTTON_IRREG_SEL, OnButtonIrregSel) ON_COMMAND(ID_BUTTON_RECT_SEL, OnButtonRectSel) ON_COMMAND(ID_BUTTON_ERASER, OnButtonEraser) ON_COMMAND(ID_BUTTON_MAGNIFY, OnButtonMagnify) ON_COMMAND(ID_BUTTON_FILL, OnButtonFill) ON_COMMAND(ID_BUTTON_BRUSH, OnButtonBrush) ON_COMMAND(ID_BUTTON_PEN, OnButtonPen) ON_COMMAND(ID_BUTTON_SELCOLOR, OnButtonSelcolor) ON_COMMAND(ID_BUTTON_TEXT, OnButtonText) ON_COMMAND(ID_BUTTON_AIRBRUSH, OnButtonAirbrush) ON_WM_CREATE() ON_WM_LBUTTONDOWN() ON_WM_MOUSEMOVE() ON_WM_LBUTTONUP() ON_COMMAND(ID_BUTTON_CURVE, OnButtonCurve) ON_UPDATE_COMMAND_UI(ID_BUTTON_CURVE, OnUpdateButtonCurve) ON_COMMAND(ID_BUTTON_LINE, OnButtonLine) ON_UPDATE_COMMAND_UI(ID_BUTTON_LINE, OnUpdateButtonLine) ON_WM_SETCURSOR() ON_UPDATE_COMMAND_UI(ID_BUTTON_RECT, OnUpdateButtonRect) ON_COMMAND(ID_BUTTON_RECT, OnButtonRect) ON_UPDATE_COMMAND_UI(ID_BUTTON_POLYGON, OnUpdateButtonPolygon) ON_COMMAND(ID_BUTTON_POLYGON, OnButtonPolygon) ON_UPDATE_COMMAND_UI(ID_BUTTON_ROUND_RECT, OnUpdateButtonRoundRect) ON_COMMAND(ID_BUTTON_ROUND_RECT, OnButtonRoundRect) ON_UPDATE_COMMAND_UI(ID_BUTTON_ELLIPSE, OnUpdateButtonEllipse) ON_COMMAND(ID_BUTTON_ELLIPSE, OnButtonEllipse) ON_COMMAND(ID_EDIT_UNDO, OnEditUndo) ON_COMMAND(ID_EDIT_REDO, OnEditRedo) //}}AFX_MSG_MAP // Standard printing commands 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() ///////////////////////////////////////////////////////////////////////////// // CMyPaintView construction/destruction CMyPaintView::CMyPaintView() { // TODO: add construction code here m_emPaintType = IRREG_SEL; m_pdcMem = new CDC; m_pbmBackground = new CBitmap; m_bDrawing = FALSE; m_bFirstDraw = FALSE; m_nEraserSize = 10; m_pbyBitmapBuf = NULL; } CMyPaintView::~CMyPaintView() { delete m_pdcMem; delete m_pbmBackground; if ( m_pbyBitmapBuf ) delete[] m_pbyBitmapBuf; } BOOL CMyPaintView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CView::PreCreateWindow(cs); } ///////////////////////////////////////////////////////////////////////////// // CMyPaintView drawing void CMyPaintView::OnDraw(CDC* pDC) { CMyPaintDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here pDC->BitBlt(0,0,m_nScreenW,m_nScreenH, m_pdcMem, 0, 0, SRCCOPY); } ///////////////////////////////////////////////////////////////////////////// // CMyPaintView printing BOOL CMyPaintView::OnPreparePrinting(CPrintInfo* pInfo) { // default preparation return DoPreparePrinting(pInfo); } void CMyPaintView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add extra initialization before printing } void CMyPaintView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add cleanup after printing } ///////////////////////////////////////////////////////////////////////////// // CMyPaintView diagnostics #ifdef _DEBUG void CMyPaintView::AssertValid() const { CView::AssertValid(); } void CMyPaintView::Dump(CDumpContext& dc) const { CView::Dump(dc); } CMyPaintDoc* CMyPaintView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyPaintDoc))); return (CMyPaintDoc*)m_pDocument; } #endif //_DEBUG COLORREF CMyPaintView::GetCanvasColor() const { CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); if ( pFrame ) return pFrame->m_clrCanvas; else return RGB(255,255,255); } COLORREF CMyPaintView::GetPaintColor() const { CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); if ( pFrame ) return pFrame->m_clrPaint; else return RGB(0,0,0); } int CMyPaintView::GetPenWidth() const { CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); if ( pFrame ) return pFrame->GetPenWidth(); else return 1; } void CMyPaintView::SetSelBox(int type) { ((CMainFrame*)AfxGetMainWnd())->m_wndToolBar.SetSelType((SELTYPE)type); } ///////////////////////////////////////////////////////////////////////////// // CMyPaintView message handlers void CMyPaintView::OnUpdateButtonIrregSel(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==IRREG_SEL); } void CMyPaintView::OnUpdateButtonRectSel(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==RECT_SEL); } void CMyPaintView::OnUpdateButtonEraser(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==ERASER); } void CMyPaintView::OnUpdateButtonFill(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==FILL); } void CMyPaintView::OnUpdateButtonMagnify(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==MAGNIFY); } void CMyPaintView::OnUpdateButtonPen(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==PEN); } void CMyPaintView::OnUpdateButtonBrush(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==BRUSH); } void CMyPaintView::OnUpdateButtonAirbrush(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==AIRBRUSH); } void CMyPaintView::OnUpdateButtonSelcolor(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==SEL_COLOR); } void CMyPaintView::OnUpdateButtonText(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==TEXT); } void CMyPaintView::OnUpdateButtonCurve(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==CURVE); } void CMyPaintView::OnUpdateButtonLine(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==LINE); } void CMyPaintView::OnButtonIrregSel() { // TODO: Add your command handler code here m_emPaintType = IRREG_SEL; SetSelBox(SEL_NONE); } void CMyPaintView::OnButtonRectSel() { // TODO: Add your command handler code here m_emPaintType = RECT_SEL; SetSelBox(SEL_NONE); } void CMyPaintView::OnButtonEraser() { // TODO: Add your command handler code here m_emPaintType = ERASER; SetSelBox(SEL_NONE); } void CMyPaintView::OnButtonMagnify() { // TODO: Add your command handler code here m_emPaintType = MAGNIFY; SetSelBox(SEL_NONE); } void CMyPaintView::OnButtonFill() { // TODO: Add your command handler code here m_emPaintType = FILL; SetSelBox(SEL_NONE); } void CMyPaintView::OnButtonBrush() { // TODO: Add your command handler code here m_emPaintType = BRUSH; SetSelBox(SEL_NONE); } void CMyPaintView::OnButtonPen() { // TODO: Add your command handler code here m_emPaintType = PEN; SetSelBox(SEL_NONE); } void CMyPaintView::OnButtonSelcolor() { // TODO: Add your command handler code here m_emPaintType = SEL_COLOR; SetSelBox(SEL_NONE); } void CMyPaintView::OnButtonText() { // TODO: Add your command handler code here m_emPaintType = TEXT; SetSelBox(SEL_NONE); } void CMyPaintView::OnButtonAirbrush() { // TODO: Add your command handler code here m_emPaintType = AIRBRUSH; SetSelBox(SEL_NONE); } void CMyPaintView::OnButtonCurve() { // TODO: Add your command handler code here m_emPaintType = CURVE; SetSelBox(SEL_PENWIDTH); } void CMyPaintView::OnButtonLine() { // TODO: Add your command handler code here m_emPaintType = LINE; SetSelBox(SEL_PENWIDTH); } int CMyPaintView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CView::OnCreate(lpCreateStruct) == -1) return -1; // TODO: Add your specialized creation code here m_nScreenW = ::GetSystemMetrics(SM_CXSCREEN); m_nScreenH = ::GetSystemMetrics(SM_CYSCREEN); CDC *pDC = GetDC(); m_pdcMem->CreateCompatibleDC(pDC); m_pbmBackground->CreateCompatibleBitmap(pDC,m_nScreenW,m_nScreenH); m_bmBackup.CreateCompatibleBitmap(pDC,m_nScreenW,m_nScreenH); m_pdcMem->SelectObject(m_pbmBackground); CBrush brush; brush.CreateSolidBrush(GetCanvasColor()); CRect rect(0,0,m_nScreenW,m_nScreenH); m_pdcMem->FillRect(rect,&brush); ReleaseDC(pDC); BITMAP bm; m_pbmBackground->GetBitmap(&bm); m_dwSizeBitmap = bm.bmWidthBytes * bm.bmHeight; m_pbyBitmapBuf = new BYTE[m_dwSizeBitmap]; return 0; } void CMyPaintView::UpdateImage() { m_pdcMem->SelectObject(m_pbmBackground); Invalidate(); } void CMyPaintView::XorLine(CPoint pt1,CPoint pt2) { CDC *pDC = GetDC(); CPen pen; pen.CreateStockObject(WHITE_PEN); CPen* pOldPen = (CPen*)pDC->SelectObject(&pen); pDC->SetROP2(R2_XORPEN); pDC->MoveTo(pt1); pDC->LineTo(pt2); pDC->SelectObject(pOldPen); ReleaseDC(pDC); } void CMyPaintView::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default Backup(); CDC* pDC = GetDC(); switch(m_emPaintType) { case LINE: case RECT: m_ptStart = point; m_bFirstDraw = TRUE; break; case PEN: case BRUSH: m_ptStart = point; break; case ERASER: m_ptStart = point; EraserBox(pDC, point); EraserBox(m_pdcMem, point); break; case FILL: Fill(pDC,point); Fill(m_pdcMem,point); break; default: break; } m_bDrawing = TRUE; ReleaseDC(pDC); CView::OnLButtonDown(nFlags, point); } void CMyPaintView::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); CString strCoord; strCoord.Format(" %d, %d", point.x, point.y); pFrame->m_wndStatusBar.SetPaneText(1, strCoord, TRUE); if ( m_bDrawing ) { CDC* pDC = GetDC(); switch(m_emPaintType) { case LINE: if ( point != m_ptEnd ) { if ( !m_bFirstDraw ) XorLine(m_ptStart,m_ptEnd); else m_bFirstDraw = FALSE; XorLine(m_ptStart,point); m_ptEnd = point; } break; case PEN: SetPixel(pDC, point); SetPixel(m_pdcMem, point); m_ptStart = point; break; case BRUSH: SetPixel(pDC, point, GetPenWidth()); SetPixel(m_pdcMem, point, GetPenWidth()); m_ptStart = point; break; case ERASER: EraserBox(pDC, point); EraserBox(m_pdcMem, point); m_ptStart = point; break; case RECT: if ( !m_bFirstDraw ) Rectangle(pDC,m_ptStart,m_ptEnd); else m_bFirstDraw = FALSE; Rectangle(pDC,m_ptStart,point); m_ptEnd = point; break; default: break; } ReleaseDC(pDC); } CView::OnMouseMove(nFlags, point); } void CMyPaintView::OnLButtonUp(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CDC* pDC = GetDC(); switch(m_emPaintType) { case LINE: XorLine(m_ptStart,m_ptEnd); Line(m_ptStart,m_ptEnd); break; case PEN: break; case RECT: Rectangle(pDC,m_ptStart,m_ptEnd); Rectangle(m_pdcMem,m_ptStart,m_ptEnd,TRUE); break; default: break; } ReleaseDC(pDC); m_bDrawing = FALSE; Invalidate(); CView::OnLButtonUp(nFlags, point); } void CMyPaintView::Line(CPoint point1, CPoint point2) { CPen pen; pen.CreatePen(PS_SOLID, GetPenWidth(), GetPaintColor()); CPen* pOldPen = (CPen*)m_pdcMem->SelectObject(&pen); m_pdcMem->MoveTo(point1); m_pdcMem->LineTo(point2); m_pdcMem->SelectObject(pOldPen); } void CMyPaintView::SetPixel(CDC* pDC,CPoint point,int nPenWidth) { CPen pen; pen.CreatePen(PS_SOLID, nPenWidth, GetPaintColor()); CPen* pOldPen = (CPen*)pDC->SelectObject(&pen); pDC->MoveTo(m_ptStart); pDC->LineTo(point); pDC->SelectObject(pOldPen); } BOOL CMyPaintView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { // TODO: Add your message handler code here and/or call default HCURSOR hCursor = NULL; switch(m_emPaintType) { case LINE: hCursor = AfxGetApp()->LoadCursor(IDC_LINE); break; case PEN: hCursor = AfxGetApp()->LoadCursor(IDC_PEN); break; case BRUSH: hCursor = AfxGetApp()->LoadCursor(IDC_BRUSH); break; case ERASER: hCursor = AfxGetApp()->LoadCursor(IDC_ERASER); break; case FILL: hCursor = AfxGetApp()->LoadCursor(IDC_FILL); break; case RECT: hCursor = AfxGetApp()->LoadCursor(IDC_LINE); break; default: break; } if ( hCursor ) { ::SetCursor(hCursor); return TRUE; } else return CView::OnSetCursor(pWnd, nHitTest, message); } void CMyPaintView::Fill(CDC *pDC, CPoint point) { CBrush brush; brush.CreateSolidBrush(GetPaintColor()); CBrush* pOldBrush = (CBrush*)pDC->SelectObject(&brush); pDC->ExtFloodFill(point.x,point.y,pDC->GetPixel(point),FLOODFILLSURFACE); pDC->SelectObject(pOldBrush); } void CMyPaintView::EraserBox(CDC* pDC, CPoint point) {//|PS_INSIDEFRAME | PS_ENDCAP_ROUND CPen pen( PS_SOLID , 9, GetCanvasColor()); CPen* pOldPen = (CPen*)pDC->SelectObject(&pen); /* CBrush brush; brush.CreateSolidBrush(GetCanvasColor()); CBrush* pOldBrush = (CBrush*)pDC->SelectObject(&brush); */ // pDC->Rectangle(point.x-5,point.y-5,point.x+5,point.y+5); pDC->MoveTo(m_ptStart); pDC->LineTo(point); // pDC->SelectObject(pOldBrush); pDC->SelectObject(pOldPen); } void CMyPaintView::Rectangle(CDC *pDC, CPoint ptUpperLeft, CPoint ptLowerLeft, BOOL bXorROP) { CPen pen; if ( !bXorROP ) pen.CreateStockObject(WHITE_PEN); else pen.CreatePen(PS_SOLID, GetPenWidth(), GetPaintColor()); CPen* pOldPen = (CPen*)pDC->SelectObject(&pen); CBrush brush; if ( bXorROP ) brush.CreateSolidBrush(GetCanvasColor()); else { brush.CreateStockObject(NULL_BRUSH); pDC->SetROP2(R2_XORPEN); } CBrush* pOldBrush = (CBrush*)pDC->SelectObject(&brush); pDC->Rectangle(ptUpperLeft.x,ptUpperLeft.y,ptLowerLeft.x,ptLowerLeft.y); pDC->SelectObject(pOldBrush); pDC->SelectObject(pOldPen); } void CMyPaintView::OnUpdateButtonRect(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==RECT); } void CMyPaintView::OnButtonRect() { // TODO: Add your command handler code here m_emPaintType = RECT; SetSelBox(SEL_RECTTYPE); } void CMyPaintView::OnUpdateButtonPolygon(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==POLYGON); } void CMyPaintView::OnButtonPolygon() { // TODO: Add your command handler code here m_emPaintType = POLYGON; SetSelBox(SEL_RECTTYPE); } void CMyPaintView::OnUpdateButtonRoundRect(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==ROUND_RECT); } void CMyPaintView::OnButtonRoundRect() { // TODO: Add your command handler code here m_emPaintType = ROUND_RECT; SetSelBox(SEL_RECTTYPE); } void CMyPaintView::OnUpdateButtonEllipse(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->SetCheck(m_emPaintType==ELLIPSE); } void CMyPaintView::OnButtonEllipse() { // TODO: Add your command handler code here m_emPaintType = ELLIPSE; SetSelBox(SEL_RECTTYPE); } void CMyPaintView::OnEditUndo() { // TODO: Add your command handler code here Restore(); } void CMyPaintView::OnEditRedo() { // TODO: Add your command handler code here } void CMyPaintView::Backup() { ASSERT(m_pbyBitmapBuf); m_pbmBackground->GetBitmapBits(m_dwSizeBitmap,m_pbyBitmapBuf); m_bmBackup.DeleteObject(); m_bmBackup.CreateBitmap(m_nScreenW,m_nScreenH, 1, 32, m_pbyBitmapBuf); } void CMyPaintView::Restore() { m_bmBackup.GetBitmapBits(m_dwSizeBitmap,m_pbyBitmapBuf); m_pbmBackground->DeleteObject(); m_pbmBackground->CreateBitmap(m_nScreenW,m_nScreenH, 1, 32, m_pbyBitmapBuf); UpdateImage(); }
// MyView.cpp : implementation of the CMyView class // #include "stdafx.h" #include "My.h" #include "MyDoc.h" #include "MyView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMyView IMPLEMENT_DYNCREATE(CMyView, CView) BEGIN_MESSAGE_MAP(CMyView, CView) //{{AFX_MSG_MAP(CMyView) ON_WM_LBUTTONDOWN() ON_WM_RBUTTONDOWN() //}}AFX_MSG_MAP // Standard printing commands 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() ///////////////////////////////////////////////////////////////////////////// // CMyView construction/destruction CMyView::CMyView() { // TODO: add construction code here } CMyView::~CMyView() { } BOOL CMyView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CView::PreCreateWindow(cs); } ///////////////////////////////////////////////////////////////////////////// // CMyView drawing void CMyView::OnDraw(CDC* pDC) { CMyDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here for(int i=0; im_nBubbleCount; i++) pDC->Ellipse(pDoc->m_rectBubble[i]); } ///////////////////////////////////////////////////////////////////////////// // CMyView printing BOOL CMyView::OnPreparePrinting(CPrintInfo* pInfo) { // default preparation return DoPreparePrinting(pInfo); } void CMyView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add extra initialization before printing } void CMyView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add cleanup after printing } ///////////////////////////////////////////////////////////////////////////// // CMyView diagnostics #ifdef _DEBUG void CMyView::AssertValid() const { CView::AssertValid(); } void CMyView::Dump(CDumpContext& dc) const { CView::Dump(dc); } CMyDoc* CMyView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyDoc))); return (CMyDoc*)m_pDocument; } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CMyView message handlers void CMyView::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CMyDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if(pDoc->m_nBubbleCount < MAX_BUBBLE) { int r = rand()%50+10; CRect rect(point.x-r, point.y-r, point.x+r, point.y+r); pDoc->m_rectBubble[pDoc->m_nBubbleCount] = rect; pDoc->m_nBubbleCount++; InvalidateRect(rect, FALSE); } CView::OnLButtonDown(nFlags, point); } void CMyView::OnRButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CMyDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); CRect rect; rect=pDoc->m_rectBubble[pDoc->m_nBubbleCount] ; pDoc->m_nBubbleCount--; InvalidateRect(rect, TRUE); CView::OnRButtonDown(nFlags, point); }
用MFC VC++实现的时钟源代码 // MFCFrame1View.cpp : implementation of the CMFCFrame1View class // #include "stdafx.h" #include "MFCFrame1.h" #include "MFCFrame1Doc.h" #include "MFCFrame1View.h" #include "PointDialog.h" #include "math.h" GLUquadricObj *objCylinder = gluNewQuadric(); #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMFCFrame1View IMPLEMENT_DYNCREATE(CMFCFrame1View, CView) BEGIN_MESSAGE_MAP(CMFCFrame1View, CView) //{{AFX_MSG_MAP(CMFCFrame1View) ON_WM_CREATE() ON_WM_DESTROY() ON_WM_SIZE() ON_COMMAND(IDM_ZIXUAN, OnZixuan) ON_WM_TIMER() ON_COMMAND(IDM_ChangDirect, OnChangDirect) //}}AFX_MSG_MAP // Standard printing commands 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() ///////////////////////////////////////////////////////////////////////////// // CMFCFrame1View construction/destruction CMFCFrame1View::CMFCFrame1View() { // TODO: add construction code here this->m_GLPixelIndex = 0; this->m_hGLContext = NULL; Angle1=0.0; Angle2=30.0; Timer=0; x=0.0; z=0.0; juli=40.0; } CMFCFrame1View::~CMFCFrame1View() { } BOOL CMFCFrame1View::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs cs.style |= (WS_CLIPCHILDREN | WS_CLIPSIBLINGS); return CView::PreCreateWindow(cs); } ///////////////////////////////////////////////////////////////////////////// // CMFCFrame1View drawing ///////////////////////////////////////////////////////////////////////////// // CMFCFrame1View printing BOOL CMFCFrame1View::OnPreparePrinting(CPrintInfo* pInfo) { // default preparation return DoPreparePrinting(pInfo); } void CMFCFrame1View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add extra initialization before printing } void CMFCFrame1View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add cleanup after printing } ///////////////////////////////////////////////////////////////////////////// // CMFCFrame1View diagnostics #ifdef _DEBUG void CMFCFrame1View::AssertValid() const { CView::AssertValid(); } void CMFCFrame1View::Dump(CDumpContext& dc) const { CView::Dump(dc); } CMFCFrame1Doc* CMFCFrame1View::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMFCFrame1Doc))); return (CMFCFrame1Doc*)m_pDocument; } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CMFCFrame1View message handlers BOOL CMFCFrame1View::SetWindowPixelFormat(HDC hDC) { PIXELFORMATDESCRIPTOR pixelDesc= { sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL| PFD_DOUBLEBUFFER|PFD_SUPPORT_GDI, PFD_TYPE_RGBA, 24, 0,0,0,0,0,0, 0, 0, 0, 0,0,0,0, 32, 0, 0, PFD_MAIN_PLANE, 0, 0,0,0 }; this->m_GLPixelIndex = ChoosePixelFormat(hDC,&pixelDesc); if(this->m_GLPixelIndex==0) { this->m_GLPixelIndex = 1; if(DescribePixelFormat(hDC,this->m_GLPixelIndex,sizeof(PIXELFORMATDESCRIPTOR),&pixelDesc)==0) { return FALSE; } } if(SetPixelFormat(hDC,this->m_GLPixelIndex,&pixelDesc)==FALSE) { return FALSE; } return TRUE; } int CMFCFrame1View::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CView::OnCreate(lpCreateStruct) == -1) return -1; // TODO: Add your specialized creation code here HWND hWnd = this->GetSafeHwnd(); HDC hDC = ::GetDC(hWnd); if(this->SetWindowPixelFormat(hDC)==FALSE) { return 0; } if(this->CreateViewGLContext(hDC)==FALSE) { return 0; } return 0; } BOOL CMFCFrame1View::CreateViewGLContext(HDC hDC) { this->m_hGLContext = wglCreateContext(hDC); if(this->m_hGLContext==NULL) {//创建失败 return FALSE; } if(wglMakeCurrent(hDC,this->m_hGLContext)==FALSE) {//选为当前RC失败 return FALSE; } return TRUE; } void CMFCFrame1View::OnDestroy() { CView::OnDestroy(); // TODO: Add your message handler code here if(wglGetCurrentContext()!=NULL) { wglMakeCurrent(NULL,NULL); } if(this->m_hGLContext!=NULL) { wglDeleteContext(this->m_hGLContext); this->m_hGLContext = NULL; } } void CMFCFrame1View::OnSize(UINT nType, int cx, int cy) { CView::OnSize(nType, cx, cy); // TODO: Add your message handler code here GLsizei width,height; GLdouble aspect; width = cx; height = cy; if(cy==0) { aspect = (GLdouble)width; } else { aspect = (GLdouble)width/(GLdouble)height; } glViewport(0,0,width,height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(40.0,aspect,5.0,1000.0); } void CMFCFrame1View::OnDraw(CDC* pDC) { CMFCFrame1Doc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here CPaintDC dc(this); glClearColor(1.0,1.0,1.0,1.0); glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0.0,0.0,10.0,0.0,0.0,0.0,0.0,1.0,0.0); glRotatef(-90.0,1.0,0.0,0.0);/*返回原坐标*/ glTranslatef(-3.0,0.0,0.0); SwapBuffers(dc.m_ps.hdc); glDrawBuffer (GL_BACK); glFlush(); } void CMFCFrame1View::OnZixuan() { // TODO: Add your command handler code here Timer=1; SetTimer(1,100,NULL); } void CMFCFrame1View::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default CPaintDC dc(this); if (Timer==1) { Angle1=Angle1-1; Angle2=Angle2-1; glClearColor(1.0,1.0,1.0,1.0); glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_MODELVIEW);/**/ glLoadIdentity(); gluLookAt(0.0,20.0,0.000000001,0.0,0.0,0.0,0.0,1.0,0.0); glPushMatrix(); glColor3f(0.7,0.7,0.7); glTranslatef(0.0,0.0,1.1); glRotatef(-90.0,1.0,0.0,0.0); glutSolidCone(5.0,0.0,60.0,60.0); /*底盘*/ glPopMatrix(); glPushMatrix(); glColor3f(0.0,0.0,0.0); glTranslatef(3.9,0.99,1.0); /*刻度*/ glRotatef(90.0,0.0,1.0,0.0); gluCylinder(objCylinder, 0.05, 0.05, 0.8, 9999, 9); glPopMatrix(); glPushMatrix(); glColor3f(0.0,0.0,0.0); glTranslatef(-4.7,0.99,1.0); /*刻度*/ glRotatef(90.0,0.0,1.0,0.0); gluCylinder(objCylinder,0.05, 0.05, 0.8, 9999, 9); glPopMatrix(); glPushMatrix(); glColor3f(0.0,0.0,0.0); glTranslatef(0.0,0.99,-2.9); /*刻度*/ glRotatef(180.0,0.0,1.0,0.0); gluCylinder(objCylinder,0.05, 0.05, 0.8, 9999, 9); glPopMatrix(); glPushMatrix(); glColor3f(0.0,0.0,0.0); glTranslatef(0.0,0.99,5.8); /*刻度*/ glRotatef(180.0,0.0,1.0,0.0); gluCylinder(objCylinder,0.05, 0.05,0.8, 9999, 9); glPopMatrix(); glPushMatrix(); glColor3f(0.0,1.0,0.0); glRotatef(45.0,0.0,1.0,0.0); glTranslatef(-0.67,0.99,0.7); /*时针*/ glRotatef(Angle1/129600,0.0,1.0,0.0); gluCylinder(objCylinder, 0.07, 0.02, 2.5, 9999, 9); glPopMatrix(); glPushMatrix(); glColor3f(1.0,0.0,0.0); glTranslatef(0.0,0.99,1.0); /*分针*/ glRotatef(Angle2/360,0.0,1.0,0.0); gluCylinder(objCylinder, 0.05, 0.02, 3.5, 9999, 9); glPopMatrix(); glPushMatrix(); glColor3f(0.0,0.0,0.5); glTranslatef(0.0,0.99,1.0); /*秒针*/ glRotatef(Angle1,0.0,1.0,0.0); gluCylinder(objCylinder, 0.07, 0.02, 4.5, 9999, 9); glPopMatrix(); SwapBuffers(dc.m_ps.hdc); glDrawBuffer (GL_BACK); glFlush(); } else if(Timer==2) { glClearColor(1.0,1.0,1.0,1.0); glClear(GL_COLOR_BUFFER_BIT); if (juli>12.0) { glMatrixMode(GL_MODELVIEW);/*建立了从世界坐标系到观察坐标系的转换矩阵*/ glLoadIdentity(); gluLookAt(0.0,8.0,juli,0.0,0.0,0.0,0.0,1.0,0.0); juli=juli-0.1; glPushMatrix(); glColor3f(0.0,0.0,0.0); glRotatef(-90.0,1.0,0.0,0.0); glutWireCone(40.0,0.0,30.0,30.0); /*画高度为0的圆锥*/ glPopMatrix(); glPushMatrix(); glColor3f(1.0,0.0,1.0); glLineWidth(4.0); glTranslatef(4.0,1.0,0.0); glutWireOctahedron(); /*画八面体*/ glLineWidth(1.0); glPopMatrix(); glPushMatrix(); glColor3f(1.0,0.0,1.0); glTranslatef(0.0,1.1,0.0); glRotatef(Angle2,0.0,1.0,0.0); gluCylinder(objCylinder, 1.0, 1.0, 10.0, 9999, 9); /*画壶*/ glPopMatrix(); } else if(juli<=12.0) { Angle2=Angle2+0.01; if (Angle2==360.0) Angle2=0.0; glMatrixMode(GL_MODELVIEW);/*建立了从世界坐标系到观察坐标系的转换矩阵*/ glLoadIdentity(); x=12.0*sin(Angle2); z=12.0*cos(Angle2); gluLookAt(x,5.0,z,0.0,0.0,0.0,0.0,1.0,0.0); glPushMatrix(); glColor3f(0.0,0.0,0.0); glRotatef(-90.0,1.0,0.0,0.0); glutWireCone(40.0,0.0,30.0,30.0); /*画高度为0的圆锥*/ glPopMatrix(); glPushMatrix(); glColor3f(1.0,0.0,1.0); glLineWidth(4.0); glTranslatef(4.0,1.0,0.0); glutWireOctahedron(); /*画八面体*/ glLineWidth(1.0); glPopMatrix(); glPushMatrix(); glColor3f(1.0,0.0,1.0); glTranslatef(0.0,1.1,0.0); gluCylinder(objCylinder, 1.0, 1.0, 10.0, 9999, 9); /*画壶*/ glPopMatrix(); } SwapBuffers(dc.m_ps.hdc); glDrawBuffer (GL_BACK); glFlush(); } CView::OnTimer(nIDEvent); } void CMFCFrame1View::OnChangDirect() { // TODO: Add your command handler code here Timer=2; SetTimer(1,100 ,NULL); }
stdafx.h的代码// This is a part of the Microsoft Foundation Classes C++ library. // Copyright (C) 1992-1998 Microsoft Corporation // All rights reserved. // // This source code is only intended as a supplement to the // Microsoft Foundation Classes Reference and related // electronic documentation provided with the library. // See these sources for detailed information regarding the // Microsoft Foundation Classes product. #ifndef __AFXWIN_H__ #ifndef RC_INVOKED #define __AFXWIN_H__ ///////////////////////////////////////////////////////////////////////////// // Make sure 'afx.h' is included first #ifndef __AFX_H__ #include #endif // Note: WINDOWS.H already included from AFXV_W32.H #ifndef _INC_SHELLAPI #include #endif #ifndef __AFXRES_H__ #include // standard resource IDs #endif #ifndef __AFXCOLL_H__ #include // standard collections #endif #ifdef _AFX_MINREBUILD #pragma component(minrebuild, off) #endif #ifndef _AFX_FULLTYPEINFO #pragma component(mintypeinfo, on) #endif #ifndef _AFX_NOFORCE_LIBS #pragma comment(lib, "uuid.lib") #endif #ifdef _INC_WINDOWSX // The following names from WINDOWSX.H collide with names in this header #undef SubclassWindow #undef CopyRgn #endif #ifdef _AFX_PACKING #pragma pack(push, _AFX_PACKING) #endif ///////////////////////////////////////////////////////////////////////////// // Classes declared in this file class CSize; class CPoint; class CRect; //CObject //CException //CSimpleException class CResourceException;// Win resource failure exception class CUserException; // Message Box alert and stop operation class CGdiObject; // CDC drawing tool class CPen; // a pen / HPEN wrapper class CBrush; // a brush / HBRUSH wrapper class CFont; // a font / HFONT wrapper class CBitmap; // a bitmap / HBITMAP wrapper class CPalette; // a palette / HPALLETE wrapper class CRgn; // a region / HRGN wrapper class CDC; // a Display Context / HDC wrapper class CClientDC; // CDC for client of window class CWindowDC; // CDC for entire window class CPaintDC; // embeddable BeginPaint struct helper class CMenu; // a menu / HMENU wrapper class CCmdTarget; // a target for user commands class CWnd; // a window / HWND wrapper class CDialog; // a dialog // standard windows controls class CStatic; // Static control class CButton; // Button control class CListBox; // ListBox control class CCheckListBox;// special listbox with checks class CComboBox; // ComboBox control class CEdit; // Edit control class CScrollBar; // ScrollBar control // frame windows class CFrameWnd; // standard SDI frame class CMDIFrameWnd; // standard MDI frame class CMDIChildWnd; // standard MDI child class CMiniFrameWnd;// half-height caption frame wnd // views on a document class CView; // a view on a document class CScrollView; // a scrolling view class CWinThread; // thread base class class CWinApp; // application base class class CDocTemplate; // template for document creation class CSingleDocTemplate;// SDI support class CMultiDocTemplate; // MDI support class CDocument; // main document abstraction // Helper classes class CCmdUI; // Menu/button enabling class CDataExchange; // Data exchange and validation context class CCommandLineInfo; // CommandLine parsing helper class CDocManager; // CDocTemplate manager object ///////////////////////////////////////////////////////////////////////////// // Type modifier for message handlers #ifndef afx_msg #define afx_msg // intentional placeholder #endif #undef AFX_DATA #define AFX_DATA AFX_CORE_DATA ///////////////////////////////////////////////////////////////////////////// // CSize - An extent, similar to Windows SIZE structure. class CSize : public tagSIZE { public: // Constructors // construct an uninitialized size CSize(); // create from two integers CSize(int initCX, int initCY); // create from another size CSize(SIZE initSize); // create from a point CSize(POINT initPt); // create from a DWORD: cx = LOWORD(dw) cy = HIWORD(dw) CSize(DWORD dwSize); // Operations BOOL operator==(SIZE size) const; BOOL operator!=(SIZE size) const; void operator+=(SIZE size); void operator-=(SIZE size); // Operators returning CSize values CSize operator+(SIZE size) const; CSize operator-(SIZE size) const; CSize operator-() const; // Operators returning CPoint values CPoint operator+(POINT point) const; CPoint operator-(POINT point) const; // Operators returning CRect values CRect operator+(const RECT* lpRect) const; CRect operator-(const RECT* lpRect) const; }; ///////////////////////////////////////////////////////////////////////////// // CPoint - A 2-D point, similar to Windows POINT structure. class CPoint : public tagPOINT { public: // Constructors // create an uninitialized point CPoint(); // create from two integers CPoint(int initX, int initY); // create from another point CPoint(POINT initPt); // create from a size CPoint(SIZE initSize); // create from a dword: x = LOWORD(dw) y = HIWORD(dw) CPoint(DWORD dwPoint); // Operations // translate the point void Offset(int xOffset, int yOffset); void Offset(POINT point); void Offset(SIZE size); BOOL operator==(POINT point) const; BOOL operator!=(POINT point) const; void operator+=(SIZE size); void operator-=(SIZE size); void operator+=(POINT point); void operator-=(POINT point); // Operators returning CPoint values CPoint operator+(SIZE size) const; CPoint operator-(SIZE size) const; CPoint operator-() const; CPoint operator+(POINT point) const; // Operators returning CSize values CSize operator-(POINT point) const; // Operators returning CRect values CRect operator+(const RECT* lpRect) const; CRect operator-(const RECT* lpRect) const; }; ///////////////////////////////////////////////////////////////////////////// // CRect - A 2-D rectangle, similar to Windows RECT structure. typedef const RECT* LPCRECT; // pointer to read/only RECT class CRect : public tagRECT { public: // Constructors // uninitialized rectangle CRect(); // from left, top, right, and bottom CRect(int l, int t, int r, int b); // copy constructor CRect(const RECT& srcRect); // from a pointer to another rect CRect(LPCRECT lpSrcRect); // from a point and size CRect(POINT point, SIZE size); // from two points CRect(POINT topLeft, POINT bottomRight); // Attributes (in addition to RECT members) // retrieves the width int Width() const; // returns the height int Height() const; // returns the size CSize Size() const; // reference to the top-left point CPoint& TopLeft(); // reference to the bottom-right point CPoint& BottomRight(); // const reference to the top-left point const CPoint& TopLeft() const; // const reference to the bottom-right point const CPoint& BottomRight() const; // the geometric center point of the rectangle CPoint CenterPoint() const; // swap the left and right void SwapLeftRight(); static void SwapLeftRight(LPRECT lpRect); // convert between CRect and LPRECT/LPCRECT (no need for &) operator LPRECT(); operator LPCRECT() const; // returns TRUE if rectangle has no area BOOL IsRectEmpty() const; // returns TRUE if rectangle is at (0,0) and has no area BOOL IsRectNull() const; // returns TRUE if point is within rectangle BOOL PtInRect(POINT point) const; // Operations // set rectangle from left, top, right, and bottom void SetRect(int x1, int y1, int x2, int y2); void SetRect(POINT topLeft, POINT bottomRight); // empty the rectangle void SetRectEmpty(); // copy from another rectangle void CopyRect(LPCRECT lpSrcRect); // TRUE if exactly the same as another rectangle BOOL EqualRect(LPCRECT lpRect) const; // inflate rectangle's width and height without // moving its top or left void InflateRect(int x, int y); void InflateRect(SIZE size); void InflateRect(LPCRECT lpRect); void InflateRect(int l, int t, int r, int b); // deflate the rectangle's width and height without // moving its top or left void DeflateRect(int x, int y); void DeflateRect(SIZE size); void DeflateRect(LPCRECT lpRect); void DeflateRect(int l, int t, int r, int b); // translate the rectangle by moving its top and left void OffsetRect(int x, int y); void OffsetRect(SIZE size); void OffsetRect(POINT point); void NormalizeRect(); // set this rectangle to intersection of two others BOOL IntersectRect(LPCRECT lpRect1, LPCRECT lpRect2); // set this rectangle to bounding union of two others BOOL UnionRect(LPCRECT lpRect1, LPCRECT lpRect2); // set this rectangle to minimum of two others BOOL SubtractRect(LPCRECT lpRectSrc1, LPCRECT lpRectSrc2); // Additional Operations void operator=(const RECT& srcRect); BOOL operator==(const RECT& rect) const; BOOL operator!=(const RECT& rect) const; void operator+=(POINT point); void operator+=(SIZE size); void operator+=(LPCRECT lpRect); void operator-=(POINT point); void operator-=(SIZE size); void operator-=(LPCRECT lpRect); void operator&=(const RECT& rect); void operator|=(const RECT& rect); // Operators returning CRect values CRect operator+(POINT point) const; CRect operator-(POINT point) const; CRect operator+(LPCRECT lpRect) const; CRect operator+(SIZE size) const; CRect operator-(SIZE size) const; CRect operator-(LPCRECT lpRect) const; CRect operator&(const RECT& rect2) const; CRect operator|(const RECT& rect2) const; CRect MulDiv(int nMultiplier, int nDivisor) const; }; #ifdef _DEBUG // Diagnostic Output CDumpContext& AFXAPI operator<<(CDumpContext& dc, SIZE size); CDumpContext& AFXAPI operator<<(CDumpContext& dc, POINT point); CDumpContext& AFXAPI operator<<(CDumpContext& dc, const RECT& rect); #endif //_DEBUG // Serialization CArchive& AFXAPI operator<<(CArchive& ar, SIZE size); CArchive& AFXAPI operator<<(CArchive& ar, POINT point); CArchive& AFXAPI operator<>(CArchive& ar, SIZE& size); CArchive& AFXAPI operator>>(CArchive& ar, POINT& point); CArchive& AFXAPI operator>>(CArchive& ar, RECT& rect); ///////////////////////////////////////////////////////////////////////////// // Standard exceptions class CResourceException : public CSimpleException // resource failure { DECLARE_DYNAMIC(CResourceException) public: CResourceException(); // Implementation public: CResourceException(BOOL bAutoDelete); CResourceException(BOOL bAutoDelete, UINT nResourceID); virtual ~CResourceException(); }; class CUserException : public CSimpleException // general user visible alert { DECLARE_DYNAMIC(CUserException) public: CUserException(); // Implementation public: CUserException(BOOL bAutoDelete); CUserException(BOOL bAutoDelete, UINT nResourceID); virtual ~CUserException(); }; void AFXAPI AfxThrowResourceException(); void AFXAPI AfxThrowUserException(); ///////////////////////////////////////////////////////////////////////////// // CGdiObject abstract class for CDC SelectObject class CGdiObject : public CObject { DECLARE_DYNCREATE(CGdiObject) public: // Attributes HGDIOBJ m_hObject; // must be first data member operator HGDIOBJ() const; HGDIOBJ GetSafeHandle() const; static CGdiObject* PASCAL FromHandle(HGDIOBJ hObject); static void PASCAL DeleteTempMap(); BOOL Attach(HGDIOBJ hObject); HGDIOBJ Detach(); // Constructors CGdiObject(); // must Create a derived class object BOOL DeleteObject(); // Operations int GetObject(int nCount, LPVOID lpObject) const; UINT GetObjectType() const; BOOL CreateStockObject(int nIndex); BOOL UnrealizeObject(); BOOL operator==(const CGdiObject& obj) const; BOOL operator!=(const CGdiObject& obj) const; // Implementation public: virtual ~CGdiObject(); #ifdef _DEBUG virtual void Dump(CDumpContext& dc) const; virtual void AssertValid() const; #endif }; ///////////////////////////////////////////////////////////////////////////// // CGdiObject subclasses (drawing tools) class CPen : public CGdiObject { DECLARE_DYNAMIC(CPen) public: static CPen* PASCAL FromHandle(HPEN hPen); // Constructors CPen(); CPen(int nPenStyle, int nWidth, COLORREF crColor); CPen(int nPenStyle, int nWidth, const LOGBRUSH* pLogBrush, int nStyleCount = 0, const DWORD* lpStyle = NULL); BOOL CreatePen(int nPenStyle, int nWidth, COLORREF crColor); BOOL CreatePen(int nPenStyle, int nWidth, const LOGBRUSH* pLogBrush, int nStyleCount = 0, const DWORD* lpStyle = NULL); BOOL CreatePenIndirect(LPLOGPEN lpLogPen); // Attributes operator HPEN() const; int GetLogPen(LOGPEN* pLogPen); int GetExtLogPen(EXTLOGPEN* pLogPen); // Implementation public: virtual ~CPen(); #ifdef _DEBUG virtual void Dump(CDumpContext& dc) const; #endif }; class CBrush : public CGdiObject { DECLARE_DYNAMIC(CBrush) public: static CBrush* PASCAL FromHandle(HBRUSH hBrush); // Constructors CBrush(); CBrush(COLORREF crColor); // CreateSolidBrush CBrush(int nIndex, COLORREF crColor); // CreateHatchBrush CBrush(CBitmap* pBitmap); // CreatePatternBrush BOOL CreateSolidBrush(COLORREF crColor); BOOL CreateHatchBrush(int nIndex, COLORREF crColor); BOOL CreateBrushIndirect(const LOGBRUSH* lpLogBrush); BOOL CreatePatternBrush(CBitmap* pBitmap); BOOL CreateDIBPatternBrush(HGLOBAL hPackedDIB, UINT nUsage); BOOL CreateDIBPatternBrush(const void* lpPackedDIB, UINT nUsage); BOOL CreateSysColorBrush(int nIndex); // Attributes operator HBRUSH() const; int GetLogBrush(LOGBRUSH* pLogBrush); // Implementation public: virtual ~CBrush(); #ifdef _DEBUG virtual void Dump(CDumpContext& dc) const; #endif }; class CFont : public CGdiObject { DECLARE_DYNAMIC(CFont) public: static CFont* PASCAL FromHandle(HFONT hFont); // Constructors CFont(); BOOL CreateFontIndirect(const LOGFONT* lpLogFont); BOOL CreateFont(int nHeight, int nWidth, int nEscapement, int nOrientation, int nWeight, BYTE bItalic, BYTE bUnderline, BYTE cStrikeOut, BYTE nCharSet, BYTE nOutPrecision, BYTE nClipPrecision, BYTE nQuality, BYTE nPitchAndFamily, LPCTSTR lpszFacename); BOOL CreatePointFont(int nPointSize, LPCTSTR lpszFaceName, CDC* pDC = NULL); BOOL CreatePointFontIndirect(const LOGFONT* lpLogFont, CDC* pDC = NULL); // Attributes operator HFONT() const; int GetLogFont(LOGFONT* pLogFont); // Implementation public: virtual ~CFont(); #ifdef _DEBUG virtual void Dump(CDumpContext& dc) const; #endif }; class CBitmap : public CGdiObject { DECLARE_DYNAMIC(CBitmap) public: static CBitmap* PASCAL FromHandle(HBITMAP hBitmap); // Constructors CBitmap(); BOOL LoadBitmap(LPCTSTR lpszResourceName); BOOL LoadBitmap(UINT nIDResource); BOOL LoadOEMBitmap(UINT nIDBitmap); // for OBM_/OCR_/OIC_ BOOL LoadMappedBitmap(UINT nIDBitmap, UINT nFlags = 0, LPCOLORMAP lpColorMap = NULL, int nMapSize = 0); BOOL CreateBitmap(int nWidth, int nHeight, UINT nPlanes, UINT nBitcount, const void* lpBits); BOOL CreateBitmapIndirect(LPBITMAP lpBitmap); BOOL CreateCompatibleBitmap(CDC* pDC, int nWidth, int nHeight); BOOL CreateDiscardableBitmap(CDC* pDC, int nWidth, int nHeight); // Attributes operator HBITMAP() const; int GetBitmap(BITMAP* pBitMap); // Operations DWORD SetBitmapBits(DWORD dwCount, const void* lpBits); DWORD GetBitmapBits(DWORD dwCount, LPVOID lpBits) const; CSize SetBitmapDimension(int nWidth, int nHeight); CSize GetBitmapDimension() const; // Implementation public: virtual ~CBitmap(); #ifdef _DEBUG virtual void Dump(CDumpContext& dc) const; #endif }; class CPalette : public CGdiObject { DECLARE_DYNAMIC(CPalette) public: static CPalette* PASCAL FromHandle(HPALETTE hPalette); // Constructors CPalette(); BOOL CreatePalette(LPLOGPALETTE lpLogPalette); BOOL CreateHalftonePalette(CDC* pDC); // Attributes operator HPALETTE() const; int GetEntryCount(); UINT GetPaletteEntries(UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY lpPaletteColors) const; UINT SetPaletteEntries(UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY lpPaletteColors); // Operations void AnimatePalette(UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY lpPaletteColors); UINT GetNearestPaletteIndex(COLORREF crColor) const; BOOL ResizePalette(UINT nNumEntries); // Implementation virtual ~CPalette(); }; class CRgn : public CGdiObject { DECLARE_DYNAMIC(CRgn) public: static CRgn* PASCAL FromHandle(HRGN hRgn); operator HRGN() const; // Constructors CRgn(); BOOL CreateRectRgn(int x1, int y1, int x2, int y2); BOOL CreateRectRgnIndirect(LPCRECT lpRect); BOOL CreateEllipticRgn(int x1, int y1, int x2, int y2); BOOL CreateEllipticRgnIndirect(LPCRECT lpRect); BOOL CreatePolygonRgn(LPPOINT lpPoints, int nCount, int nMode); BOOL CreatePolyPolygonRgn(LPPOINT lpPoints, LPINT lpPolyCounts, int nCount, int nPolyFillMode); BOOL CreateRoundRectRgn(int x1, int y1, int x2, int y2, int x3, int y3); BOOL CreateFromPath(CDC* pDC); BOOL CreateFromData(const XFORM* lpXForm, int nCount, const RGNDATA* pRgnData); // Operations void SetRectRgn(int x1, int y1, int x2, int y2); void SetRectRgn(LPCRECT lpRect); int CombineRgn(CRgn* pRgn1, CRgn* pRgn2, int nCombineMode); int CopyRgn(CRgn* pRgnSrc); BOOL EqualRgn(CRgn* pRgn) const; int OffsetRgn(int x, int y); int OffsetRgn(POINT point); int GetRgnBox(LPRECT lpRect) const; BOOL PtInRegion(int x, int y) const; BOOL PtInRegion(POINT point) const; BOOL RectInRegion(LPCRECT lpRect) const; int GetRegionData(LPRGNDATA lpRgnData, int nCount) const; // Implementation virtual ~CRgn(); }; ///////////////////////////////////////////////////////////////////////////// // The device context class CDC : public CObject { DECLARE_DYNCREATE(CDC) public: // Attributes HDC m_hDC; // The output DC (must be first data member) HDC m_hAttribDC; // The Attribute DC operator HDC() const; HDC GetSafeHdc() const; // Always returns the Output DC CWnd* GetWindow() const; static CDC* PASCAL FromHandle(HDC hDC); static void PASCAL DeleteTempMap(); BOOL Attach(HDC hDC); // Attach/Detach affects only the Output DC HDC Detach(); virtual void SetAttribDC(HDC hDC); // Set the Attribute DC virtual void SetOutputDC(HDC hDC); // Set the Output DC virtual void ReleaseAttribDC(); // Release the Attribute DC virtual void ReleaseOutputDC(); // Release the Output DC BOOL IsPrinting() const; // TRUE if being used for printing CPen* GetCurrentPen() const; CBrush* GetCurrentBrush() const; CPalette* GetCurrentPalette() const; CFont* GetCurrentFont() const; CBitmap* GetCurrentBitmap() const; // for bidi and mirrored localization DWORD GetLayout() const; DWORD SetLayout(DWORD dwLayout); // Constructors CDC(); BOOL CreateDC(LPCTSTR lpszDriverName, LPCTSTR lpszDeviceName, LPCTSTR lpszOutput, const void* lpInitData); BOOL CreateIC(LPCTSTR lpszDriverName, LPCTSTR lpszDeviceName, LPCTSTR lpszOutput, const void* lpInitData); BOOL CreateCompatibleDC(CDC* pDC); BOOL DeleteDC(); // Device-Context Functions virtual int SaveDC(); virtual BOOL RestoreDC(int nSavedDC); int GetDeviceCaps(int nIndex) const; UINT SetBoundsRect(LPCRECT lpRectBounds, UINT flags); UINT GetBoundsRect(LPRECT lpRectBounds, UINT flags); BOOL ResetDC(const DEVMODE* lpDevMode); // Drawing-Tool Functions CPoint GetBrushOrg() const; CPoint SetBrushOrg(int x, int y); CPoint SetBrushOrg(POINT point); int EnumObjects(int nObjectType, int (CALLBACK* lpfn)(LPVOID, LPARAM), LPARAM lpData); // Type-safe selection helpers public: virtual CGdiObject* SelectStockObject(int nIndex); CPen* SelectObject(CPen* pPen); CBrush* SelectObject(CBrush* pBrush); virtual CFont* SelectObject(CFont* pFont); CBitmap* SelectObject(CBitmap* pBitmap); int SelectObject(CRgn* pRgn); // special return for regions CGdiObject* SelectObject(CGdiObject* pObject); // CGdiObject* provided so compiler doesn't use SelectObject(HGDIOBJ) // Color and Color Palette Functions COLORREF GetNearestColor(COLORREF crColor) const; CPalette* SelectPalette(CPalette* pPalette, BOOL bForceBackground); UINT RealizePalette(); void UpdateColors(); // Drawing-Attribute Functions COLORREF GetBkColor() const; int GetBkMode() const; int GetPolyFillMode() const; int GetROP2() const; int GetStretchBltMode() const; COLORREF GetTextColor() const; virtual COLORREF SetBkColor(COLORREF crColor); int SetBkMode(int nBkMode); int SetPolyFillMode(int nPolyFillMode); int SetROP2(int nDrawMode); int SetStretchBltMode(int nStretchMode); virtual COLORREF SetTextColor(COLORREF crColor); BOOL GetColorAdjustment(LPCOLORADJUSTMENT lpColorAdjust) const; BOOL SetColorAdjustment(const COLORADJUSTMENT* lpColorAdjust); // Mapping Functions int GetMapMode() const; CPoint GetViewportOrg() const; virtual int SetMapMode(int nMapMode); // Viewport Origin virtual CPoint SetViewportOrg(int x, int y); CPoint SetViewportOrg(POINT point); virtual CPoint OffsetViewportOrg(int nWidth, int nHeight); // Viewport Extent CSize GetViewportExt() const; virtual CSize SetViewportExt(int cx, int cy); CSize SetViewportExt(SIZE size); virtual CSize ScaleViewportExt(int xNum, int xDenom, int yNum, int yDenom); // Window Origin CPoint GetWindowOrg() const; CPoint SetWindowOrg(int x, int y); CPoint SetWindowOrg(POINT point); CPoint OffsetWindowOrg(int nWidth, int nHeight); // Window extent CSize GetWindowExt() const; virtual CSize SetWindowExt(int cx, int cy); CSize SetWindowExt(SIZE size); virtual CSize ScaleWindowExt(int xNum, int xDenom, int yNum, int yDenom); // Coordinate Functions void DPtoLP(LPPOINT lpPoints, int nCount = 1) const; void DPtoLP(LPRECT lpRect) const; void DPtoLP(LPSIZE lpSize) const; void LPtoDP(LPPOINT lpPoints, int nCount = 1) const; void LPtoDP(LPRECT lpRect) const; void LPtoDP(LPSIZE lpSize) const; // Special Coordinate Functions (useful for dealing with metafiles and OLE) void DPtoHIMETRIC(LPSIZE lpSize) const; void LPtoHIMETRIC(LPSIZE lpSize) const; void HIMETRICtoDP(LPSIZE lpSize) const; void HIMETRICtoLP(LPSIZE lpSize) const; // Region Functions BOOL FillRgn(CRgn* pRgn, CBrush* pBrush); BOOL FrameRgn(CRgn* pRgn, CBrush* pBrush, int nWidth, int nHeight); BOOL InvertRgn(CRgn* pRgn); BOOL PaintRgn(CRgn* pRgn); // Clipping Functions virtual int GetClipBox(LPRECT lpRect) const; virtual BOOL PtVisible(int x, int y) const; BOOL PtVisible(POINT point) const; virtual BOOL RectVisible(LPCRECT lpRect) const; int SelectClipRgn(CRgn* pRgn); int ExcludeClipRect(int x1, int y1, int x2, int y2); int ExcludeClipRect(LPCRECT lpRect); int ExcludeUpdateRgn(CWnd* pWnd); int IntersectClipRect(int x1, int y1, int x2, int y2); int IntersectClipRect(LPCRECT lpRect); int OffsetClipRgn(int x, int y); int OffsetClipRgn(SIZE size); int SelectClipRgn(CRgn* pRgn, int nMode); // Line-Output Functions CPoint GetCurrentPosition() const; CPoint MoveTo(int x, int y); CPoint MoveTo(POINT point); BOOL LineTo(int x, int y); BOOL LineTo(POINT point); BOOL Arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4); BOOL Arc(LPCRECT lpRect, POINT ptStart, POINT ptEnd); BOOL Polyline(LPPOINT lpPoints, int nCount); BOOL AngleArc(int x, int y, int nRadius, float fStartAngle, float fSweepAngle); BOOL ArcTo(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4); BOOL ArcTo(LPCRECT lpRect, POINT ptStart, POINT ptEnd); int GetArcDirection() const; int SetArcDirection(int nArcDirection); BOOL PolyDraw(const POINT* lpPoints, const BYTE* lpTypes, int nCount); BOOL PolylineTo(const POINT* lpPoints, int nCount); BOOL PolyPolyline(const POINT* lpPoints, const DWORD* lpPolyPoints, int nCount); BOOL PolyBezier(const POINT* lpPoints, int nCount); BOOL PolyBezierTo(const POINT* lpPoints, int nCount); // Simple Drawing Functions void FillRect(LPCRECT lpRect, CBrush* pBrush); void FrameRect(LPCRECT lpRect, CBrush* pBrush); void InvertRect(LPCRECT lpRect); BOOL DrawIcon(int x, int y, HICON hIcon); BOOL DrawIcon(POINT point, HICON hIcon); #if (WINVER >= 0x400) BOOL DrawState(CPoint pt, CSize size, HBITMAP hBitmap, UINT nFlags, HBRUSH hBrush = NULL); BOOL DrawState(CPoint pt, CSize size, CBitmap* pBitmap, UINT nFlags, CBrush* pBrush = NULL); BOOL DrawState(CPoint pt, CSize size, HICON hIcon, UINT nFlags, HBRUSH hBrush = NULL); BOOL DrawState(CPoint pt, CSize size, HICON hIcon, UINT nFlags, CBrush* pBrush = NULL); BOOL DrawState(CPoint pt, CSize size, LPCTSTR lpszText, UINT nFlags, BOOL bPrefixText = TRUE, int nTextLen = 0, HBRUSH hBrush = NULL); BOOL DrawState(CPoint pt, CSize size, LPCTSTR lpszText, UINT nFlags, BOOL bPrefixText = TRUE, int nTextLen = 0, CBrush* pBrush = NULL); BOOL DrawState(CPoint pt, CSize size, DRAWSTATEPROC lpDrawProc, LPARAM lData, UINT nFlags, HBRUSH hBrush = NULL); BOOL DrawState(CPoint pt, CSize size, DRAWSTATEPROC lpDrawProc, LPARAM lData, UINT nFlags, CBrush* pBrush = NULL); #endif // Ellipse and Polygon Functions BOOL Chord(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4); BOOL Chord(LPCRECT lpRect, POINT ptStart, POINT ptEnd); void DrawFocusRect(LPCRECT lpRect); BOOL Ellipse(int x1, int y1, int x2, int y2); BOOL Ellipse(LPCRECT lpRect); BOOL Pie(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4); BOOL Pie(LPCRECT lpRect, POINT ptStart, POINT ptEnd); BOOL Polygon(LPPOINT lpPoints, int nCount); BOOL PolyPolygon(LPPOINT lpPoints, LPINT lpPolyCounts, int nCount); BOOL Rectangle(int x1, int y1, int x2, int y2); BOOL Rectangle(LPCRECT lpRect); BOOL RoundRect(int x1, int y1, int x2, int y2, int x3, int y3); BOOL RoundRect(LPCRECT lpRect, POINT point); // Bitmap Functions BOOL PatBlt(int x, int y, int nWidth, int nHeight, DWORD dwRop); BOOL BitBlt(int x, int y, int nWidth, int nHeight, CDC* pSrcDC, int xSrc, int ySrc, DWORD dwRop); BOOL StretchBlt(int x, int y, int nWidth, int nHeight, CDC* pSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, DWORD dwRop); COLORREF GetPixel(int x, int y) const; COLORREF GetPixel(POINT point) const; COLORREF SetPixel(int x, int y, COLORREF crColor); COLORREF SetPixel(POINT point, COLORREF crColor); BOOL FloodFill(int x, int y, COLORREF crColor); BOOL ExtFloodFill(int x, int y, COLORREF crColor, UINT nFillType); BOOL MaskBlt(int x, int y, int nWidth, int nHeight, CDC* pSrcDC, int xSrc, int ySrc, CBitmap& maskBitmap, int xMask, int yMask, DWORD dwRop); BOOL PlgBlt(LPPOINT lpPoint, CDC* pSrcDC, int xSrc, int ySrc, int nWidth, int nHeight, CBitmap& maskBitmap, int xMask, int yMask); BOOL SetPixelV(int x, int y, COLORREF crColor); BOOL SetPixelV(POINT point, COLORREF crColor); // Text Functions virtual BOOL TextOut(int x, int y, LPCTSTR lpszString, int nCount); BOOL TextOut(int x, int y, const CString& str); virtual BOOL ExtTextOut(int x, int y, UINT nOptions, LPCRECT lpRect, LPCTSTR lpszString, UINT nCount, LPINT lpDxWidths); BOOL ExtTextOut(int x, int y, UINT nOptions, LPCRECT lpRect, const CString& str, LPINT lpDxWidths); virtual CSize TabbedTextOut(int x, int y, LPCTSTR lpszString, int nCount, int nTabPositions, LPINT lpnTabStopPositions, int nTabOrigin); CSize TabbedTextOut(int x, int y, const CString& str, int nTabPositions, LPINT lpnTabStopPositions, int nTabOrigin); virtual int DrawText(LPCTSTR lpszString, int nCount, LPRECT lpRect, UINT nFormat); int DrawText(const CString& str, LPRECT lpRect, UINT nFormat); CSize GetTextExtent(LPCTSTR lpszString, int nCount) const; CSize GetTextExtent(const CString& str) const; CSize GetOutputTextExtent(LPCTSTR lpszString, int nCount) const; CSize GetOutputTextExtent(const CString& str) const; CSize GetTabbedTextExtent(LPCTSTR lpszString, int nCount, int nTabPositions, LPINT lpnTabStopPositions) const; CSize GetTabbedTextExtent(const CString& str, int nTabPositions, LPINT lpnTabStopPositions) const; CSize GetOutputTabbedTextExtent(LPCTSTR lpszString, int nCount, int nTabPositions, LPINT lpnTabStopPositions) const; CSize GetOutputTabbedTextExtent(const CString& str, int nTabPositions, LPINT lpnTabStopPositions) const; virtual BOOL GrayString(CBrush* pBrush, BOOL (CALLBACK* lpfnOutput)(HDC, LPARAM, int), LPARAM lpData, int nCount, int x, int y, int nWidth, int nHeight); UINT GetTextAlign() const; UINT SetTextAlign(UINT nFlags); int GetTextFace(int nCount, LPTSTR lpszFacename) const; int GetTextFace(CString& rString) const; BOOL GetTextMetrics(LPTEXTMETRIC lpMetrics) const; BOOL GetOutputTextMetrics(LPTEXTMETRIC lpMetrics) const; int SetTextJustification(int nBreakExtra, int nBreakCount); int GetTextCharacterExtra() const; int SetTextCharacterExtra(int nCharExtra); // Advanced Drawing #if (WINVER >= 0x400) BOOL DrawEdge(LPRECT lpRect, UINT nEdge, UINT nFlags); BOOL DrawFrameControl(LPRECT lpRect, UINT nType, UINT nState); #endif // Scrolling Functions BOOL ScrollDC(int dx, int dy, LPCRECT lpRectScroll, LPCRECT lpRectClip, CRgn* pRgnUpdate, LPRECT lpRectUpdate); // Font Functions BOOL GetCharWidth(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer) const; BOOL GetOutputCharWidth(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer) const; DWORD SetMapperFlags(DWORD dwFlag); CSize GetAspectRatioFilter() const; BOOL GetCharABCWidths(UINT nFirstChar, UINT nLastChar, LPABC lpabc) const; DWORD GetFontData(DWORD dwTable, DWORD dwOffset, LPVOID lpData, DWORD cbData) const; int GetKerningPairs(int nPairs, LPKERNINGPAIR lpkrnpair) const; UINT GetOutlineTextMetrics(UINT cbData, LPOUTLINETEXTMETRIC lpotm) const; DWORD GetGlyphOutline(UINT nChar, UINT nFormat, LPGLYPHMETRICS lpgm, DWORD cbBuffer, LPVOID lpBuffer, const MAT2* lpmat2) const; BOOL GetCharABCWidths(UINT nFirstChar, UINT nLastChar, LPABCFLOAT lpABCF) const; BOOL GetCharWidth(UINT nFirstChar, UINT nLastChar, float* lpFloatBuffer) const; // Printer/Device Escape Functions virtual int Escape(int nEscape, int nCount, LPCSTR lpszInData, LPVOID lpOutData); int Escape(int nEscape, int nInputSize, LPCSTR lpszInputData, int nOutputSize, LPSTR lpszOutputData); int DrawEscape(int nEscape, int nInputSize, LPCSTR lpszInputData); // Escape helpers int StartDoc(LPCTSTR lpszDocName); // old Win3.0 version int StartDoc(LPDOCINFO lpDocInfo); int StartPage(); int EndPage(); int SetAbortProc(BOOL (CALLBACK* lpfn)(HDC, int)); int AbortDoc(); int EndDoc(); // MetaFile Functions BOOL PlayMetaFile(HMETAFILE hMF); BOOL PlayMetaFile(HENHMETAFILE hEnhMetaFile, LPCRECT lpBounds); BOOL AddMetaFileComment(UINT nDataSize, const BYTE* pCommentData); // can be used for enhanced metafiles only // Path Functions BOOL AbortPath(); BOOL BeginPath(); BOOL CloseFigure(); BOOL EndPath(); BOOL FillPath(); BOOL FlattenPath(); BOOL StrokeAndFillPath(); BOOL StrokePath(); BOOL WidenPath(); float GetMiterLimit() const; BOOL SetMiterLimit(float fMiterLimit); int GetPath(LPPOINT lpPoints, LPBYTE lpTypes, int nCount) const; BOOL SelectClipPath(int nMode); // Misc Helper Functions static CBrush* PASCAL GetHalftoneBrush(); void DrawDragRect(LPCRECT lpRect, SIZE size, LPCRECT lpRectLast, SIZE sizeLast, CBrush* pBrush = NULL, CBrush* pBrushLast = NULL); void FillSolidRect(LPCRECT lpRect, COLORREF clr); void FillSolidRect(int x, int y, int cx, int cy, COLORREF clr); void Draw3dRect(LPCRECT lpRect, COLORREF clrTopLeft, COLORREF clrBottomRight); void Draw3dRect(int x, int y, int cx, int cy, COLORREF clrTopLeft, COLORREF clrBottomRight); // Implementation public: virtual ~CDC(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif // advanced use and implementation BOOL m_bPrinting; HGDIOBJ SelectObject(HGDIOBJ); // do not use for regions protected: // used for implementation of non-virtual SelectObject calls static CGdiObject* PASCAL SelectGdiObject(HDC hDC, HGDIOBJ h); }; ///////////////////////////////////////////////////////////////////////////// // CDC Helpers class CPaintDC : public CDC { DECLARE_DYNAMIC(CPaintDC) // Constructors public: CPaintDC(CWnd* pWnd); // BeginPaint // Attributes protected: HWND m_hWnd; public: PAINTSTRUCT m_ps; // actual paint struct! // Implementation public: virtual ~CPaintDC(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif }; class CClientDC : public CDC { DECLARE_DYNAMIC(CClientDC) // Constructors public: CClientDC(CWnd* pWnd); // Attributes protected: HWND m_hWnd; // Implementation public: virtual ~CClientDC(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif }; class CWindowDC : public CDC { DECLARE_DYNAMIC(CWindowDC) // Constructors public: CWindowDC(CWnd* pWnd); // Attributes protected: HWND m_hWnd; // Implementation public: virtual ~CWindowDC(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif }; ///////////////////////////////////////////////////////////////////////////// // CMenu class CMenu : public CObject { DECLARE_DYNCREATE(CMenu) public: // Constructors CMenu(); BOOL CreateMenu(); BOOL CreatePopupMenu(); BOOL LoadMenu(LPCTSTR lpszResourceName); BOOL LoadMenu(UINT nIDResource); BOOL LoadMenuIndirect(const void* lpMenuTemplate); BOOL DestroyMenu(); // Attributes HMENU m_hMenu; // must be first data member HMENU GetSafeHmenu() const; operator HMENU() const; static CMenu* PASCAL FromHandle(HMENU hMenu); static void PASCAL DeleteTempMap(); BOOL Attach(HMENU hMenu); HMENU Detach(); // CMenu Operations BOOL DeleteMenu(UINT nPosition, UINT nFlags); BOOL TrackPopupMenu(UINT nFlags, int x, int y, CWnd* pWnd, LPCRECT lpRect = 0); BOOL operator==(const CMenu& menu) const; BOOL operator!=(const CMenu& menu) const; // CMenuItem Operations BOOL AppendMenu(UINT nFlags, UINT nIDNewItem = 0, LPCTSTR lpszNewItem = NULL); BOOL AppendMenu(UINT nFlags, UINT nIDNewItem, const CBitmap* pBmp); UINT CheckMenuItem(UINT nIDCheckItem, UINT nCheck); UINT EnableMenuItem(UINT nIDEnableItem, UINT nEnable); UINT GetMenuItemCount() const; UINT GetMenuItemID(int nPos) const; UINT GetMenuState(UINT nID, UINT nFlags) const; int GetMenuString(UINT nIDItem, LPTSTR lpString, int nMaxCount, UINT nFlags) const; int GetMenuString(UINT nIDItem, CString& rString, UINT nFlags) const; BOOL GetMenuItemInfo(UINT nIDItem, LPMENUITEMINFO lpMenuItemInfo, BOOL fByPos = FALSE); CMenu* GetSubMenu(int nPos) const; BOOL InsertMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem = 0, LPCTSTR lpszNewItem = NULL); BOOL InsertMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem, const CBitmap* pBmp); BOOL ModifyMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem = 0, LPCTSTR lpszNewItem = NULL); BOOL ModifyMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem, const CBitmap* pBmp); BOOL RemoveMenu(UINT nPosition, UINT nFlags); BOOL SetMenuItemBitmaps(UINT nPosition, UINT nFlags, const CBitmap* pBmpUnchecked, const CBitmap* pBmpChecked); BOOL CheckMenuRadioItem(UINT nIDFirst, UINT nIDLast, UINT nIDItem, UINT nFlags); BOOL SetDefaultItem(UINT uItem, BOOL fByPos = FALSE); UINT GetDefaultItem(UINT gmdiFlags, BOOL fByPos = FALSE); // Context Help Functions BOOL SetMenuContextHelpId(DWORD dwContextHelpId); DWORD GetMenuContextHelpId() const; // Overridables (must override draw and measure for owner-draw menu items) virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct); // Implementation public: virtual ~CMenu(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif static CMenu* PASCAL CMenu::FromHandlePermanent(HMENU hMenu); }; ///////////////////////////////////////////////////////////////////////////// // Window message map handling struct AFX_MSGMAP_ENTRY; // declared below after CWnd struct AFX_MSGMAP { #ifdef _AFXDLL const AFX_MSGMAP* (PASCAL* pfnGetBaseMap)(); #else const AFX_MSGMAP* pBaseMap; #endif const AFX_MSGMAP_ENTRY* lpEntries; }; #ifdef _AFXDLL #define DECLARE_MESSAGE_MAP() \ private: \ static const AFX_MSGMAP_ENTRY _messageEntries[]; \ protected: \ static AFX_DATA const AFX_MSGMAP messageMap; \ static const AFX_MSGMAP* PASCAL _GetBaseMessageMap(); \ virtual const AFX_MSGMAP* GetMessageMap() const; \ #else #define DECLARE_MESSAGE_MAP() \ private: \ static const AFX_MSGMAP_ENTRY _messageEntries[]; \ protected: \ static AFX_DATA const AFX_MSGMAP messageMap; \ virtual const AFX_MSGMAP* GetMessageMap() const; \ #endif #ifdef _AFXDLL #define BEGIN_MESSAGE_MAP(theClass, baseClass) \ const AFX_MSGMAP* PASCAL theClass::_GetBaseMessageMap() \ { return &baseClass;::messageMap; } \ const AFX_MSGMAP* theClass::GetMessageMap() const \ { return &theClass;::messageMap; } \ AFX_COMDAT AFX_DATADEF const AFX_MSGMAP theClass::messageMap = \ { &theClass;::_GetBaseMessageMap, &theClass;::_messageEntries[0] }; \ AFX_COMDAT const AFX_MSGMAP_ENTRY theClass::_messageEntries[] = \ { \ #else #define BEGIN_MESSAGE_MAP(theClass, baseClass) \ const AFX_MSGMAP* theClass::GetMessageMap() const \ { return &theClass;::messageMap; } \ AFX_COMDAT AFX_DATADEF const AFX_MSGMAP theClass::messageMap = \ { &baseClass;::messageMap, &theClass;::_messageEntries[0] }; \ AFX_COMDAT const AFX_MSGMAP_ENTRY theClass::_messageEntries[] = \ { \ #endif #define END_MESSAGE_MAP() \ {0, 0, 0, 0, AfxSig_end, (AFX_PMSG)0 } \ }; \ // Message map signature values and macros in separate header #include ///////////////////////////////////////////////////////////////////////////// // Dialog data exchange (DDX_) and validation (DDV_) // CDataExchange - for data exchange and validation class CDataExchange { // Attributes public: BOOL m_bSaveAndValidate; // TRUE => save and validate data CWnd* m_pDlgWnd; // container usually a dialog // Operations (for implementors of DDX and DDV procs) HWND PrepareCtrl(int nIDC); // return HWND of control HWND PrepareEditCtrl(int nIDC); // return HWND of control void Fail(); // will throw exception #ifndef _AFX_NO_OCC_SUPPORT CWnd* PrepareOleCtrl(int nIDC); // for OLE controls in dialog #endif // Implementation CDataExchange(CWnd* pDlgWnd, BOOL bSaveAndValidate); HWND m_hWndLastControl; // last control used (for validation) BOOL m_bEditLastControl; // last control was an edit item }; #include // standard DDX_ and DDV_ routines ///////////////////////////////////////////////////////////////////////////// // OLE types typedef LONG HRESULT; struct IUnknown; typedef IUnknown* LPUNKNOWN; struct IDispatch; typedef IDispatch* LPDISPATCH; struct IConnectionPoint; typedef IConnectionPoint* LPCONNECTIONPOINT; struct IEnumOLEVERB; typedef IEnumOLEVERB* LPENUMOLEVERB; typedef struct _GUID GUID; typedef GUID IID; typedef GUID CLSID; #ifndef _REFCLSID_DEFINED #define REFCLSID const CLSID & #endif typedef long DISPID; typedef unsigned short VARTYPE; typedef long SCODE; #if defined(WIN32) && !defined(OLE2ANSI) typedef WCHAR OLECHAR; #else typedef char OLECHAR; #endif typedef OLECHAR* BSTR; struct tagDISPPARAMS; typedef tagDISPPARAMS DISPPARAMS; struct tagVARIANT; typedef tagVARIANT VARIANT; struct ITypeInfo; typedef ITypeInfo* LPTYPEINFO; struct ITypeLib; typedef ITypeLib* LPTYPELIB; ///////////////////////////////////////////////////////////////////////////// // CCmdTarget // private structures struct AFX_CMDHANDLERINFO; // info about where the command is handled struct AFX_EVENT; // info about an event class CTypeLibCache; // cache for OLE type libraries ///////////////////////////////////////////////////////////////////////////// // OLE interface map handling (more in AFXDISP.H) #ifndef _AFX_NO_OLE_SUPPORT struct AFX_INTERFACEMAP_ENTRY { const void* piid; // the interface id (IID) (NULL for aggregate) size_t nOffset; // offset of the interface vtable from m_unknown }; struct AFX_INTERFACEMAP { #ifdef _AFXDLL const AFX_INTERFACEMAP* (PASCAL* pfnGetBaseMap)(); // NULL is root class #else const AFX_INTERFACEMAP* pBaseMap; #endif const AFX_INTERFACEMAP_ENTRY* pEntry; // map for this class }; #ifdef _AFXDLL #define DECLARE_INTERFACE_MAP() \ private: \ static const AFX_INTERFACEMAP_ENTRY _interfaceEntries[]; \ protected: \ static AFX_DATA const AFX_INTERFACEMAP interfaceMap; \ static const AFX_INTERFACEMAP* PASCAL _GetBaseInterfaceMap(); \ virtual const AFX_INTERFACEMAP* GetInterfaceMap() const; \ #else #define DECLARE_INTERFACE_MAP() \ private: \ static const AFX_INTERFACEMAP_ENTRY _interfaceEntries[]; \ protected: \ static AFX_DATA const AFX_INTERFACEMAP interfaceMap; \ virtual const AFX_INTERFACEMAP* GetInterfaceMap() const; \ #endif #endif //!_AFX_NO_OLE_SUPPORT ///////////////////////////////////////////////////////////////////////////// // OLE dispatch map handling (more in AFXDISP.H) #ifndef _AFX_NO_OLE_SUPPORT struct AFX_DISPMAP_ENTRY; struct AFX_DISPMAP { #ifdef _AFXDLL const AFX_DISPMAP* (PASCAL* pfnGetBaseMap)(); #else const AFX_DISPMAP* pBaseMap; #endif const AFX_DISPMAP_ENTRY* lpEntries; UINT* lpEntryCount; DWORD* lpStockPropMask; }; #ifdef _AFXDLL #define DECLARE_DISPATCH_MAP() \ private: \ static const AFX_DISPMAP_ENTRY _dispatchEntries[]; \ static UINT _dispatchEntryCount; \ static DWORD _dwStockPropMask; \ protected: \ static AFX_DATA const AFX_DISPMAP dispatchMap; \ static const AFX_DISPMAP* PASCAL _GetBaseDispatchMap(); \ virtual const AFX_DISPMAP* GetDispatchMap() const; \ #else #define DECLARE_DISPATCH_MAP() \ private: \ static const AFX_DISPMAP_ENTRY _dispatchEntries[]; \ static UINT _dispatchEntryCount; \ static DWORD _dwStockPropMask; \ protected: \ static AFX_DATA const AFX_DISPMAP dispatchMap; \ virtual const AFX_DISPMAP* GetDispatchMap() const; \ #endif #endif //!_AFX_NO_OLE_SUPPORT ///////////////////////////////////////////////////////////////////////////// // OLE Document Object command target handling #ifndef _AFX_NO_DOCOBJECT_SUPPORT struct AFX_OLECMDMAP_ENTRY { const GUID* pguid; // id of the command group ULONG cmdID; // OLECMD ID UINT nID; // corresponding WM_COMMAND message ID }; struct AFX_OLECMDMAP { #ifdef _AFXDLL const AFX_OLECMDMAP* (PASCAL* pfnGetBaseMap)(); #else const AFX_OLECMDMAP* pBaseMap; #endif const AFX_OLECMDMAP_ENTRY* lpEntries; }; #ifdef _AFXDLL #define DECLARE_OLECMD_MAP() \ private: \ static const AFX_OLECMDMAP_ENTRY _commandEntries[]; \ protected: \ static AFX_DATA const AFX_OLECMDMAP commandMap; \ static const AFX_OLECMDMAP* PASCAL _GetBaseCommandMap(); \ virtual const AFX_OLECMDMAP* GetCommandMap() const; \ #else #define DECLARE_OLECMD_MAP() \ private: \ static const AFX_OLECMDMAP_ENTRY _commandEntries[]; \ protected: \ static AFX_DATA const AFX_OLECMDMAP commandMap; \ virtual const AFX_OLECMDMAP* GetCommandMap() const; \ #endif #ifdef _AFXDLL #define BEGIN_OLECMD_MAP(theClass, baseClass) \ const AFX_OLECMDMAP* PASCAL theClass::_GetBaseCommandMap() \ { return &baseClass;::commandMap; } \ const AFX_OLECMDMAP* theClass::GetCommandMap() const \ { return &theClass;::commandMap; } \ AFX_COMDAT AFX_DATADEF const AFX_OLECMDMAP theClass::commandMap = \ { &theClass;::_GetBaseCommandMap, &theClass;::_commandEntries[0] }; \ AFX_COMDAT const AFX_OLECMDMAP_ENTRY theClass::_commandEntries[] = \ { \ #else #define BEGIN_OLECMD_MAP(theClass, baseClass) \ const AFX_OLECMDMAP* theClass::GetCommandMap() const \ { return &theClass;::commandMap; } \ AFX_COMDAT AFX_DATADEF const AFX_OLECMDMAP theClass::commandMap = \ { &baseClass;::commandMap, &theClass;::_commandEntries[0] }; \ AFX_COMDAT const AFX_OLECMDMAP_ENTRY theClass::_commandEntries[] = \ { \ #endif #define END_OLECMD_MAP() \ {NULL, 0, 0} \ }; \ class COleCmdUI; #endif //!_AFX_NO_DOCOBJECT_SUPPORT ///////////////////////////////////////////////////////////////////////////// // OLE event sink map handling (more in AFXDISP.H) #ifndef _AFX_NO_OCC_SUPPORT struct AFX_EVENTSINKMAP_ENTRY; struct AFX_EVENTSINKMAP { #ifdef _AFXDLL const AFX_EVENTSINKMAP* (PASCAL* pfnGetBaseMap)(); #else const AFX_EVENTSINKMAP* pBaseMap; #endif const AFX_EVENTSINKMAP_ENTRY* lpEntries; UINT* lpEntryCount; }; #ifdef _AFXDLL #define DECLARE_EVENTSINK_MAP() \ private: \ static const AFX_EVENTSINKMAP_ENTRY _eventsinkEntries[]; \ static UINT _eventsinkEntryCount; \ protected: \ static AFX_DATA const AFX_EVENTSINKMAP eventsinkMap; \ static const AFX_EVENTSINKMAP* PASCAL _GetBaseEventSinkMap(); \ virtual const AFX_EVENTSINKMAP* GetEventSinkMap() const; \ #else #define DECLARE_EVENTSINK_MAP() \ private: \ static const AFX_EVENTSINKMAP_ENTRY _eventsinkEntries[]; \ static UINT _eventsinkEntryCount; \ protected: \ static AFX_DATA const AFX_EVENTSINKMAP eventsinkMap; \ virtual const AFX_EVENTSINKMAP* GetEventSinkMap() const; \ #endif #endif //!_AFX_NO_OCC_SUPPORT ///////////////////////////////////////////////////////////////////////////// // OLE connection map handling (more in AFXDISP.H) #ifndef _AFX_NO_OLE_SUPPORT struct AFX_CONNECTIONMAP_ENTRY { const void* piid; // the interface id (IID) size_t nOffset; // offset of the interface vtable from m_unknown }; struct AFX_CONNECTIONMAP { #ifdef _AFXDLL const AFX_CONNECTIONMAP* (PASCAL* pfnGetBaseMap)(); // NULL is root class #else const AFX_CONNECTIONMAP* pBaseMap; #endif const AFX_CONNECTIONMAP_ENTRY* pEntry; // map for this class }; #ifdef _AFXDLL #define DECLARE_CONNECTION_MAP() \ private: \ static const AFX_CONNECTIONMAP_ENTRY _connectionEntries[]; \ protected: \ static AFX_DATA const AFX_CONNECTIONMAP connectionMap; \ static const AFX_CONNECTIONMAP* PASCAL _GetBaseConnectionMap(); \ virtual const AFX_CONNECTIONMAP* GetConnectionMap() const; \ #else #define DECLARE_CONNECTION_MAP() \ private: \ static const AFX_CONNECTIONMAP_ENTRY _connectionEntries[]; \ protected: \ static AFX_DATA const AFX_CONNECTIONMAP connectionMap; \ virtual const AFX_CONNECTIONMAP* GetConnectionMap() const; \ #endif #endif //!_AFX_NO_OLE_SUPPORT ///////////////////////////////////////////////////////////////////////////// // CCmdTarget proper #ifndef _AFX_NO_OCC_SUPPORT class COccManager; // forward reference (see ..\src\occimpl.h) #endif #ifdef _AFXDLL class CCmdTarget : public CObject #else class AFX_NOVTABLE CCmdTarget : public CObject #endif { DECLARE_DYNAMIC(CCmdTarget) protected: public: // Constructors CCmdTarget(); // Attributes LPDISPATCH GetIDispatch(BOOL bAddRef); // retrieve IDispatch part of CCmdTarget static CCmdTarget* PASCAL FromIDispatch(LPDISPATCH lpDispatch); // map LPDISPATCH back to CCmdTarget* (inverse of GetIDispatch) BOOL IsResultExpected(); // returns TRUE if automation function should return a value // Operations void EnableAutomation(); // call in constructor to wire up IDispatch void EnableConnections(); // call in constructor to wire up IConnectionPointContainer void BeginWaitCursor(); void EndWaitCursor(); void RestoreWaitCursor(); // call after messagebox #ifndef _AFX_NO_OLE_SUPPORT // dispatch OLE verbs through the message map BOOL EnumOleVerbs(LPENUMOLEVERB* ppenumOleVerb); BOOL DoOleVerb(LONG iVerb, LPMSG lpMsg, HWND hWndParent, LPCRECT lpRect); #endif // Overridables // route and dispatch standard command message types // (more sophisticated than OnCommand) virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo); #ifndef _AFX_NO_OLE_SUPPORT // called when last OLE reference is released virtual void OnFinalRelease(); #endif #ifndef _AFX_NO_OLE_SUPPORT // called before dispatching to an automation handler function virtual BOOL IsInvokeAllowed(DISPID dispid); #endif #ifndef _AFX_NO_OLE_SUPPORT // support for OLE type libraries void EnableTypeLib(); HRESULT GetTypeInfoOfGuid(LCID lcid, const GUID& guid, LPTYPEINFO* ppTypeInfo); virtual BOOL GetDispatchIID(IID* pIID); virtual UINT GetTypeInfoCount(); virtual CTypeLibCache* GetTypeLibCache(); virtual HRESULT GetTypeLib(LCID lcid, LPTYPELIB* ppTypeLib); #endif // Implementation public: virtual ~CCmdTarget(); #ifdef _DEBUG virtual void Dump(CDumpContext& dc) const; virtual void AssertValid() const; #endif #ifndef _AFX_NO_OLE_SUPPORT void GetNotSupported(); void SetNotSupported(); #endif protected: friend class CView; CView* GetRoutingView(); CFrameWnd* GetRoutingFrame(); static CView* PASCAL GetRoutingView_(); static CFrameWnd* PASCAL GetRoutingFrame_(); DECLARE_MESSAGE_MAP() // base class - no {{ }} macros #ifndef _AFX_NO_DOCOBJECT_SUPPORT DECLARE_OLECMD_MAP() friend class COleCmdUI; #endif #ifndef _AFX_NO_OLE_SUPPORT DECLARE_DISPATCH_MAP() DECLARE_CONNECTION_MAP() DECLARE_INTERFACE_MAP() #ifndef _AFX_NO_OCC_SUPPORT DECLARE_EVENTSINK_MAP() #endif // !_AFX_NO_OCC_SUPPORT // OLE interface map implementation public: // data used when CCmdTarget is made OLE aware long m_dwRef; LPUNKNOWN m_pOuterUnknown; // external controlling unknown if != NULL DWORD m_xInnerUnknown; // place-holder for inner controlling unknown public: // advanced operations void EnableAggregation(); // call to enable aggregation void ExternalDisconnect(); // forcibly disconnect LPUNKNOWN GetControllingUnknown(); // get controlling IUnknown for aggregate creation // these versions do not delegate to m_pOuterUnknown DWORD InternalQueryInterface(const void*, LPVOID* ppvObj); DWORD InternalAddRef(); DWORD InternalRelease(); // these versions delegate to m_pOuterUnknown DWORD ExternalQueryInterface(const void*, LPVOID* ppvObj); DWORD ExternalAddRef(); DWORD ExternalRelease(); // implementation helpers LPUNKNOWN GetInterface(const void*); LPUNKNOWN QueryAggregates(const void*); // advanced overrideables for implementation virtual BOOL OnCreateAggregates(); virtual LPUNKNOWN GetInterfaceHook(const void*); // OLE automation implementation protected: struct XDispatch { DWORD m_vtbl; // place-holder for IDispatch vtable #ifndef _AFX_NO_NESTED_DERIVATION size_t m_nOffset; #endif } m_xDispatch; BOOL m_bResultExpected; // member variable-based properties void GetStandardProp(const AFX_DISPMAP_ENTRY* pEntry, VARIANT* pvarResult, UINT* puArgErr); SCODE SetStandardProp(const AFX_DISPMAP_ENTRY* pEntry, DISPPARAMS* pDispParams, UINT* puArgErr); // DISPID to dispatch map lookup static UINT PASCAL GetEntryCount(const AFX_DISPMAP* pDispMap); const AFX_DISPMAP_ENTRY* PASCAL GetDispEntry(LONG memid); static LONG PASCAL MemberIDFromName(const AFX_DISPMAP* pDispMap, LPCTSTR lpszName); // helpers for member function calling implementation static UINT PASCAL GetStackSize(const BYTE* pbParams, VARTYPE vtResult); #ifdef _PPC_ SCODE PushStackArgs(BYTE* pStack, const BYTE* pbParams, void* pResult, VARTYPE vtResult, DISPPARAMS* pDispParams, UINT* puArgErr, VARIANT* rgTempVars, UINT nSizeArgs); #else SCODE PushStackArgs(BYTE* pStack, const BYTE* pbParams, void* pResult, VARTYPE vtResult, DISPPARAMS* pDispParams, UINT* puArgErr, VARIANT* rgTempVars); #endif SCODE CallMemberFunc(const AFX_DISPMAP_ENTRY* pEntry, WORD wFlags, VARIANT* pvarResult, DISPPARAMS* pDispParams, UINT* puArgErr); friend class COleDispatchImpl; #ifndef _AFX_NO_OCC_SUPPORT public: // OLE event sink implementation BOOL OnEvent(UINT idCtrl, AFX_EVENT* pEvent, AFX_CMDHANDLERINFO* pHandlerInfo); protected: const AFX_EVENTSINKMAP_ENTRY* PASCAL GetEventSinkEntry(UINT idCtrl, AFX_EVENT* pEvent); #endif // !_AFX_NO_OCC_SUPPORT // OLE connection implementation struct XConnPtContainer { DWORD m_vtbl; // place-holder for IConnectionPointContainer vtable #ifndef _AFX_NO_NESTED_DERIVATION size_t m_nOffset; #endif } m_xConnPtContainer; #ifdef _AFXDLL AFX_MODULE_STATE* m_pModuleState; friend class CInnerUnknown; friend UINT APIENTRY _AfxThreadEntry(void* pParam); #endif virtual BOOL GetExtraConnectionPoints(CPtrArray* pConnPoints); virtual LPCONNECTIONPOINT GetConnectionHook(const IID& iid); friend class COleConnPtContainer; #endif //!_AFX_NO_OLE_SUPPORT }; class CCmdUI // simple helper class { public: // Attributes UINT m_nID; UINT m_nIndex; // menu item or other index // if a menu item CMenu* m_pMenu; // NULL if not a menu CMenu* m_pSubMenu; // sub containing menu item // if a popup sub menu - ID is for first in popup // if from some other window CWnd* m_pOther; // NULL if a menu or not a CWnd // Operations to do in ON_UPDATE_COMMAND_UI virtual void Enable(BOOL bOn = TRUE); virtual void SetCheck(int nCheck = 1); // 0, 1 or 2 (indeterminate) virtual void SetRadio(BOOL bOn = TRUE); virtual void SetText(LPCTSTR lpszText); // Advanced operation void ContinueRouting(); // Implementation CCmdUI(); BOOL m_bEnableChanged; BOOL m_bContinueRouting; UINT m_nIndexMax; // last + 1 for iterating m_nIndex CMenu* m_pParentMenu; // NULL if parent menu not easily determined // (probably a secondary popup menu) BOOL DoUpdate(CCmdTarget* pTarget, BOOL bDisableIfNoHndler); }; // special CCmdUI derived classes are used for other UI paradigms // like toolbar buttons and status indicators // pointer to afx_msg member function #ifndef AFX_MSG_CALL #define AFX_MSG_CALL #endif typedef void (AFX_MSG_CALL CCmdTarget::*AFX_PMSG)(void); enum AFX_DISPMAP_FLAGS { afxDispCustom = 0, afxDispStock = 1 }; struct AFX_DISPMAP_ENTRY { LPCTSTR lpszName; // member/property name long lDispID; // DISPID (may be DISPID_UNKNOWN) LPCSTR lpszParams; // member parameter description WORD vt; // return value type / or type of property AFX_PMSG pfn; // normal member On or, OnGet AFX_PMSG pfnSet; // special member for OnSet size_t nPropOffset; // property offset AFX_DISPMAP_FLAGS flags;// flags (e.g. stock/custom) }; struct AFX_EVENTSINKMAP_ENTRY { AFX_DISPMAP_ENTRY dispEntry; UINT nCtrlIDFirst; UINT nCtrlIDLast; }; // DSC Sink state/reason codes passed to MFC user event handlers enum DSCSTATE { dscNoState = 0, dscOKToDo, dscCancelled, dscSyncBefore, dscAboutToDo, dscFailedToDo, dscSyncAfter, dscDidEvent }; enum DSCREASON { dscNoReason = 0, dscClose, dscCommit, dscDelete, dscEdit, dscInsert, dscModify, dscMove }; ///////////////////////////////////////////////////////////////////////////// // CWnd implementation // structures (see afxext.h) struct CCreateContext; // context for creating things struct CPrintInfo; // print preview customization info struct AFX_MSGMAP_ENTRY { UINT nMessage; // windows message UINT nCode; // control code or WM_NOTIFY code UINT nID; // control ID (or 0 for windows messages) UINT nLastID; // used for entries specifying a range of control id's UINT nSig; // signature type (action) or pointer to message # AFX_PMSG pfn; // routine to call (or special value) }; ///////////////////////////////////////////////////////////////////////////// // CWnd - a Microsoft Windows application window class COleDropTarget; // for more information see AFXOLE.H class COleControlContainer; class COleControlSite; // CWnd::m_nFlags (generic to CWnd) #define WF_TOOLTIPS 0x0001 // window is enabled for tooltips #define WF_TEMPHIDE 0x0002 // window is temporarily hidden #define WF_STAYDISABLED 0x0004 // window should stay disabled #define WF_MODALLOOP 0x0008 // currently in modal loop #define WF_CONTINUEMODAL 0x0010 // modal loop should continue running #define WF_OLECTLCONTAINER 0x0100 // some descendant is an OLE control #define WF_TRACKINGTOOLTIPS 0x0400 // window is enabled for tracking tooltips // CWnd::m_nFlags (specific to CFrameWnd) #define WF_STAYACTIVE 0x0020 // look active even though not active #define WF_NOPOPMSG 0x0040 // ignore WM_POPMESSAGESTRING calls #define WF_MODALDISABLE 0x0080 // window is disabled #define WF_KEEPMINIACTIVE 0x0200 // stay activate even though you are deactivated // flags for CWnd::RunModalLoop #define ML

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧