我将在C#程序中使用WM_KEYDOWN和其他WM_消息。 这些常量是在某个地方定义的,还是应该在每个程序中手动定义的?
因为这些常量是在winapi库中定义的,而不是.net,你需要自己重新创建它们。 使用这些常量的函数也在winapi中定义,所以您需要使用interop在应用程序中使用它们。 http://www.pinvoke.net/是一个很好的资源来处理这些winapi常量和函数的互操作版本。
不,他们不是。
但是,这里有一个方便的枚举,供您参考
过去我曾经使用这个小工具。 我仍然认为这是有用的
PInvoke互操作助手
使用这个工具,你可以生成(对于VB.NET和C#)只是你的程序需要的常量。
他们大多可以在这里找到: http : //www.pinvoke.net/default.aspx/Constants.WM
该页面的代码片段:
/// <summary> /// Windows Messages /// Defined in winuser.h from Windows SDK v6.1 /// Documentation pulled from MSDN. /// </summary> public enum WM : uint { /// <summary> /// The WM_NULL message performs no operation. An application sends the WM_NULL message if it wants to post a message that the recipient window will ignore. /// </summary> NULL = 0x0000, /// <summary> /// The WM_CREATE message is sent when an application requests that a window be created by calling the CreateWindowEx or CreateWindow function. (The message is sent before the function returns.) The window procedure of the new window receives this message after the window is created, but before the window becomes visible. /// </summary> CREATE = 0x0001, /// <summary> /// The WM_DESTROY message is sent when a window is being destroyed. It is sent to the window procedure of the window being destroyed after the window is removed from the screen. /// This message is sent first to the window being destroyed and then to the child windows (if any) as they are destroyed. During the processing of the message, it can be assumed that all child windows still exist. /// /// </summary> DESTROY = 0x0002, ...