如何在Afxbeginthread的指定函数中打开上下文菜单? [英] How Can I Open Context Menu In Afxbeginthread's Specified Function?

查看:96
本文介绍了如何在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;
    }

推荐答案

这是否适用于打开ContextMenu?
Is That works for opening ContextMenu ??


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆