Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WM#U KEYDOWN常量是否在C#程序集中定义?_C#_Windows_Constants_Messaging_Using - Fatal编程技术网

WM#U KEYDOWN常量是否在C#程序集中定义?

WM#U KEYDOWN常量是否在C#程序集中定义?,c#,windows,constants,messaging,using,C#,Windows,Constants,Messaging,Using,我将在C程序中使用WM#KEYDOWN和其他WM#消息。这些常量是在某个地方定义的还是应该在每个程序中手动定义?大多数常量可以在这里找到: 来自该页面的代码片段: /// <summary> /// Windows Messages /// Defined in winuser.h from Windows SDK v6.1 /// Documentation pulled from MSDN. /// </summary> public enum

我将在C程序中使用WM#KEYDOWN和其他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,
    ...
//
///Windows消息
///在Windows SDK v6.1的winuser.h中定义
///从MSDN中提取的文档。
/// 
公共枚举WM:uint
{
/// 
///WM_NULL消息不执行任何操作。如果应用程序希望发布收件人窗口将忽略的消息,则会发送WM_NULL消息。
/// 
NULL=0x0000,
/// 
///当应用程序通过调用CreateWindowEx或CreateWindow函数请求创建窗口时,会发送WM_CREATE消息。(该消息在函数返回之前发送。)新窗口的窗口过程在创建窗口后但窗口变为可见之前接收该消息。
/// 
CREATE=0x0001,
/// 
///WM_DESTROY消息在销毁窗口时发送。从屏幕上删除窗口后,它将发送到销毁窗口的窗口过程。
///此消息首先发送到要销毁的窗口,然后发送到被销毁的子窗口(如果有)。在处理该消息的过程中,可以假定所有子窗口仍然存在。
/// /// 
销毁=0x0002,
...
不,它们不是


您应该手动定义它们。您可以在PInvoke.Net网站中搜索它们的值。例如,可以在此处找到WM常量


使用此网站,您可以创建(适用于VB.NET和C#)只需要程序所需的常量。

因为这些常量是在winapi库中定义的,而不是在.net中定义的,所以您需要自己在某个地方重新创建它们。使用这些常量的函数也在winapi中定义,因此您需要使用interop在应用程序中使用它们。这是一个很好的资源,可用于输入i这些winapi常量和函数的Interop版本。

是的,它们在任何地方都有定义,但它们都是内部的。所以您必须这样做。请看