⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wzdview.cpp

📁 《vc++扩展编程实例》源码。运用Visual C++ 5.0或6.0的高级编程技巧
💻 CPP
字号:
// WzdView.cpp : implementation of the CWzdView class
//

#include "stdafx.h"
#include "Wzd.h"

#include "WzdDoc.h"
#include "WzdView.h"
#include "WzdWnd.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CWzdView

IMPLEMENT_DYNCREATE(CWzdView, CView)

BEGIN_MESSAGE_MAP(CWzdView, CView)
	//{{AFX_MSG_MAP(CWzdView)
	ON_COMMAND(ID_TEST_WZD1, OnTestWzd1)
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CWzdView construction/destruction

CWzdView::CWzdView()
{
	// TODO: add construction code here

}

CWzdView::~CWzdView()
{
}

BOOL CWzdView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CWzdView drawing

void CWzdView::OnDraw(CDC* pDC)
{
	CWzdDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CWzdView printing

BOOL CWzdView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CWzdView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CWzdView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CWzdView diagnostics

#ifdef _DEBUG
void CWzdView::AssertValid() const
{
	CView::AssertValid();
}

void CWzdView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CWzdDoc* CWzdView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CWzdDoc)));
	return (CWzdDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CWzdView message handlers

void CWzdView::OnTestWzd1() 
{
	// create a child window with the "BUTTON" window class
	m_wndChildButton.CreateEx(0,	// extended window style
		_T("BUTTON"),				// window class name
		"Button",					// window caption
		WS_CHILD|WS_VISIBLE,		// window style
		10,10,100,75,					// position and dimensions
		m_hWnd,						// parent window handle
		(HMENU)IDC_WZD_BUTTON		// window id
		);

	// create same button using member function of CButton class
	CRect rect(200,200,300,275);
	m_wndButton.Create(
		"Button",					//window caption
		WS_CHILD|WS_VISIBLE,		//window style
		rect,						// position and dimensions
		this,						// parent window class
		IDC_WZD_BUTTON				// window id
		);


	// create an overlapped window with an MFC window class
	LPCTSTR lpszClass = AfxRegisterWndClass(0, ::LoadCursor(NULL, IDC_ARROW),
		(HBRUSH)(COLOR_BACKGROUND+1), NULL);

	HMENU hMenu=::LoadMenu(NULL,MAKEINTRESOURCE(IDR_WZD_MENU));

	CWzdWnd *pWnd=new CWzdWnd;
	pWnd->CreateEx(WS_EX_CLIENTEDGE,// extended window style
		lpszClass,					// window class name
		"Overlapped",				// window caption
		WS_CAPTION|WS_SYSMENU|WS_OVERLAPPED|WS_VISIBLE|WS_DLGFRAME, 
									// window style
		120,120,200,100,			// position and dimensions
		NULL,						// owner window handle--NULL is Desktop
		hMenu						// for popup and overlapped windows: window menu handle
		);


	// create window with Windows API, then wrap with an MFC class
	HWND hWnd=::CreateWindowEx(
		WS_EX_CLIENTEDGE,			// extended window style
		lpszClass,					// windows class name
		"Overlapped 2",				// window caption
		WS_CAPTION|WS_SYSMENU|WS_OVERLAPPED|WS_VISIBLE|WS_DLGFRAME, 
									// window style
		220,220,200,100,			// position and dimensions
		NULL,						// owner window handle--NULL is Desktop
		hMenu,						// for popup and overlapped windows: window menu handle
		AfxGetInstanceHandle(),		// handle to application instance
		NULL				        // pointer to window-creation data
		);
 
	m_wndWrapper.Attach(hWnd);

	/// access window using CWnd class member functions


	// detach from an existing window and destroy class
	m_wndWrapper.Detach();

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -