How do I make form or windowed control RecreateWnd-aware properly?

白昼怎懂夜的黑 提交于 2019-11-30 07:59:31
Remy Lebeau

Override CreateWnd() and DestroyWnd() in most situations. Override DestroyWnd() to do window unregistrations, temporarily save any window-dependent data if the csRecreating flag is present in the ControlState property, and call the inherited DestroyWnd() (which calls DestroyWindowHandle()) to destroy the HWND. Override CreateWnd() to call the inherited CreateWnd() (which calls CreateWindowHandle()) to create the HWND, load and discard temporary window-dependent data if any was previously saved, and do window registrations.

Override CreateWindowHandle() and DestroyWindowHandle() when you need to obtain/free an HWND through other means than normal Win32 CreateWindow/Ex() and DestroyWindow() calls. For example, TForm overrides these to create/free MDI child windows by sending WM_MDICREATE and WM_MDIDESTROY messages to its ClientHandle window.

I have never seen CreateHandle() and DestroyHandle() overridden for anything useful.

See this discussion for more details:

What's the difference between CreateWnd and CreateWindowHandle?

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!