问题描述
在Win32编程中,窗口的父级和窗口的所有者之间有什么区别?我以为知道了,然后遇到了这段代码:
In Win32 programming, what is the difference between a window's parent and a window's owner? I thought I had it figured out, then I came across this code:
SetWindowLong(handle, GWL_HWNDPARENT, foo);
这实际上设置了窗口的所有者,而不是父窗口-尽管使用了GWL_HWNDPARENT.父母/所有者这两个术语可以互换吗,或者实际上有区别吗?
This actually sets the window's owner, not the parent - despite the GWL_HWNDPARENT being used. Are the terms parent/owner interchangeable, or is there actually a difference?
推荐答案
所有者是负责控件或对话框的Window *(例如,负责创建/销毁窗口).
Owner is the Window* responsible for a control or dialog (for example, responsible for creating/destroying the window).
父级是窗口链中控件或对话框的下一个高级窗口*,但实际上并不对其负责(不必关心其生命周期等).窗口的父级也可以是其所有者.
Parent is the next-senior window* to a control or dialog in the window chain, but isn't actually responsible for it (doesn't necessarily care about its lifecycle, etc). A window's parent can also be its owner.
*窗口与窗口:窗口是显示在屏幕上的实际窗口;窗口是具有HWND的任何对象(包括按钮,面板等).
*Window vs window: Window is an actual window displayed on the screen; window is any object with a HWND (includes buttons, panels, etc).
这篇关于Win32窗口所有者vs窗口父级?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!