Mouse_event

This is a discussion on Mouse_event within the C++ Programming forums, part of the General Programming Boards category; ok Im trying to do somting like this dont know the code and cant figure it out so if you ...

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    43

    Mouse_event

    ok Im trying to do somting like this dont know the code and cant figure it out so if you guys could help that would be great

    wait untill mouse = mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);

    or somting like this

    how do I go about doing this thanks

    Dev-C++ on windows XP
    Last edited by JordanCason; 11-20-2007 at 12:02 PM.

  2. #2
    Registered User
    Join Date
    Mar 2007
    Posts
    416
    what are you trying to do? wait until the left mouse button is released? There is no return value for the function mouse_event(). mouse_event() is used to create an event, not see if an event occured.

  3. #3
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    After reading your post on this, and your post on the finding color values, it seems like you are trying to dive into the Windows API too deep too fast without having a good knowledge of some more basic things.

    Whatever the case is, there's millions of ways you can capture a mouse event, depending on the API you are using.
    My Website

    "Circular logic is good because it is."

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584
    To capture a mouse event you can write code for WM_ mouse messages that get sent to your window.

    Many APIs have different ways of dealing with this core Win32 message handling method but they are all fairly similar in function.

  5. #5
    Registered User
    Join Date
    Oct 2007
    Posts
    158
    The way I do that is something like this which processes windows messages. I suppose you could implement something similar. (Just make sure you add some condition where you step out of the loop).
    Code:
    MSG wmsg;
    while (GetMessage(&wmsg, NULL, 0,0))
    {
        if (wmsg.message == WM_LBUTTONUP) dostuff;
    }

  6. #6
    Registered User
    Join Date
    Nov 2007
    Posts
    43
    hay thatks I'll geve it a try : )

    Code:
    int main()
    {
    int x, y;
    while (mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0))
    {
        if (mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0))
        cout << "test";
        ;
    }}
    I get this error "coid value not ignored as it ought to be".
    can some one tell me what that means?
    I am using Dev-C++ in windows XP.
    Last edited by JordanCason; 11-21-2007 at 01:54 AM.

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I take it the error message is "void value not ignored".

    mouse_event() appears to be a "void" function - meaning it doesn't return anything.

    Did you try the code posted by DrSnuggles?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #8
    Registered User
    Join Date
    Nov 2007
    Posts
    43
    O thank you I dident understand the void thing yet maby this one is to hard for me now ill finish my book 1st. : )

  9. #9
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    void is used to indicate that the function doesn't return ANYTHING - it has no "value" to "return".

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  10. #10
    Registered User
    Join Date
    Mar 2007
    Posts
    416
    In my first post I stated this function returns nothing. Understanding return values, using return values, and definitely void is key before using any functions in while and if statements.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21