Mouse co-ordinates?????

This is a discussion on Mouse co-ordinates????? within the Windows Programming forums, part of the Platform Specific Boards category; Heres what I'd like to do : pick up th emouse x and y posiion and then print that back ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    75

    Mouse co-ordinates?????

    Heres what I'd like to do :



    pick up th emouse x and y posiion and then print that back to the screen, then maybe once that is done try and load my own bitmap into the window, and have some of my own custom buttons, then using the mouse position detect wether it is over the button and ready to click or whatever , probably something simple but I'd liek to try it with bitmaps, if somebody coul dhelp



    thanks alot


    Cheers


    Stealth
    If I knew what You know I wouldnt be here.............. Stealth

    Ecliptic Entertainment
    http://www.ecliptic-entertainment.com/

  2. #2
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Lightbulb I don't think you have to...

    I don't think you have to use mouse pos. Try this:

    case WM_COMMAND:
    switch(LOWORD(wParam))
    {
    case "RSRCBMPNAME":
    // do stuff
    break;
    }
    break;
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: trifaze_mattu@lycos.com

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    75
    Oh ok , so I dont need to do that then huh?, hmm mso it cant be the best way then, but this other way, will that let me know where the mouse is, cause thats what I want, I've never really seen anything liek that b4 , so is it ok if u explain a little more, sorry about that, oh yeah did u read r post about the pong game? cause I replied there asking if I could help u, just email me if it's ok


    Stealth2kone@hotmail.com


    thanks alot


    Cheers


    Stealth
    If I knew what You know I wouldnt be here.............. Stealth

    Ecliptic Entertainment
    http://www.ecliptic-entertainment.com/

  4. #4
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Talking Ok, here...

    Yup. I replied. Can you reply to my Hotmail? Ok, for what you want:


    POINT m;

    GetCursorPos(&m);

    if(m == pos)
    {
    // do this
    }

    I'm not sure but it may work
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: trifaze_mattu@lycos.com

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    75
    hmmmmm looks like that would be the "Cursor" position wouldnt it?, and I'm sfter the mouse co - ordinates so that something can happen if the mouse is inside a "Reactive area"or something like that, I'm kinda getting the idea though


    thanks again


    Cheers



    Stealth
    If I knew what You know I wouldnt be here.............. Stealth

    Ecliptic Entertainment
    http://www.ecliptic-entertainment.com/

  6. #6
    Registered User DutchStud's Avatar
    Join Date
    Oct 2001
    Posts
    43

    other way...

    you could also use the case WM_MOUSEMOVE, one of the params - i don't remember which - is a POINT which is your mouse position. if you have bitmaps, you can use the PtInRect() command, which will tell you if your mouse has moved over the certain rectangle that your bitmap is in.

  7. #7
    Registered User
    Join Date
    Oct 2001
    Posts
    75
    Oh yeah I kinda understand the ptInrect() now , hmmm thanks for the help guys, I still need to learn a little more these functions though



    Cheers


    Stealth
    If I knew what You know I wouldnt be here.............. Stealth

    Ecliptic Entertainment
    http://www.ecliptic-entertainment.com/

  8. #8
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    1. On WM_LBUTTONDOWN ect copy the wparam / lparam onto a POINT var. Or use the macro MAKEPOINTS.
    Convert this to / from POINTS to POINT with a type cast (is short int -> int )

    2. GetClientRect() of the button / area on screen.

    3. As both are in diff cood's convert both to the same with ClientToScreen().

    4. Use PtInRect() with the client rect and the mouse point. If the return is zero try another button, else that area / button was clicked.

    I use an array that has the HWND, ClientRect ID, pointer to processing function ect of all the buttons and use a for loop to find the one clicked.
    Last edited by novacain; 11-30-2001 at 12:29 AM.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. need Help in Mouse Pointer
    By obaid in forum C++ Programming
    Replies: 3
    Last Post: 12-07-2006, 03:33 AM
  2. Problem in mouse position
    By Arangol in forum Game Programming
    Replies: 6
    Last Post: 08-08-2006, 08:07 AM
  3. Problem with Mouse Over Menu!!! HELP!!!
    By SweeLeen in forum C++ Programming
    Replies: 3
    Last Post: 02-09-2006, 02:10 AM
  4. Making a mouse hover button, API style
    By hanhao in forum C++ Programming
    Replies: 1
    Last Post: 05-27-2004, 07:17 AM
  5. Game Design Topic #2 - Keyboard or Mouse?
    By TechWins in forum Game Programming
    Replies: 4
    Last Post: 10-08-2002, 04:34 PM

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