GetWindowLong返回值的位定义 [英] The bit definition of return value from GetWindowLong

查看:203
本文介绍了GetWindowLong返回值的位定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个窗口表单,我想知道鼠标按钮的状态,

我在下面声明相关功能:

I am writing a window form, I would like to know the mouse button state,

I declare the related function below :

const long WS_VSCROLL = 0x 00100000L; 

[DllImport("user32.dll")]
public static extern int GetWindowLong(IntPtr hWnd, int nIndex);
long CheckState()
{
  long windowStyle;
  windowStyle = GetWindowLong(this.Handle, -16);
  return (windowStyle & WS_VSCROLL );
}



因此,当我从CheckState获得返回值时,我可以知道垂直滚动状态.

现在的问题是:
任何机构都可以提供wendowStyle的所有详细信息位定义",例如WS_VSCROLL吗?特别是鼠标左键.谢谢.



so when I get the return value from CheckState, I can know the vertical scroll state.

The question now is :
Can any body provide all detail ''bit definition'' of wendowStyle, such as WS_VSCROLL ? Especially of the mouse left button. Thanks.

推荐答案

我不知道您会错过什么. MSDN帮助在此问题上看起来一目了然.用你的方法CheckState只能返回两个值.值0表示:窗口hWnd没有垂直滚动条,否则有一个".与鼠标无关.

阅读(再次?):
http://msdn.microsoft.com/zh-我们/library/windows/desktop/ms633584%28v=vs.85%29.aspx [ http://msdn.microsoft.com/zh-我们/library/windows/desktop/ms632600%28v=vs.85%29.aspx [
I don''t know what could you miss. The MSDN help looks crystal-clear about this matter. Take your method CheckState can return only two values. The value of 0 means: "the window hWnd does not have a vertical scroll bar, otherwise it has one". It has nothing to do with your mouse.

Read (again?):
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633584%28v=vs.85%29.aspx[^],
http://msdn.microsoft.com/en-us/library/windows/desktop/ms632600%28v=vs.85%29.aspx[^].

Hey, don''t hard-code -16, etc. Write some explicit constant for GWL_STYLE. Even better way to code such constant is enumeration type. No cast needed. Just replace your int with enumeration type(s) in your P/Invoked functions.

One more thing: using Windows API P/Invoke it practically not needed in .NET Forms. You usually can do everything in pure .NET and keep your assembly portable; exclusions are very rare.

—SA


这篇关于GetWindowLong返回值的位定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆