Created
March 25, 2020 08:16
-
-
Save nibasya/f3fc0597861335fcec09addadd6ca5f6 to your computer and use it in GitHub Desktop.
An example of user interface thread implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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