Static mouse overs?

This is a discussion on Static mouse overs? within the Windows Programming forums, part of the Platform Specific Boards category; Hi I wanna do something when the user place the mouse on a static control...is there a Message i can ...

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    36

    Static mouse overs?

    Hi

    I wanna do something when the user place the mouse on a static control...is there a Message i can capture(can't find one)...if not how would i do it? thnx
    Time for TOTAL WAR

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User
    Join Date
    Jun 2002
    Posts
    36

    But ...

    Hmm..but the user has to click a button

    WM_LBUTTONDOWN WM_MBUTTONDOWN
    WM_RBUTTONDOWN

    As far as i understood it...the user has to put the Mouse over the control AND click....i want it without the click..... can someone help??

    thnx
    Time for TOTAL WAR

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Try

    TrackMouseEvent()
    "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

  5. #5
    Registered User
    Join Date
    Jun 2002
    Posts
    36

    i...

    hmmm i don't know...what about responding to WM_LBUTTONUP
    and checking the mouse position with GetCursorPos()
    and checking it wether it is within the boundaries of the static
    with GetWindowRect()

    Is there some easier or better way then this???

    hehehe....is this even possible?


    thnx
    Time for TOTAL WAR

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Is this possible?

    No

    Not without SetCapture() and a WM_LBUTTONDOWN first

    MSDN
    "The WM_LBUTTONUP message is posted when the user releases the left mouse button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor."

    It may work on a WM_MOUSEMOVE msg after a call to SetCapture()

    Use PtInRect() to test teh point is in the contols area. You may need to convert using ScreenToClient() or ClientToScreen()
    "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

  7. #7
    Registered User
    Join Date
    Jun 2002
    Posts
    36

    hmmm

    hmmm...ok then i think i;ll do the following :

    1.get the WM_MOUSEMOVE
    2.Determine Mouse Position GetCursorPos()
    3.The Point i get from 2 will be used in PtInrect()

    possible?

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

    Lightbulb Code for Zionaster's solution (changed some things)...

    case WM_MOUSEMOVE:
    POINT pt; // Current mouse point
    GetCursorPos(&pt); // Coords of cursor

    // Check x position
    if ((pt.x >= STATIC_X) && (pt.x <= STATIC_WIDTH)) {
    if ((pt.y >= STATIC_Y) && (pt.y <= STATIC_HEIGHT)) {
    // This is where you handle the mouse over
    // the static control
    }
    }
    break;

    STATIC_X and STATIC_Y are the X and Y-Axis that the static control is on and STATIC_WIDTH and STATIC_HEIGHT are the width and height of the static control. This should do what you are wanting to =).
    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

  9. #9
    Registered User
    Join Date
    Jun 2002
    Posts
    36

    Nice hehehe

    That was exactly what i had in mind....glad that that is doible hehehehe

    Well thaks SyntaxBubble and all the others helping me out

  10. #10
    Zion
    Guest

    hmm

    if i did it via Syntax bubbles way it would be abit tedious...i am trying to do this:

    GetWindowRect(Button_Up,&Up_Rect);
    GetWindowRect(Button_Down,&Down_Rect);
    GetWindowRect(Button_Left,&Left_Rect);
    GetWindowRect(Button_Right,&Right_Rect);

    break;

    case WM_MOUSEMOVE:
    POINT p;
    GetCursorPos(&p);
    if(PtInRect(&Up_Rect,p)!=0)
    {
    CPosUp();
    }
    else if(PtInRect(&Up_Rect,p)==0)
    {
    MessageBox(NULL,"asd","asd",MB_OK);
    }
    else if(PtInRect(&Down_Rect,p)!=0)
    {
    CPosDown();
    }
    else if(PtInRect(&Right_Rect,p)!=0)
    {
    CPosRight();
    }
    else if(PtInRect(&Left_Rect,p)!=0)
    {
    CPosLeft();
    }
    break;

    But it doesn't work....argggg the msgbox always popsup help..

    have tried GetClientRect() but still no go ahhhh!!

  11. #11
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Your if else logic is wrong. It can never get to the third if statement as the point is either in the UP rect or not.

    Call the getClientRect() under the mouse move msg or make them static. As many msg's are passing thru the callback the rects will have lost scope unless you do.





    If you want to make cleaner code try this;

    If you create the buttons then create them with consecutive resource IDs.

    Or edit the resource.h file so all the buttons have consecutive ID numbers.

    Then use a for loop.
    Code:
    for(i=ID_FIRST_CTRL;i<ID_LAST_CTRL;i++)
    {
          GetClientRect( GetDlgItem(hDlg,i) ,&Rect);
          if(PtInRect(&Rect,Point))
                 iButtonClicked=i;
    }
    "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. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  2. seg fault at vectornew
    By tytelizgal in forum C Programming
    Replies: 2
    Last Post: 10-25-2008, 01:22 PM
  3. uploading file to http server via multipart form data
    By Dynamo in forum C++ Programming
    Replies: 1
    Last Post: 09-03-2008, 04:36 AM
  4. LNK2001 ERROR!!! need help
    By lifeafterdeath in forum C++ Programming
    Replies: 7
    Last Post: 05-27-2008, 05:05 PM
  5. [GLUT] Pointers to class methods
    By cboard_member in forum C++ Programming
    Replies: 13
    Last Post: 02-16-2006, 03:03 PM

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