我将在C#程序中使用WM_KEYDOWN和其他WM_消息。这些常量是在某处定义的还是应该在每个程序中手动定义?
答案 0 :(得分:3)
答案 1 :(得分:2)
答案 2 :(得分:2)
因为这些常量是在winapi库中定义的而不是.net,所以你需要在某处自己重新创建它们。使用这些常量的函数也在winapi中定义,因此您需要使用interop在应用程序中使用它们。 http://www.pinvoke.net/是一个很好的资源,用于对这些winapi常量和函数的互操作版本进行原型设计。
答案 3 :(得分:1)
大多数都可以在这里找到: 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,
...