Thread: Using mouse click

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    14

    Question Using mouse click

    i would like to ask anyone who knows how to use a mouse click in C++. i want to use the mouse to enter a choice of list.
    Eg.
    LOGIN
    REGISTER
    EXIT
    i wan to use my mouse to enter either one of the choice. can i do it using C++? is it possible? and i m using MinGW Studio Developer by the way. can anyone help me?

  2. #2
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    Is this for a console app or windowed app? What OS?
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  3. #3
    Registered User
    Join Date
    Oct 2005
    Posts
    14
    This is using window xp. i m not using VC++. n i m not sure what is console app o window app cos i m stil learning. what is the different, anyway?

  4. #4
    Registered User
    Join Date
    Sep 2005
    Posts
    142
    a windows app is a windows application like an install programme,
    it uses windows.h functions, a consol app is programmed differently, as for using a mouse with a consol app i don't know,
    WhAtHA hell Is GoInG ON

  5. #5
    Registered User
    Join Date
    Oct 2005
    Posts
    14
    yes....its window app

  6. #6
    Rabite SirCrono6's Avatar
    Join Date
    Nov 2003
    Location
    California, US
    Posts
    269
    Are they buttons then (CreateWindow( "BUTTON"... ))? If so:
    Code:
    case WM_COMMAND:
      switch( wParam )
      {
        case BUTTON_ID: //Replace this with the button's ID
          //Do stuff
          break;
        case OTHER_BUTTON: //Again, replace this with the button's ID
          //Do something else
          break;
      }
      break;
    should go in the window proc.
    From C to shining C++!

    Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
    - Bubba

    IDE and Compiler - Code::Blocks with MinGW
    Operating System - Windows XP Professional x64 Edition

  7. #7
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    If it is instead a console application for Windows, you would ::SetConsoleMode(..) with ENABLE_MOUSE_INPUT. You then recieve mouse event notifications with a MOUSE_EVENT_RECORD structure, and a COORD of the mouse position in the dwMousePosition structure member.

  8. #8
    Registered User
    Join Date
    Oct 2005
    Posts
    14
    what library do i have to include to use this mouse click function??

  9. #9
    Registered User
    Join Date
    Oct 2005
    Posts
    14
    and one more thing, can someone explain to me how to use it?? cos i m new in programming and i dun know how to use it. if u can, gives some short example as wells. thanks!!!

  10. #10
    The Richness... Richie T's Avatar
    Join Date
    Jan 2006
    Location
    Ireland
    Posts
    469
    if you're new, i wouldnt recommend atttempting windows programming until you are very comfortable at using and manipulating console apps, the fact that you werent aware of the difference would imply that either you havent scratched the surface of windows programming, or that you are relatively new to programming altogether. in the case of the former, there is a programmer on this forum who has a tutorial website -

    http://www.adrianxw.dk/

    a friend of mine has recently started windows programming and has come leaps and bounds in a really short time. as far i know, this site deals mostly with console apps that access winsows functions, so it would be a good starting point for someone interested in GUI.

    however if you are the latter, think about writing more complex console apps before you try windows programming - its a whole different world in my opinion.
    No No's:
    fflush (stdin); gets (); void main ();


    Goodies:
    Example of fgets (); The FAQ, C/C++ Reference


    My Gear:
    OS - Windows XP
    IDE - MS Visual C++ 2008 Express Edition


    ASCII stupid question, get a stupid ANSI

  11. #11
    Registered User
    Join Date
    Oct 2005
    Posts
    14
    Thanks to all of u for helping me out!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem in mouse position
    By Arangol in forum Game Programming
    Replies: 6
    Last Post: 08-08-2006, 07:07 AM
  2. Replies: 2
    Last Post: 03-23-2006, 07:08 AM
  3. Hold Mouse Click
    By zach0616 in forum C++ Programming
    Replies: 3
    Last Post: 07-06-2005, 08:13 PM
  4. Making a Mouse Click
    By r0ss in forum C Programming
    Replies: 1
    Last Post: 06-03-2004, 08:55 PM
  5. mouse click coords and moving a rect
    By techrolla in forum Windows Programming
    Replies: 1
    Last Post: 03-07-2004, 09:49 PM