父GUI对话框线程的子线程可以创建子窗口吗? [英] Can a child thread of parent GUI dialog thread create a child window?

查看:134
本文介绍了父GUI对话框线程的子线程可以创建子窗口吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以从辅助子线程创建子窗口,还是必须从GUI线程创建子窗口?假设子线程的生命周期是直到程序结束.

Can you create a child window from a secondary child thread or it must be created from GUI thread? Assuming the life time of child thread is until the end of program.

推荐答案

与其他操作系统不同,Windows中的每个线程都可以承载自己的消息泵,因此也可以承载Windows.

Unlike other operating systems, each thread in windows can host its own message pump, and thus windows.

必须小心,因为子窗口需要与其父窗口进行同步通信-因此,在调用可能会导致发送SendMessage的窗口API时,您必须注意确保两个线程都没有持有关键部分或同步对象.将使线程死锁.

Care must be taken as child windows need to communicate synchronously with their parent - so you must take care to ensure that neither thread holds a critical section or synchronous object while calling an window API that could result in a SendMessage being sent - this WILL deadlock the threads.

这篇关于父GUI对话框线程的子线程可以创建子窗口吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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