Jump to content
  • Advertisement

Archived

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

Estauns

Win32 : Have TGA File, Want Click Event...

This topic is 5562 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 all, I have this TGA file stored in a class with a function called ChangeState. I then have an array of these classes, arranged in a 3x3 grid. Basically what I want is, when the TGA is clicked on, the function ChangeState is called. How would I go about doing this? Its all Win32 / GDI too. I''m not going to get into D3D or OpenGL for something like this for a long time. Thanks a bunch!

Share this post


Link to post
Share on other sites
Advertisement
After some playing around, I''ve found that I can just store the images centre position and check the ImageHeight and the ImageWidth and then check if the mouse co-ordinates are within the image.

Is this the best / only way to do this?

Share this post


Link to post
Share on other sites
Just want to make sure I''m on the right track here...


if(MouseX > Image.Centre.X - Image.Width / 2 && MouseX < Image.Centre.X + Image.Width / 2)


That works, and for Y too.

But is there some Click On Event (like Visual Basic) I can just trigger, or is this the only way to go about it?

Thanks guys.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
if i understand you correctly, you are justing painting these tgas into the app''s main window in response to a WM_PAINT msg purhaps? are you processing the WM_LBUTTONDOWN msg at all or are you just looking at WM_MOUSEMOVE msgs? i''m not quite sure what you currently have so i can''t quite tell you what would be "better."

if you are going the one window route for now, what you could do is create a separate child window for each of the tgas, via an Init method in the class. you could also store the HWND or made-up resource ID of the child window in the class for use later. if you specify the window class as "static" during the CreateWindow call, along with the SS_NOTIFY and SS_BITMAP styles, you will get a control that''s pretty close to a VB picture box. to process the mouse down event, you would then have two choices: 1) have the parent window process the STN_CLICKED notification msg that would be sent to the parent as a WM_COMMAND whenever the static window was clicked on, or 2) "sub-class" the static dialog proc with your own tga class''s msg handler and have that msg proc handle the mouse events. this would provide for a more self-contained class.

Share this post


Link to post
Share on other sites

  • 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!