WM_LBUTTONDOWN
The WM_LBUTTONDOWN message is posted when the user presses the left mouse button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor. Otherwise, the message is posted to the window that has captured the mouse. A window receives this message through its WindowProc function. LRESULT CALLBACK WindowProc(
  HWND hwnd,       // handle to window
  UINT uMsg,       // WM_LBUTTONDOWN
  WPARAM wParam,   // key indicator
  LPARAM lParam    // horizontal and vertical position
);
Parameters
wParam 
Indicates whether various virtual keys are down. This parameter can be one or more of the following values. Value Description 
MK_CONTROL The CTRL key is down. 
MK_LBUTTON The left mouse button is down. 
MK_MBUTTON The middle mouse button is down. 
MK_RBUTTON The right mouse button is down. 
MK_SHIFT The SHIFT key is down. 
MK_XBUTTON1 Windows 2000: The first X button is down. 
MK_XBUTTON2 Windows 2000: The second X button is down. 
lParam 
The low-order word specifies the x-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area. 
The high-order word specifies the y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area. Return Values
If an application processes this message, it should return zero. Res
Use the following code to obtain the horizontal and vertical position:xPos = GET_X_LPARAM(lParam); 
yPos = GET_Y_LPARAM(lParam); 
You can also use the MAKEPOINTS macro to convert the lParam parameter to a POINTS structure. To detect that the ALT key was pressed, check whether GetKeyState(VK_MENU) < 0. Note, this must not be GetAsyncKeyState.Requirements 
  Windows NT/2000: Requires Windows NT 3.1 or later.
  Windows 95/98: Requires Windows 95 or later.
  Header: Declared in Winuser.h; include Windows.h.

解决方案 »

  1.   

    WM_LBUTTONDOWN fwKeys = wParam; xPos = LOWORD(lParam); 
    yPos = HIWORD(lParam);
    fwKeys 
    Indicates whether various virtual keys are down. It is any combination of the following values: MK_CONTROL Set if the CTRL key is down. 
    MK_LBUTTON Set if the left mouse button is down. 
    MK_SHIFT   Set if the SHIFT key is down. 
      

  2.   

    两位楼上:
     老兄现在遇到的问题是这样的:
        当我在 Form 上放一个Button 或 其他控件,当鼠标放在这些控件上都可得到控件的名字
    而当把几个控件放在 panel上,当鼠标放在控件上,就不能得到panel上的控件名字