如何从线程创建对话框 [英] How to create a dialog from thread

查看:126
本文介绍了如何从线程创建对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,

我是VC ++环境的新手.在这里,我的工作是从线程创建一个对话框并将其绘制到子对话框上.我在这里发布一个伪代码.

在文件Sched.cpp

Hello Friends,

I am new to VC++ environment. Here my job was to create a dialog from the thread and to be plotted on to the child dialog. Here I''m posting a pseudo code.

In file Sched.cpp

extern CPaint *m_dlg;
void CSched:: Minor()
{
   CWinThread *pThread = NULL;
   pThread = AfxBeginThread((AFX_THREADPROC)CallGraph,NULL);
   if(pThread == NULL)
      MessageBox("Thread Fails");
}

UINT CShed::CallGraph(LPVOID pParam) 
{
   m_dlg -> StartGraph();
   return TRUE;
}



在另一个文件Paint.cpp



In another file Paint.cpp

void CPaint::StartGraph()
{
   CPaint *m_dlg;
   m_dlg = new CPaint();
   m_dlg->Create(IDD_PAINT_DLG,NULL);
   m_dlg->ShowWindow(SW_SHOW);
}



请尽可能尽快回复.我没有在此代码中遇到什么错误,但是我确定程序正在编译并且创建了线程并且未创建对话框.

预先谢谢您.



Please reply as soon as possible. I am not getting what mistake is there in this code but I am sure that the program is compiling and thread is created and dialog is not created.

Thank you in advance

推荐答案

对不起,我说的是明显的出血,但是您的程序中是否有消息循环?
Excuse me for stating the bleeding obvious, but do you have a message loop somewhere in your program?


请阅读WTL中的多线程GUI源代码.
Please read the multithread GUI source code within WTL。


同意艾伯特的意见,您无法在线程中创建无模式对话框,该对话框在创建对话框后终止!
Agreed with albert, you can''t have modeless dialog box within thread which is terminating after creation of dialog!


这篇关于如何从线程创建对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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