Jump to content
  • Advertisement
Sign in to follow this  
jordi_0071

text as "button"

This topic is 4902 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey, i want that if you click on a text it does something, like if you click on a button. this is what i have:
TextOut(hdc, 650, 70,  "  New Game", 12);

Share this post


Link to post
Share on other sites
Advertisement
Err, let's see. you could try something like this:

if ( MessageBox(NULL, TEXT(" New Game"),
captionName, MB_YESNOCANCEL) == IDOK )
{
// ... do something
// ...
}

I'm pretty new to win32 so I don't think this is the best way to do it but I think it does the job.

Consult this link for more info on MessageBox and freinds if needed.

Share this post


Link to post
Share on other sites
Or you could just create a button ?

#define ID_BUTTON 100

if (CreateWindowEx(0, "BUTTON", "button text here", WS_CHILD | WS_VISIBLE, x, y, width, height, hwnd_Parent, ID_BUTTON, GetModuleHandle(0), 0) == 0)
{
// button was not created
}

Inside your WindowProc function

case WM_COMMAND:
if (wParam == MAKELONG(ID_BUTTON, BN_CLICKED))
{
// button was clicked, do stuff
}
break;

Share this post


Link to post
Share on other sites
Or you could just look at the mouse coords when the mouse button is clicked and if they are in the bouding box of the text then it fires off the event.
You can use GetCharWidth to determine the exact size of the bounding box.

Share this post


Link to post
Share on other sites
use the DrawText first with the DT_CALCRECT to get rectnagle coordinates, then test against it in your left button message handler.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!