[問題] VC++ mfc內多執行緒
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
VS2008 / VC++
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
MFC
問題(Question):
使用Afxbeginthread(Data_handler, NULL);後
在UINT __cdecl Data_handler(LPVOID pParam)中
要如何取得原執行緒之doc類別的指標?
餵入的資料(Input):
預期的正確結果(Expected Output):
pDoc得到正確的指標,並可以順利存取到原執行緒之doc物件
錯誤結果(Wrong Output):
執行到
static CQuoteTesterDoc* pDoc=
(CQuoteTesterDoc*)(pMDIFrame->GetActiveDocument());
之後會出現:http://sunto.cc/d/4508
的錯誤碼
程式碼(Code):(請善用置底文網頁, 記得排版)
UINT __cdecl Data_handler(LPVOID pParam){
static CFrameWnd* pFrame =
(CFrameWnd*)(AfxGetApp()->m_pMainWnd);
static CFrameWnd* pMDIFrame=
(CFrameWnd*) (pFrame->GetActiveFrame());
static CQuoteTesterDoc* pDoc=
(CQuoteTesterDoc*)(pMDIFrame->GetActiveDocument());
...
...
}
補充說明(Supplement):
第一次在這邊po文請大家多多指點,有不詳盡的地方再請指出
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.124.3.17
→
06/07 20:13, , 1F
06/07 20:13, 1F
→
06/08 23:51, , 2F
06/08 23:51, 2F
→
06/14 16:02, , 3F
06/14 16:02, 3F
→
06/14 16:04, , 4F
06/14 16:04, 4F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章