Hello,
I have made a function for drawing a custom button using bitmaps. I'm drawing it when recieving WM_PAINT message (is this OK?). Now I want to detect when the user clicks the LMB in the client area. I do this using the WM_LBUTTONUP message. What I am thinking to do is whenever I recieve a WM_LBUTTONUP, I have to loop through the coordinates and sizes of all buttons created in my window and check if the mouse pointer is within one of those. If it is, I'll redraw the button to a pressed state, and send a user specified message to my window. Does this sound like a good idea?
The way I think I want to accomplish this is to use a structure that goes something like this;
Code:
struct myButton
{
int messageID;
int xPos;
int yPos;
int width;
int height;
};
Then in my function for creating the button I'll do something like this:
Code:
myButton *myButtonPnt;
myButtonPnt = new myButton;
To make a new pointer to my button structure, and then fill in the appropriate values. Then I'll have to store it somewhere so that my function for checking if the user clicked it can use it again. Any suggestions on how to accomplish this in the most smart and efficient way?
Any comments or suggestions on any of the above is greatly appreciated.
Thanks,
Eirik