开发者

Getting window style

开发者 https://www.devze.com 2022-12-28 02:33 出处:网络
I\'m trying to check if a window has a certain style using GetWindowLong(hWnd, GWL_STYLE) but that gives me a LONG type of variable. how would you check for a specific style from 开发者_开发知识库that

I'm trying to check if a window has a certain style using GetWindowLong(hWnd, GWL_STYLE) but that gives me a LONG type of variable. how would you check for a specific style from 开发者_开发知识库that say a const value type 'WS_CAPTION'?


use the bitwise & operator to compare with that long type,

example

if (szLng & WS_CAPTION){
    // that window has caption
}


Most of the window styles WS_ are single-bit values; that is each of them occupies only one bit in dwStyles.

Here dwStyles can be obtained from: DWORD dwStyles = CWnd::GetStyle();

But some of the WS_ styles, such as WS_CAPTION, WS_OVERLAPPEDWINDOW, WS_POPUPWINDOW, combine a few single-bit styles.

The test code below is OK for single-bit window styles but not OK for combined styles.

DWORD dwSomeStyle = WS_... ;
BOOL bSomeStyleIsPresentForThisWnd;

if (dwStyles & dwSomeStyle)
  bSomeStyleIsPresentForThisWnd = TRUE;
else
  bSomeStyleIsPresentForThisWnd = FALSE;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号