I have drawn a small box in a game, that I would like to be able to click it in order to bring up another Larger box that would contain various information, I have named InfoLarge()

This is the Small box
VOID InfoSmall ()

Rectangle(730, 390, 60, 17);
	draw(732, 405, 4, false, 4, -1,"Info");

Could some give me an example of how to use GetASyncKeyState to detect that I am clicking InfoSmall() and to open InfoLarge() , I have never done anything like this before and google didnt come up with anything I am really looking for.

Oh I'm not asking for anyone to do it for me, I just want an example of something similiar, anything else would defeat the purpose!

Recommended Answers

All 3 Replies

GetASyncKeyState just tells you whether a key is down. You need to get the mouse coordinates, and determine if they fall within your rectangle. For that, you will need to trap one of the mouse messages, like WM_LBUTTONDOWN or WM_LBUTTONUP (both left-mouse-button messages). The lParam value of the message will indicate the X and Y positions of the mouse in the client area. See this link for some help.

Yea I that was as far as I had gotten, I just didnt post the code, I had something similiar to..

 if(GetAsyncKeyState(VKLBUTTONUP )) //Key to press in order to click 
    {
       mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 2, 2); //Click Down
       mouse_event(MOUSEEVENTF_LEFTUP, x, y, 2, 2); //Click Up 
       Print("nice");

    }

Oh and those werent the actual buttons I used if anyone was confused, I just typed that up to give an idea.

This didnt work and I didnt want to look like a complete noob posting it

Unless I misunderstand the function, "mouse_event" is used to generate mouse events. If you want to find the mouse's current position, you would need to trap the message as it arrives.

What does your main loop look like?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.