Archived

This topic is now archived and is closed to further replies.

sakky

mouse rollover detection

Recommended Posts

I know this question might be a little out of hand but here goes. I need a rollover formula for my Game''s menu. Basicly what I mean is when the mouse is in a setain area. Like a detection RECT. so I can then change the color of the font or grahpics. I tried doing this my self and came up with a realy crapy program that didn''t do what I needed. I want to know how I can detet if the mouse is positioned in a RECT struct. This should be simple to figure out but I''m having a little bit of trouble with it. I''v made a called RECT detect;. Then I set its co-ords like this detect.top=0; detect.left=0; detect.bottom=50; detect.right=50; Now how to I test to see weather my 2 varibles int mos_x=(int)LOWORD(lParam); int mos_y=(int)HIWORD(lParam); are with in detect''s co-ords? Can nay body help me with this please?!

Share this post


Link to post
Share on other sites
I would get the mouse coordinates, then if you dont already id have a struct or class that is for the rect, and in your menu loop have it check whether the mouse coordinates are inside thae rects.

Share this post


Link to post
Share on other sites
Yeah, I figured it out. I don''t know what I was thinking. I was trying to send a message for changing the test or what ever when the mouse came across the rect I defined. Bad thang though. Now it sends to many messages. I made a little window that I could test stuff with. Mainly this ideas and I called it test. I drew a black rectangle and tested the mouse co-ords. But when its in the rect is that bad thang. Because it keeps sending the message. I made the mistake of having a little messagebox popup when the mouse cursor was in the rect. Saaying "got it". Then when I moved the mouse into the rect ass loads of messageboxes started poping up.. . .LOL Now I have to figure out how to only make it check once if the mouse is in the rect. Then do what evre I want it to. Then I need some sort of method to send a message if the mouse was in the rect but has just left it. So I can set the text back to normal. I need to get something going like java-script so to speak. I''m thinking about making a MENU struct or class. So I can make me oneof those cool looking menus you would see on STARCRAFT or DIABLO. A very graphical one that lets you choose border width and a sertain amount of menuitems. I guess going and looking into some of my windows header files can give me a good jump start and a few ideas on how to make one.

Share this post


Link to post
Share on other sites