新开线程能否拥有自己的对话框?

hailiang 2000-07-17 09:03:00
我想开个线程并显示一个对话框而和主程序并行运行,不知道可不可以,谁能告诉我?
准确一点哦
...全文
143 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
bird2000 2000-07-21
  • 打赏
  • 举报
回复
一个程序两个消息循环有意义吗?

大家探讨!
wwqbj 2000-07-17
  • 打赏
  • 举报
回复
创建一个CWinThread的继承类,eg. MyUI;
在其InitInstance中填写UI代码

如下:

BOOL MyUI:InitInstance()
{

......
CMyDlg* Dlg = New CMyDlg;
Dlg->Create(...);
Dlg->UpdateWindow()
Dlg->ShowWindow();
m_pMainWnd = dlg; /// 这一行很重要
......

}


在住程序中调用

void CallDlg()
{
AfxBeginThread((RUNTIME_CLASS)CMyUI,...);

}
hailiang 2000-07-17
  • 打赏
  • 举报
回复
谢谢大家关心:
谁能告诉我创建两种线程的异同?怎样才能创建基于UI的线程?
tomorrowdreamer 2000-07-17
  • 打赏
  • 举报
回复
谁说一个进程只能有一个UI线程?
不要误导群众。
在vc中有两种线程:UI线程和worker线程。UI线程有消息循环,当然有窗口?worker线程
没有消息循环,一般用于后台计算,子能显示模态对话框
茂奇软件 2000-07-17
  • 打赏
  • 举报
回复
there are two kind of thread in the windows,
working thread and GUI thread. In a process,
there is only one GUI thread can exist.
You will meet some trouble, if you use window
resource handle cross the thread directly.
My advice is that the working thread can send
message to the windows main loop. and the GUI
thread do the action according the message.

Jansen Zhu.
net_worm 2000-07-17
  • 打赏
  • 举报
回复
当然可以哦,你可以使用主窗口句柄,用AfxGetMainWnd()的到,也可以传入窗口句柄。

15,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧