WS_CLIPCHILDREN與WS_CLIPSIBLINGS(轉載)

英文單詞解釋
clip:夾子、子彈夾、回形針;夾住,修剪
sibling:同胞兄弟或姐妹
overlapped:重疊

這兩個Window Stype的特性與異同素來不太清楚,今日作一筆記:
MSDN的解釋爲:
WS_CLIPCHILDREN   Excludes the area occupied by child windows when you draw within the parent window. Used when you create the parent window.

WS_CLIPSIBLINGS   Clips child windows relative to each other; that is, when a particular child window receives a paint message, the WS_CLIPSIBLINGS style clips all other overlapped child windows out of the region of the child window to be updated. (If WS_CLIPSIBLINGS is not given and child windows overlap, when you draw within the client area of a child window, it is possible to draw within the client area of a neighboring child window.) For use with the WS_CHILD style only. 

此處另有一文的解釋爲:
 
JohnCz
06-27-2006, 09:40 PM
It is not a property per se.
WS_xxx are Window styles. Both clip of area of other window when window overlaps another window.
Clip sibling for example will cause MDI child window to paint itself over another child window (sibling) when overlapped. The same will happen 

WS_CLIPCHILDREN will do exactly the same when parent overlaps child window.

綜上所述
WS_CLIPCHILDREN,使得父窗體在繪製時留出其上的子窗體的位置不去畫它,而那片區域留着子窗體去畫。
WS_CLIPSIBLING,必須用於子窗體,使得該子窗體在收到WM_PAINT時同時令其共父的諸多子窗體(MSDN講必須不在該區域,即不與之重疊)也會被PAINT。

//下面也是對WS_CLIPSIBLINGS的理解
所有的overlapped窗口和popup窗口,都有WS_CLIPSIBLINGS 屬性,
這些窗口不能在它的sibling窗口上繪圖

對於child窗口,如果沒有這個屬性,它能在它的sibling窗口上繪圖

                 +-----------+
                  |A             |
                  |   +--------+-------
                  |   |            |     B |
                  |   |  C        |        |
                 +---+-------+       |
                      |                    |
                      +---------------+
如果A, B都是child窗口,
如果A具有WS_CLIPSIBLINGS屬性,
那麼A重繪時不會重繪C部分

clip是裁減,去除的意思 相當與英文的Exclude

個人理解:WS_CLIPCHILDREN和WS_CLIPSIBLING都是爲了減少重畫,減少閃動,保證窗口的重疊部分只有一個窗口來實現PAINT。

轉自:http://blog.163.com/sandylin_wind/blog/static/935500552008105104617806/

發佈了18 篇原創文章 · 獲贊 27 · 訪問量 20萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章