Thread: Quick Help.

  1. #1
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379

    Quick Help.

    Alright, I'm finishing up my game and I want to add one more function, I tried to make it so when you clicked the right mouse button it triggered an event.

    The left mouse button detector works, the right detector however, doesnt.

    Heres my code:

    Code:
    #include <iostream> //Some of theyse are unneeded in this snippit
    #include <windows.h> //But my whole code uses them all.
    #include <conio.h>
    #include <fstream.h>
    #include <stdlib.h>
    using namespace std;
    void Hi() {
     COORD Pos, Pos2;
     HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);
     HANDLE hOt = GetStdHandle(STD_OUTPUT_HANDLE);
     DWORD evk;
     INPUT_RECORD rec;
     int x_pos, y_pos, x;
    
     Pos2.X = 0;
     Pos2.Y = 0;
    
     while(!ok) {
      for(;;) {
       ReadConsoleInput(hIn, &rec, 1, &evk);
       if(rec.EventType == MOUSE_EVENT) {
        if(rec.Event.MouseEvent.dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED) {
         x_pos = rec.Event.MouseEvent.dwMousePosition.X;
         y_pos = rec.Event.MouseEvent.dwMousePosition.Y;
         break;
         }
        if(rec.Event.MouseEvent.dwButtonState == FROM_LEFT_2ND_BUTTON_PRESSED) {
         x_pos = rec.Event.MouseEvent.dwMousePosition.X;
         y_pos = rec.Event.MouseEvent.dwMousePosition.Y;
         Pos.X = x_pos;
         Pos.Y = y_pos;
         SetConsoleCursorPosition(hOt, Pos);
         cout << "To!";
         }
        }
       }
    }
    Well, as I said, a left click gets detected, a right click doesnt. I cant figure out why.

    Thank you very much!
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  2. #2
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    use RIGHTMOST_BUTTON_PRESSED
    Kurt

  3. #3
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379
    Woohooo! That was the last bit of code I needed to complete my program!

    Thank you very much kurt! (Btw, where do you find all of theyse constant definitions?)
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  4. #4
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    googling for FROM_LEFT_2ND_BUTTON_PRESSED most likely shows you the definition of the other buttons too.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. strcmp returning 1...
    By Axel in forum C Programming
    Replies: 12
    Last Post: 09-08-2006, 07:48 PM
  2. Do you know...
    By davejigsaw in forum C++ Programming
    Replies: 1
    Last Post: 05-10-2005, 10:33 AM
  3. Questions on basic Quick Sort
    By Weng in forum C++ Programming
    Replies: 4
    Last Post: 12-16-2003, 10:06 AM
  4. Quick Sort Help
    By NavyBlue in forum C Programming
    Replies: 1
    Last Post: 03-02-2003, 10:34 PM
  5. Replies: 0
    Last Post: 04-30-2002, 07:24 PM