urgent ......anyone know this Mouse_event( )? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

urgent ......anyone know this Mouse_event( )?

Hi!
Anyone know how to use this

[code]
VOID mouse_event(
DWORD dwFlags, // motion and click options
DWORD dx, // horizontal position or change
DWORD dy, // vertical position or change
DWORD dwData, // wheel movement
ULONG_PTR dwExtraInfo // application-defined information
);

[/code]

How to use this function in the program , what is the function of this mouse_event?
Can I use straight without declare in my program?

Example Like this:

[code]

void CMouseHandling::check_mouse(){
.........

........
mouse_event(MOUSEEVENTF_ABSOLUTE, dx, dy, 0, NULL);

m_nmouse_x= dx;
m_nmouse_y=dy;

if(m_nmouse_y <0)
return true;

........
........

}
[/code]

And the last question I wanna ask is about this parameter (ULONG_PTR dwExtraInfo )if I don't have any extraInfo, what should I put in this place? Can I just put a NULL on it??


thank you!!!


cheers
airwinx

Comments

  • DariusDarius Posts: 1,666Member
    : Hi!
    : Anyone know how to use this
    :
    : [code]
    : VOID mouse_event(
    : DWORD dwFlags, // motion and click options
    : DWORD dx, // horizontal position or change
    : DWORD dy, // vertical position or change
    : DWORD dwData, // wheel movement
    : ULONG_PTR dwExtraInfo // application-defined information
    : );
    :
    : [/code]
    :
    : How to use this function in the program , what is the function of this mouse_event?
    : Can I use straight without declare in my program?
    :
    : Example Like this:
    :
    : [code]
    :
    : void CMouseHandling::check_mouse(){
    : .........
    :
    : ........
    : mouse_event(MOUSEEVENTF_ABSOLUTE, dx, dy, 0, NULL);
    :
    : m_nmouse_x= dx;
    : m_nmouse_y=dy;
    :
    : if(m_nmouse_y <0)
    : return true;
    :
    : ........
    : ........
    :
    : }
    : [/code]
    :
    : And the last question I wanna ask is about this parameter (ULONG_PTR dwExtraInfo )if I don't have any extraInfo, what should I put in this place? Can I just put a NULL on it??
    :
    :
    : thank you!!!
    :
    :
    : cheers
    : airwinx
    :
    :

    It's a normal function, you need to do the same things you would do for any function. So, yes it has to be declared, but it is declared when you include windows.h, just like every other WinAPI function. It synthesizes a mouse_event, ie when you call the function the computer acts like you actually did what you describe with the parameters (or at least your program does). Passing NULL for the extra info would make sense if you don't have any extra info, however it's not a pointer, it's simply a DWORD. You can treat it as a pointer if you'd like though. Anyways, here's the information from Borland's Win32.hlp file on this function...

    The mouse_event function synthesizes mouse motion and button clicks.

    VOID mouse_event(

    DWORD dwFlags, // flags specifying various motion/click variants
    DWORD dx, // horizontal mouse position or position change
    DWORD dy, // vertical mouse position or position change
    DWORD cButtons, // unused, reserved for future use, set to zero
    DWORD dwExtraInfo // 32 bits of application-defined information
    );
    Parameters

    dwFlags

    A set of flag bits that specify various aspects of mouse motion and button clicking. The bits in this parameter can be any reasonable combination of the following values:

    Value Meaning
    MOUSEEVENTF_ABSOLUTE Specifies that the dx and dy parameters contain normalized absolute coordinates. If not set, those parameters contain relative data: the change in position since the last reported position. This flag can be set, or not set, regardless of what kind of mouse or mouse-like device, if any, is connected to the system. For further information about relative mouse motion, see the following Remarks section.
    MOUSEEVENTF_MOVE Specifies that movement occurred.
    MOUSEEVENTF_LEFTDOWN Specifies that the left button changed to down.
    MOUSEEVENTF_LEFTUP Specifies that the left button changed to up.
    MOUSEEVENTF_RIGHTDOWN Specifies that the right button changed to down.
    MOUSEEVENTF_RIGHTUP Specifies that the right button changed to up.
    MOUSEEVENTF_MIDDLEDOWN Specifies that the middle button changed to down.
    MOUSEEVENTF_MIDDLEUP Specifies that the middle button changed to up.
    The flag bits that specify mouse button status are set to indicate changes in status, not ongoing conditions. For example, if the left mouse button is pressed and held down, MOUSEEVENTF_LEFTDOWN is set when the left button is first pressed, but not for subsequent motions. Similarly, MOUSEEVENTF_LEFTUP is set only when the button is first released.

    dx

    Specifies the mouse's absolute position along the x-axis or its amount of motion since the last mouse event was generated, depending on the setting of MOUSEEVENTF_ABSOLUTE. Absolute data is given as the mouse's actual x-coordinate; relative data is given as the number of mickeys moved.

    dy

    Specifies the mouse's absolute position along the y-axis or its amount of motion since the last mouse event was generated, depending on the setting of MOUSEEVENTF_ABSOLUTE. Absolute data is given as the mouse's actual y-coordinate; relative data is given as the number of mickeys moved.

    cButtons

    This parameter is currently unused. It is reserved for future use. It must be set to zero.

    dwExtraInfo

    Specifies an additional 32-bit value associated with the mouse event. An application calls GetMessageExtraInfo to obtain this extra information.

    Return Value

    This function has no return value.

    Remarks

    If the mouse has moved, indicated by MOUSEEVENTF_MOVE being set, dx and dy hold information about that motion. The information is given as absolute or relative integer values.
    If MOUSEEVENTF_ABSOLUTE value is specified, dx and dy contain normalized absolute coordinates between 0 and 65,535. The event procedure maps these coordinates onto the display surface. Coordinate (0,0) maps onto the upper-left corner of the display surface, (65535,65535) maps onto the lower-right corner.

    If the MOUSEEVENTF_ABSOLUTE value is not specified, dx and dy specify relative motions from when the last mouse event was generated (the last reported position). Positive values mean the mouse moved right (or down); negative values mean the mouse moved left (or up).
    Relative mouse motion is subject to the effects of the mouse speed and the two mouse threshold values. An end user sets these three values with the Mouse Tracking Speed slider of Control Panel's Mouse option. An application obtains and sets these values with the SystemParametersInfo function. The operating system applies two tests to the specified relative mouse motion. If the specified distance along either the x or y axis is greater than the first mouse threshold value, and the mouse speed is not zero, the operating system doubles the distance. If the specified distance along either the x or y axis is greater than the second mouse threshold value, and the mouse speed is equal to two, the operating system doubles the distance that resulted from applying the first threshold test. It is thus possible for the operating system to multiply relatively-specified mouse motion along the x or y axis by up to four times.

    The mouse_event function is used to synthesize mouse events by applications that need to do so. It is also used by applications that need to obtain more information from the mouse than its position and button state. For example, if a tablet manufacturer wants to pass pen-based information to its own applications, it can write a dynamic-link library (DLL) that communicates directly to the tablet hardware, obtains the extra information, and saves it in a queue. The DLL then calls mouse_event with the standard button and x/y position data, along with, in the dwExtraInfo parameter, some pointer or index to the queued extra information. When the application needs the extra information, it calls the DLL with the pointer or index stored in dwExtraInfo, and the DLL returns the extra information.

    See Also

    GetMessageExtraInfo, SystemParametersInfo

    "There's no such thing as Hell, but you can make it if you try".
    -Prove It, Bad Religion

  • airwinxairwinx Posts: 28Member
    Hi!
    Thank you for your guide.


    If I wanna know whether the player has scroll the mouse up, down, left or right, which method of code is the best to do this or which function in the win API can do this!!!

    After knowing the mouse movement so that I can give them the score....................





    cheers
    airwinx
  • DariusDarius Posts: 1,666Member
    : Hi!
    : Thank you for your guide.
    :
    :
    : If I wanna know whether the player has scroll the mouse up, down, left or right, which method of code is the best to do this or which function in the win API can do this!!!
    :
    : After knowing the mouse movement so that I can give them the score....................
    :
    :
    :
    :
    :
    : cheers
    : airwinx
    :
    mouse_event() isn't used to GET information, it's used to GENERATE it. There is very little reason for it to be used in most cases.

    The proper way to get mouse input is to handle the relevant mouse messages in your WndProc. If you don't know what I'm talking about, look up a Windows tutorial or read a book on Windows programming or read any documentation you have on Windows programming.

    "There's no such thing as Hell, but you can make it if you try".
    -Prove It, Bad Religion

Sign In or Register to comment.