Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
An example of user interface thread implementation
#include "pch.h"
#include "ShowOfflineFiles.h"
#include "ShowOfflineFilesDoc.h"
#include "CFindStatusDlg.h"
#include "CFindStatusDlgThread.h"
// CFindStatusDlgThread
IMPLEMENT_DYNCREATE(CFindStatusDlgThread, CWinThread)
CFindStatusDlgThread::CFindStatusDlgThread():
m_pDoc(NULL), m_hParent(NULL)
{
}
CFindStatusDlgThread::~CFindStatusDlgThread()
{
}
BOOL CFindStatusDlgThread::InitInstance()
{
ASSERT(m_pDoc != NULL);
CFindStatusDlg* &pDlg = m_pDoc->m_pFindStatusDlg;
pDlg->m_hParent = m_hParent;
m_pMainWnd = pDlg;
pDlg->DoModal();
return TRUE;
}
int CFindStatusDlgThread::ExitInstance()
{
return CWinThread::ExitInstance();
}
BEGIN_MESSAGE_MAP(CFindStatusDlgThread, CWinThread)
END_MESSAGE_MAP()
void CShowOfflineFilesDoc::OnFind()
{
/* Snip */
CFindStatusDlgThread* pThread = DYNAMIC_DOWNCAST(CFindStatusDlgThread, AfxBeginThread(RUNTIME_CLASS(CFindStatusDlgThread), 0, 0, CREATE_SUSPENDED));
ASSERT(pThread);
pThread->m_pDoc = this;
pThread->m_hParent = AfxGetMainWnd()->m_hWnd;
pThread->ResumeThread();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.