获取窗口样式
我正在尝试使用 GetWindowLong(hWnd, GWL_STYLE) 检查窗口是否具有某种样式,但这给了我一个 LONG 类型的变量。您将如何检查常量值类型“WS_CAPTION”中的特定样式?
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'?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用按位 &与该 long 类型进行比较的运算符,
例如
use the bitwise & operator to compare with that long type,
example
大多数窗口样式 WS_ 都是单位值;
也就是说,它们在 dwStyles 中只占一位。
这里
dwStyles
可以通过以下方式获得:DWORD dwStyles = CWnd::GetStyle();
但是有些WS_样式,如
WS_CAPTION
,<代码>WS_OVERLAPPEDWINDOW,WS_POPUPWINDOW
,组合了一些单位样式。下面的测试代码适用于单位窗口样式
但对于组合样式则不
OK
。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.