Creating a button with Windows API
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Creating a button with Windows API

  1. #1
    Join Date
    Aug 2006
    Posts
    98

    Creating a button with Windows API

    Hello,

    I am trying to create a button using the Windows API (not using Windows Forms), using OpenGL in 2D mode to draw the button. So far, what I have done is to monitor every time the mouse is clicked, using the WndProc() function, and to check whether the mouse cursor lies within the boundary of the box. Then, I call the button's relevant function to indicate a button click.

    This works fine, but I now want to extend this to change the image drawn by the button when it is clicked. Just like with Windows buttons, I want to change the image so that it looks like the button is pressed into the screen. Then, when the mouse button is released, or the cursor moves outside the button's bounding box, the image should change back to the unpressed image.

    To change the button to the pressed image is easy - just by checking the mouse click location in WndProc() - but how can I tell when the button is released? The only way I can think of doing this is by continually monitoring the cursor's location in WndProc(), and when it moves outside of the button's bounding box, then change the image back. But this seems like a lot of unneccessary checking of the mouse's location. Is there a neater way of doing it?

    Thanks!!

  2. #2
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,957

    Re: Creating a button with Windows API

    Check the post
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center