哪些外部事件触发TCustomForm.RecreateWnd? [英] What external events trigger TCustomForm.RecreateWnd?

查看:91
本文介绍了哪些外部事件触发TCustomForm.RecreateWnd?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个特定的VCL应用程序崩溃,很少,而且显然是自发的,我强烈怀疑这是因为正在响应操作系统的某些外部触发而重新创建主窗体的窗口句柄。

A particular VCL application is crashing, rarely, and apparently spontaneously, and I strongly suspect it is because the main form's window handle is being recreated in response to some external trigger from the operating system.

我确实知道,如果 主窗体的窗口句柄发生更改,那么肯定会出现麻烦(因为后台线程将消息发送到此句柄)。

I do know for certain that if the main form's window handle were to change then trouble would certainly follow (because background threads post messages to this handle).

但是我想在着手进行代码更改以修复该错误之前知道如何重现此错误,如果仅是这样,那么我可以确认这是导致崩溃的合理原因,症状与报告的症状相符,并且代码更改确实可以解决问题。 (另外,如果操作系统无法触发对 TCustomForm.RecreateWnd 的调用,我还需要找到其他有关崩溃的解释。是的,我可以发布 CM_RECREATEWND 到主表单,但这只是一个问题。)

But I would like to know how to reproduce this bug before I set about making code changes intended to fix it, if only so I can confirm that this is a plausible cause of the crashes, that the symptoms match those reported, and that the code changes do indeed fix it. (Also if there is no way the OS can trigger a call to TCustomForm.RecreateWnd I need to find some other explanation for the crashes. Yes, I could post CM_RECREATEWND to the main form but that just begs the question.)

(我知道从后台发布消息的正确方法到VCL线程的所有线程都是纯粹使用 AllocateHWnd 创建隐藏消息窗口的-这是我建议的解决方法。)

(I am aware that the correct way to post messages from background threads to the VCL thread is to create a hidden message window purely for this purpose using AllocateHWnd - that is my proposed fix.)

我看到类似的错误,后代是 TCustomListView ,其中通过更改桌面触发了 RecreateWnd Windows XP Windows Classic 的样式。但是我还没有找到在 TCustomForm 上触发 RecreateWnd 的方法。 (我花了相当多的时间来阅读VCL代码,我肯定会丢失一些东西。)

I have seen a similar error with a descendent of TCustomListView where RecreateWnd was being triggered by changing the desktop style from Windows XP to Windows Classic. But I haven't been able yet to find such a method to trigger RecreateWnd on a TCustomForm. (I've spent a considerable amount of time reading through the VCL code and I must be missing something.)

摘要:

在操作系统的刺激下,VCL最终在 TCustomForm上调用 RecreateWnd ? (如果对Windows 7有所帮助,我特别感兴趣。)

Under what stimuli from the operating system does the VCL end up calling RecreateWnd on a TCustomForm? (I'm especially interested in Windows 7 if that makes a difference.)

如果操作系统有这种刺激,我可以证明它是否引起了所观察到的症状。如果没有,那么我可以证明不是造成窗口重新创建的原因。

If there is such a stimulus from the OS, I can prove whether it causes the observed symptoms. If there definitively isn't then I can prove window recreation isn't the cause.

推荐答案

Windows会销毁您的表单

Windows will destroy your form if it is owned or parented to another window that is being destroyed.

这将导致表单句柄被破坏。

That will cause your form's handle to be destroyed.

但是由于您的表单仍然存在,Delphi将在下一次重新创建句柄。

But since your form is still around, Delphi will re-create the handle the next time.

这篇关于哪些外部事件触发TCustomForm.RecreateWnd?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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