?? uiandworkthreadview.cpp
字號:
// UIandWorkThreadView.cpp : implementation of the CUIandWorkThreadView class
//
#include "stdafx.h"
#include "resource.h"
#include "UIandWorkThread.h"
#include "UIandWorkThreadDoc.h"
#include "UIandWorkThreadView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CUIandWorkThreadView
IMPLEMENT_DYNCREATE(CUIandWorkThreadView, CFormView)
BEGIN_MESSAGE_MAP(CUIandWorkThreadView, CFormView)
//{{AFX_MSG_MAP(CUIandWorkThreadView)
ON_BN_CLICKED(IDC_BTN_BEGINTHREAD, OnBtnBeginthread)
ON_BN_CLICKED(IDC_BTN_CANCAL, OnBtnCancal)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUIandWorkThreadView construction/destruction
CUIandWorkThreadView::CUIandWorkThreadView()
: CFormView(CUIandWorkThreadView::IDD)
{
//{{AFX_DATA_INIT(CUIandWorkThreadView)
m_strOutMsg = _T("");
//}}AFX_DATA_INIT
// TODO: add construction code here
}
CUIandWorkThreadView::~CUIandWorkThreadView()
{
}
void CUIandWorkThreadView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CUIandWorkThreadView)
DDX_Control(pDX, IDC_BTN_CANCAL, m_btnQuit);
DDX_Text(pDX, IDC_EDIT_MSG, m_strOutMsg);
//}}AFX_DATA_MAP
}
BOOL CUIandWorkThreadView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CFormView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CUIandWorkThreadView diagnostics
#ifdef _DEBUG
void CUIandWorkThreadView::AssertValid() const
{
CFormView::AssertValid();
}
void CUIandWorkThreadView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CUIandWorkThreadDoc* CUIandWorkThreadView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CUIandWorkThreadDoc)));
return (CUIandWorkThreadDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CUIandWorkThreadView message handlers
void CUIandWorkThreadView::UpdateMsg(CEdit *hWndEdit, CString strMsg)
{
CString strText;
hWndEdit->SetRedraw(FALSE);
hWndEdit->GetWindowText(strText);
strText += L"\r\n";
strText += strMsg;
hWndEdit->SetWindowText(strText);
hWndEdit->LineScroll (hWndEdit->GetLineCount(), 0);
hWndEdit->SetRedraw(TRUE);
}
void CUIandWorkThreadView::OnBtnBeginthread()
{
CEdit* hWndMsg = (CEdit*)GetDlgItem(IDC_EDIT_MSG);
hWndMsg->SetWindowText(L"");
CWinThread* hThread = AfxBeginThread((AFX_THREADPROC)ShowThread, this);
}
void CUIandWorkThreadView::ShowThread(CUIandWorkThreadView *pThis)
{
CEdit* hWndMsg = (CEdit*)pThis->GetDlgItem(IDC_EDIT_MSG);
UpdateMsg(hWndMsg, L"WorkThread begin...");
UpdateMsg(hWndMsg, L"Transaction processing here...");
Sleep(300);
UpdateMsg(hWndMsg, L"Step 1 ...");
Sleep(300);
UpdateMsg(hWndMsg, L"Step 2 ...");
Sleep(300);
UpdateMsg(hWndMsg, L"Step 3 ...");
Sleep(300);
UpdateMsg(hWndMsg, L"Step 4 ...");
Sleep(300);
UpdateMsg(hWndMsg, L"Step 5 ...");
Sleep(1000);
UpdateMsg(hWndMsg, L"End transaction processing ...");
}
void CUIandWorkThreadView::OnBtnCancal()
{
::PostQuitMessage(0);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -