简体   繁体   English

如何将主 Dlg 的指针从线程传递到 MFC 内部的函数

[英]How to pass the pointer of main Dlg from a thread to a function inside in MFC

There are two Thread sharing a funciton.有两个线程共享一个函数。 I want to show information in Dlg when I run the function.我想在运行函数时在 Dlg 中显示信息。 But I don't know how to pass the pointer of main Dlg.但是我不知道如何传递main Dlg的指针。 When I run the following code ,it shows ERROR 2061.当我运行以下代码时,它显示 ERROR 2061。

XXXTab.h XXXTab.h

static void Snap(CBoxUnstackingDlg *CMFCAppDlg);

static UINT __cdecl MtA(LPVOID lpParam);
static UINT __cdecl MtB(LPVOID lpParam);

XXXTab.cpp XXXTab.cpp

void CThirdTab::Snap(CBoxUnstackingDlg *CMFCAppDlg)```
{
}

UINT __cdecl CThirdTab::MtA(LPVOID lpParam)
{
   CBoxUnstackingDlg *CMFCAppDlg = (CBoxUnstackingDlg *)lpParam;
   Snap(CMFCAppDlg );
}

UINT __cdecl CThirdTab::MtB(LPVOID lpParam)
{
   CBoxUnstackingDlg *CMFCAppDlg = (CBoxUnstackingDlg *)lpParam;
   Snap(CMFCAppDlg );
}

I found the reason is two headers include each other.我发现原因是两个标题相互包含。 Making the function Snap out of class Thirdtab can fix the problem.将函数Snap出类Thirdtab可以解决这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM