www.pudn.com > 在控件的客户区中使用textout.rar > vueView.cpp


// vueView.cpp : implementation of the CVueView class 
// 
 
#include "stdafx.h" 
#include "vue.h" 
#include "autovuex.h" 
#include "vueDoc.h" 
#include "vueView.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CVueView 
 
IMPLEMENT_DYNCREATE(CVueView, CFormView) 
 
BEGIN_MESSAGE_MAP(CVueView, CFormView) 
	//{{AFX_MSG_MAP(CVueView) 
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1) 
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2) 
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3) 
	ON_BN_CLICKED(IDC_TEXTOUT, OnTextout) 
 
	//}}AFX_MSG_MAP 
	// Standard printing commands 
	ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint) 
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint) 
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview) 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CVueView construction/destruction 
 
CVueView::CVueView() 
	: CFormView(CVueView::IDD) 
{ 
	//{{AFX_DATA_INIT(CVueView) 
		// NOTE: the ClassWizard will add member initialization here 
	//}}AFX_DATA_INIT 
	// TODO: add construction code here 
	m_mark=false; 
	m_bDragging=false; 
	m_hCross=AfxGetApp()->LoadStandardCursor(IDC_CROSS); 
 
} 
 
CVueView::~CVueView() 
{ 
} 
 
void CVueView::DoDataExchange(CDataExchange* pDX) 
{ 
	CFormView::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CVueView) 
		// NOTE: the ClassWizard will add DDX and DDV calls here 
	DDX_Control(pDX, IDC_AUTOVUEXCTRL1, m_AvXCtrl); 
	//}}AFX_DATA_MAP 
} 
 
BOOL CVueView::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	// TODO: Modify the Window class or styles here by modifying 
	//  the CREATESTRUCT cs 
 
	return CFormView::PreCreateWindow(cs); 
} 
 
void CVueView::OnInitialUpdate() 
{ 
	CFormView::OnInitialUpdate(); 
	GetParentFrame()->RecalcLayout(); 
	ResizeParentToFit(); 
 
 
 
 /*	if(m_bInit == FALSE) { 
		// Tricky part. Do not initialize twice, otherwise, the OCX toolbars will  
		// not get painted properly 
		CFormView::OnInitialUpdate(); 
		 
		if (!m_AvXCtrl.GetSafeHwnd()) 
		{ 
			return; 
		} 
		GetParentFrame()->RecalcLayout(); 
		ResizeParentToFit(); 
		m_bInit = TRUE; 
	}*/ 
		 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CVueView printing 
 
BOOL CVueView::OnPreparePrinting(CPrintInfo* pInfo) 
{ 
	// default preparation 
	return DoPreparePrinting(pInfo); 
} 
 
void CVueView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add extra initialization before printing 
} 
 
void CVueView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add cleanup after printing 
} 
 
void CVueView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add customized printing code here 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CVueView diagnostics 
 
#ifdef _DEBUG 
void CVueView::AssertValid() const 
{ 
	CFormView::AssertValid(); 
} 
 
void CVueView::Dump(CDumpContext& dc) const 
{ 
	CFormView::Dump(dc); 
} 
 
CVueDoc* CVueView::GetDocument() // non-debug version is inline 
{ 
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CVueDoc))); 
	return (CVueDoc*)m_pDocument; 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CVueView message handlers 
 
BEGIN_EVENTSINK_MAP(CVueView, CFormView) 
    //{{AFX_EVENTSINK_MAP(CVueView) 
	ON_EVENT(CVueView, IDC_AUTOVUEXCTRL1, 1 /* ModeChanged */, OnModeChanged, VTS_I2 VTS_I2) 
	ON_EVENT(CVueView, IDC_AUTOVUEXCTRL1, 9 /* OnLMButtonDown */, OnOnLMButtonDownAutovuexctrl, VTS_R8 VTS_R8) 
	ON_EVENT(CVueView, IDC_AUTOVUEXCTRL1, 12 /* OnRMButtonDown */, OnOnRMButtonDownAutovuexctrl, VTS_R8 VTS_R8) 
	//}}AFX_EVENTSINK_MAP 
END_EVENTSINK_MAP() 
 
 
 
void CVueView::OnModeChanged(short nOldMode, short nNewMode)  
{ 
	// TODO: Add your control notification handler code here 
	if (!m_AvXCtrl.GetSafeHwnd()) 
	{ 
		return; 
	} 
 
// 	CListBox* pLB = (CListBox*) GetDlgItem(IDC_FILELIST); 
// 	CEdit* pEditDir = (CEdit*) GetDlgItem(IDC_PATH); 
// 	CEdit* pEditFileName = (CEdit*) GetDlgItem(IDC_SELECTEDFILE); 
	 
// 	if (pLB == NULL || pEditDir == NULL || pEditFileName == NULL) { 
// 		return; 
// 	} 
	if (nNewMode == 0) { 
// 		pLB->EnableWindow(TRUE); 
// 		pEditDir->EnableWindow(TRUE); 
// 		pEditFileName->EnableWindow(TRUE); 
 	}  else { 
		// Enter markup / print preview mode, force to repainting  
//  		pLB->EnableWindow(FALSE); 
// 		pEditDir->EnableWindow(FALSE); 
// 		pEditFileName->EnableWindow(FALSE); 
		m_AvXCtrl.Invalidate(); 
		m_AvXCtrl.UpdateWindow(); 
	} 
} 
 
void CVueView::OnButton1()  
{ 
	// TODO: Add your control notification handler code here 
	m_AvXCtrl.ZoomFit(); 
} 
 
void CVueView::OnButton2()  
{ 
	// TODO: Add your control notification handler code here 
	m_AvXCtrl.EnableZoomBoxMode(false); 
} 
 
void CVueView::OnButton3()  
{ 
	// TODO: Add your control notification handler code here 
	m_AvXCtrl.EnablePanMode(1); 
} 
 
void CVueView::OnTextout()  
{ 
	// TODO: Add your control notification handler code here 
	CWnd * pWnd=GetDlgItem(IDC_AUTOVUEXCTRL1); 
// 	CDC * pControlDC=pWnd->GetDC(); 
	CClientDC dc(pWnd); 
 	 
 	pWnd->Invalidate();//既要在控件窗口内绘图,又要防止windows对它进行重复绘制(技术内幕6.8) 
 	pWnd->UpdateWindow(); 
	int i=(int)dPosX; 
	int j=(int)dPosY; 
 //  MessageBox("得到当前设备环境"); 
	pControlDC->SetBkMode(TRANSPARENT); 
	pControlDC->TextOut(i,j,"试试看在formview上写东西"); 
	UpdateData(false); 
	 
} 
 
 
 
 
BOOL CVueView::PreTranslateMessage(MSG* pMsg)  
{ 
	// TODO: Add your specialized code here and/or call the base class 
	 
	return CFormView::PreTranslateMessage(pMsg); 
} 
 
 
void CVueView::OnOnLMButtonDownAutovuexctrl(double xPos, double yPos)  
{ 
	// TODO: Add your control notification handler code here 
	m_AvXCtrl.EnableZoomBoxMode(false); 
	dPosY=yPos; 
	dPosX=xPos; 
} 
 
void CVueView::OnOnRMButtonDownAutovuexctrl(double xPos, double yPos)  
{ 
	// TODO: Add your control notification handler code here 
	m_AvXCtrl.EnableZoomBoxMode(false); 
}