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
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:
The Windows SDK was written to work with C programs. #define is equivalent to Const in VB.NET. The
0xprefix 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. ButPrivate Const WM_NCLBUTTONDOWN = 161will 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.