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

📄 wcefirstappview.cpp

📁 WinCE编程的一个简单示例
💻 CPP
字号:
// WCEFirstAppView.cpp : implementation of the CWCEFirstAppView class
//

#include "stdafx.h"
#include "WCEFirstApp.h"

#include "WCEFirstAppDoc.h"
#include "WCEFirstAppView.h"
#include "WCEFirstDialog.h"


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

/////////////////////////////////////////////////////////////////////////////
// CWCEFirstAppView

IMPLEMENT_DYNCREATE(CWCEFirstAppView, CView)

BEGIN_MESSAGE_MAP(CWCEFirstAppView, CView)
	//{{AFX_MSG_MAP(CWCEFirstAppView)
	ON_WM_ERASEBKGND()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CWCEFirstAppView construction/destruction

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

}

CWCEFirstAppView::~CWCEFirstAppView()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CWCEFirstAppView drawing

void CWCEFirstAppView::OnDraw(CDC* pDC)
{
	CWCEFirstAppDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

}

/////////////////////////////////////////////////////////////////////////////
// CWCEFirstAppView diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CWCEFirstAppView message handlers
BOOL CWCEFirstAppView::OnEraseBkgnd(CDC* pDC) 
{
	///////////////////////////////////////////////////////////////////////////
	// Define Our Variables                                                  //
	///////////////////////////////////////////////////////////////////////////
    CBitmap bmp, *poldbmp;
	BITMAP bmpStruct;
    CDC memdc;
	CRect bmpRect, clientRect;
    
	///////////////////////////////////////////////////////////////////////////
	// Let's Paint the Background Black for a Nice Contrast with the Bitmap  //
	///////////////////////////////////////////////////////////////////////////

	// Set brush to desired background color
    CBrush backBrush(RGB(0,0,0));

    // Save old brush
    CBrush* pOldBrush = pDC->SelectObject(&backBrush);

	// Get the Size of the CLient Area
    GetClientRect(&clientRect);     

	// Fill the Client Area Using our new Brush
	pDC->FillRect(&clientRect, &backBrush);
	
	///////////////////////////////////////////////////////////////////////////
	// Now Lets Blit the Bitmap                                              //
	///////////////////////////////////////////////////////////////////////////

	// Load the bitmap resource
    bmp.LoadBitmap(IDB_WINCE_BITMAP);
    bmp.GetBitmap(&bmpStruct);

	// Figure out the Coordinates to Center the Bitmap
	bmpRect.left   = clientRect.left + (clientRect.Width() - 
		                                bmpStruct.bmWidth)/2;
	bmpRect.top    = clientRect.top + (clientRect.Height() - 
		                               bmpStruct.bmHeight)/2;
	bmpRect.right  = clientRect.right - (clientRect.Width() - 
		                                 bmpStruct.bmWidth)/2;
	bmpRect.bottom = clientRect.bottom - (clientRect.Height() - 
		                                  bmpStruct.bmHeight)/2;

    // Create a compatible memory DC
    memdc.CreateCompatibleDC(pDC);

    // Select the bitmap into the DC
    poldbmp = memdc.SelectObject( &bmp );

    // Copy (BitBlt) bitmap from memory DC to screen DC
    pDC->BitBlt(bmpRect.left, 
		        bmpRect.top, 
		        bmpRect.right,
				bmpRect.bottom, 
				&memdc, 
				0,
				0, 
				SRCCOPY);

	// Restore the DC to it's Original State
    memdc.SelectObject(poldbmp);
    pDC->SelectObject(pOldBrush);
	
	return TRUE;
}

⌨️ 快捷键说明

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