本文介绍了如何在Afxbeginthread的指定函数中打开上下文菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

THREADSTRUCT* ts = new THREADSTRUCT;
ts->_this = this;
AfxBeginThread(ThreadFunction,ts);





UINT CExample_MFCDlg :: ThreadFunction(void * param)

{

THREADSTRUCT * thread =(THREADSTRUCT *)param;

int i = 0;

CString str;

while(1)

{

str.Format(L%d,i);

thread-> _this-> m_ThreadValue.SetWindowTextW(str);

i + = 10 ;

睡眠(60);

}

} //以上代码使用Thread工作正常但当我改变时





UINT CExample_MFCDlg::ThreadFunction(void* param)
{
THREADSTRUCT *thread = (THREADSTRUCT*)param;
int i = 0;
CString str;
while(1)
{
str.Format(L"%d",i);
thread->_this->m_ThreadValue.SetWindowTextW(str);
i +=10;
Sleep(60);
}
} // Above Code working fine using Thread But when i Change By

THREADSTRUCT *thread = (THREADSTRUCT*)param;
    bool showWindow = false;
    while(1)
    {
        {
            CMenu *mnuPopupMenu = thread->_this->mnuPopupSubmit.GetSubMenu(0);
            ASSERT(mnuPopupMenu);

            CPoint tempPOint;
            ::GetCursorPos(&tempPOint);
mnuPopupMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,thread->point.x,thread->point.y,  thread->_this);
        }
        showWindow = true;
    }

推荐答案


这篇关于如何在Afxbeginthread的指定函数中打开上下文菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 21:51