Results 1 to 8 of 8

Thread: Mouse in c++

  1. #1

    Post Mouse in c++

    hey how do u use amouse in c++,is it possible and if yes to what extent,right click??
    [/color][glowpurple]The ladder of sucess is never crowded at top:Napolean[/glowpurple]

  2. #2
    Senior Member
    Join Date
    Jan 2003
    Posts
    3,915
    What do you mean by "use a mouse"???

    C++ is a programming language..

    You can write code to take advantage of mouse clicks, mouse movement and everything in between..

    Are you talking about your C++ IDE? Then the answer would be it depends on the IDE.. but 99.9% of the time yes you could use the mouse.(unless you're using a console editor like vi or pico (at a console without a mouse))

    Peace,
    HT

  3. #3
    could u gimme an example or tell me where i cud get some info abt this
    [/color][glowpurple]The ladder of sucess is never crowded at top:Napolean[/glowpurple]

  4. #4
    Senior Member
    Join Date
    Jan 2003
    Posts
    3,915
    Quote Originally Posted by phoenixmajestic
    could u gimme an example or tell me where i cud get some info abt this
    About what??? (How about you type with proper spelling and punctuation as well)... There's nothing to tell you.. You still haven't said which you are talking about... If you want to utilize the mouse in a C++ program that you're writing... then go look up documentation based on the graphics libraries and GUI support that you are including...

  5. #5
    Just Another Geek
    Join Date
    Jul 2002
    Location
    Rotterdam, Netherlands
    Posts
    3,401
    Quote Originally Posted by phoenixmajestic
    could u gimme an example or tell me where i cud get some info abt this
    http://www.lawrencegoetz.com/programs/mousepractice/
    Oliver's Law:
    Experience is something you don't get until just after you need it.

  6. #6
    Senior Member nihil's Avatar
    Join Date
    Jul 2003
    Location
    United Kingdom: Bridlington
    Posts
    17,188

  7. #7
    Junior Member -Chris-'s Avatar
    Join Date
    Nov 2006
    Location
    UK
    Posts
    11
    If you wish to use mouse clicks (this just works for clicking anywhere), then there is a way to do it in C++ (this will briefly tell you what to do):

    #define KEY_DOWN(key_code)((GetAsyncKeyState(key_code)&0x8000)?1:0)
    #define KEY_UP(key_code)((GetAsyncKeyState(key_code)&0x8000)?0:1)

    #define KEY_LBUTTON 1
    #define KEY_RBUTTON 2

    #include <windows.h>
    #include <iostream>

    using namespace std;

    int main()
    {
    while(1)
    {
    if(KEY_DOWN(KEY_LBUTTON)){cout<<"You have left mouse clicked"<<endl; Sleep(105);}
    if(KEY_DOWN(KEY_RBUTTON)){cout<<"You have right mouse click"<<endl; Sleep(105);}
    }
    }

    However bare in mind that this will work anywhere you click (outside of console, when console is minimised etc).

    Hope this helps.

  8. #8
    thanks guys
    [/color][glowpurple]The ladder of sucess is never crowded at top:Napolean[/glowpurple]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •