程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> .NET實例教程 >> 關於窗口的Parent&Child關系與Owner&Owned關系

關於窗口的Parent&Child關系與Owner&Owned關系

編輯:.NET實例教程

先說明一下兩個窗口是Parent&Child關系或是Owner&Owned關系會對他們有些什麼影響(摘自MSDN

Parent&Child

               If an application creates a child window that is larger than the parent window or positions a child window so that some or all of the child window extends beyond the borders of the parent, the system clips the child window

Parent Window

Child Window

Destroyed

Destroyed before the parent window is destroyed.

Hidden

Hidden before the parent window is hidden. A child window is visible only when the parent window is visible.

Moved

Moved with the parent window''s client area. The child window is responsible for painting its clIEnt area after the move.

Shown

Shown after the parent window is shown.

 

Owner&Owned

       An owned window is always above its owner in the z-order.

       The system automatically destroys an owned window when its owner is destroyed.

       An owned window is hidden when its owner is minimized.

 

 

假設有hwnd1hwnd2兩個窗口,如果他們要滿足Parent&Child關系,即hwnd2hwnd1的子窗口,在創建Child的時候必須指定hwnd2WS_CHILD屬性。然後要麼在創建hwnd2到時候指定其parenthwnd1,或者在創建好hwnd2 後,通過SetParent指定hwnd1為其父窗口。

如果hwnd2沒有WS_CHILD屬性,僅僅通過調用SetParent指定其父窗口為hwnd1,那麼只會將hwnd2成為hwnd1事實上的子窗口,但並不改變他們名義上的關系(甚至都不會讓hwnd1成為hwnd2Owner),即hwnd2的父窗口仍可能為NULL,而且hwnd2仍是Top-Level window

如果hwnd2沒有WS_CHILD屬性,但CreateWindow的時候指定了其Parent參數為hwnd1,那麼hwnd1將會成為hwnd2Owner window,他們的關系就變成了Owner&&Owned關系。得到hwnd2Owner,可以通過用GW_OWNER參數調用GetWindow得到。

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved