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

📄 mthrea~2.cpp

📁 visual c++ 时尚编程百例 全部源代码
💻 CPP
字号:
// MThreadView.cpp : implementation of the CMThreadView class
//

#include "stdafx.h"
#include "MThread.h"

#include "MThreadDoc.h"
#include "MThreadView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMThreadView

IMPLEMENT_DYNCREATE(CMThreadView, CView)

BEGIN_MESSAGE_MAP(CMThreadView, CView)
	//{{AFX_MSG_MAP(CMThreadView)
	ON_COMMAND(ID_THREAD, OnThread)
	ON_WM_TIMER()
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CMThreadView construction/destruction

CMThreadView::CMThreadView()
{
	m_init=FALSE;
	// TODO: add construction code here

}

CMThreadView::~CMThreadView()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMThreadView drawing

void CMThreadView::OnDraw(CDC* pDC)
{
	CMThreadDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CMThreadView printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CMThreadView diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CMThreadView message handlers
UINT CompileThread(LPVOID param)
{
	CMThreadView*pParent=(CMThreadView*)(((CFrameWnd*)(AfxGetApp()->m_pMainWnd))->GetActiveView());
	if(pParent)
	{
		CRect rect(30,PosCount+40,230,PosCount+60);
		PosCount+=40;
		CProgressCtrl progress;
		progress.Create(WS_CHILD|WS_VISIBLE,rect,pParent,0);
		progress.SetRange(0,100);
		progress.SetPos(0);
		progress.SetStep(1);
		int i=Count;
		for(;;)
		{
			if(Count>i)
			{
				int p;
				progress.StepIt();
				p=progress.GetPos();
				if(p==100)
					return 1;
				i=Count;
			}
		}
	}
	return 1;
}

void CMThreadView::OnThread() 
{
m_init=TRUE;
Invalidate();
SetTimer(0,50,NULL);
HWND hwnd=GetSafeHwnd();
AfxBeginThread(CompileThread,hwnd,THREAD_PRIORITY_LOWEST);	
}

void CMThreadView::OnTimer(UINT nIDEvent) 
{
Count++;	
	CView::OnTimer(nIDEvent);
}

⌨️ 快捷键说明

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