(WM_NCLBUTTONDOWN)有什么作用?

发布于 2024-12-25 17:40:35 字数 317 浏览 0 评论 0原文

我正在研究如何在 Visual Basic 6 中制作圆形形状的示例,然后我停在代码处: 公共常量 WM_NCLBUTTONDOWN = &HA1 我只知道这是作为 Const 传递给 Windows 的消息...

我想知道的是:

  • &HA1 是什么?

  • Const WM_NCLBUTTONDOWN 的作用是什么?它向 Windows 发送什么消息?

  • 有关它的任何其他信息。

拜托,谢谢

i was studying the example of how to make round-shape form in Visual Basic 6, and i stopped at the code :
Public Const WM_NCLBUTTONDOWN = &HA1
I only know that this is a message to the windows passed as Const ...

What i want to know is :

  • what is &HA1 ?

  • what does Const WM_NCLBUTTONDOWN do ? what message does it send to Windows ?

  • anything else about it .

Please, thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

蓝咒 2025-01-01 17:40:35

您正在使用 Windows 发送到窗口的消息来告诉您的代码发生了一些有趣的事情。您会发现该常量用在表单的 WndProc() 方法中,该方法在 Windows 发送消息时运行。

WM_NCLBUTTONDOWN 消息就是其中之一。 WM = 窗口消息。 NC = 非客户端,窗口中不属于客户端区域、边框和标题栏的部分。 L=左键,可以算出BUTTONDOWN。

这些消息在 Windows SDK 文件中声明。你的机器上会有它,该文件的 VS2008 版本位于 C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include\WinUser.h。用文本编辑器或者VS打开它,看看里面有什么。搜索消息标识符以找到此行:

 #define WM_NCLBUTTONDOWN                0x00A1

Windows SDK 是为使用 C 程序而编写的。 #define 相当于 VB.NET 中的 Const。 0x 前缀在 C 语言中表示“十六进制”,就像 VB.NET 中的 &H 一样。 Windows 计算器有助于将十六进制值转换为十进制值并返回,使用 View + Programmer。您将看到在 VB.NET 程序中使用 &H 的原因,这些常量在核心声明中以十六进制开头。但是 Private Const WM_NCLBUTTONDOWN = 161 也同样有效 (10 x 16 + 1)。

因此,在 WndProc() 中,您可以使用 Select Case 或 If 语句来检测消息。当用户在窗口标题栏上单击鼠标左键时,您可以执行一些特殊操作。如果忽略它,则 MyBase.WndProc(m) 运行并发生正常的事情:Windows 启动一个模态循环,让用户移动窗口。实际上,您想要停止或更改该行为的情况很少,用户非常喜欢这种默认行为,因为 Windows 中的所有窗口都是如此。您通常想要自定义其行为的唯一消息是 WM_NCHITTEST。对于提供无边框窗口类似边框的行为非常有用。但那是另一个故事了。

You are working with messages that Windows sends to a window to tell your code that something interesting happened. You'll find this constant used in the WndProc() method of a form, the method that runs when Windows sends a message.

The WM_NCLBUTTONDOWN message is one of those messages. WM = Window Message. NC = Non Client, the part of the window that's not the client area, the borders and the title bar. L = Left button, you can figure out BUTTONDOWN.

These messages are declared in a Windows SDK file. You'll have it on your machine, the VS2008 version of that file is located in C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include\WinUser.h. Open it with a text editor or VS to see what's inside. Search for the message identifier to find this line:

 #define WM_NCLBUTTONDOWN                0x00A1

The Windows SDK was written to work with C programs. #define is equivalent to Const in VB.NET. The 0x prefix means 'hexadecimal' in the C language, just like &H does in VB.NET. The Windows calculator is helpful to convert hexadecimal values to decimal and back, use View + Programmer. You'll see the reason that &H is used in a VB.NET program, these constants started out in hexadecimal in the core declaration. But Private Const WM_NCLBUTTONDOWN = 161 will work just as well (10 x 16 + 1).

So within WndProc() you'd use a Select Case or If statement to detect the message. And you can do something special when the user clicks the left mouse button on the window title bar. If you ignore it then MyBase.WndProc(m) runs and the normal thing happens: Windows starts a modal loop that lets the user move the window. It is actually very rare that you want to stop or alter that behavior, users are pretty fond of that default behavior since all windows in Windows behave that way. The only message whose behavior you'd typically want to customize is WM_NCHITTEST. Very useful to give a borderless window border-like behavior. But that's another story.

╰ゝ天使的微笑 2025-01-01 17:40:35
  • 这是一个十六进制整数文字

  • 它声明了一个常量;它实际上没有做任何事情。
    WM_NCLBUTTONDOWN message当用户在光标位于窗口的非工作区时按下鼠标左键时发布消息。该消息被发布到包含光标的窗口

  • That's a hexadecimal integer literal

  • It declares a constant; it doesn't actually do anything.
    The WM_NCLBUTTONDOWN message is posted when the user presses the left mouse button while the cursor is within the nonclient area of a window. This message is posted to the window that contains the cursor

对你的占有欲 2025-01-01 17:40:35
  • &HA1 表示十六进制数字A1,即161(尽管您通常会看到以十六进制表示的 Windows 消息常量)。更常见的是,您会将其视为 0xA1(或 0x00A1),因为这就是十六进制数字在 C 或 C++ 中的表示方式(Windows API 最初是为 C 编写的) 。
  • 您不会向 Windows 发送 WM_NCLBUTTONDOWN;恰恰相反。 Windows 将向您发送 WM_NCLBUTTONDOWN

如果您想了解 WM_NCLBUTTONDOWN 的用途,请参阅文档只需网络搜索即可。

  • &HA1 means the hexadecimal number A1, i.e., 161 (though you'll usually see Windows message constants represented in hex). More commonly you'll see this as 0xA1 (or 0x00A1) since that's how the hex number would be represented in C or C++ (the Windows API was originally written for C).
  • You won't be sending WM_NCLBUTTONDOWN to Windows; it's the other way around. Windows will be sending you WM_NCLBUTTONDOWN.

If you want to know what WM_NCLBUTTONDOWN is for, the documentation is just a Web-search away.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文