So what I'm understanding is that you are looking for a quick way to test for GUI button presses?
The way I check is to have each button contain its own rectangle and check for a collision between the mouse and the button rectangle.
#include <windows.h>
class Button
{
public:
//The 'rect' variable is the 'Hotspot' for the button
//Whether that is the whole button or just a select piece of it.
RECT rect;
//The constructor sets the 'rect' var accordingly.
Button(RECT rect){this->rect = rect;};
//Checks for collision between two RECTs
bool RectCollision(RECT rectA, RECT rectB)
{
if(rectA.left > rectB.right)
return false;
if(rectA.right < rectB.left)
return false;
if(rectA.top > rectB.bottom)
return false;
if(rectA.bottom < rectB.top)
return false;
return true;
}
//This function is ran if the mouse button is pressed
//which is checked in your 'WindowProc' function.
bool CheckForButtonPress()
{
POINT mousePos;
if(GetCursorPos(&mousePos)) //Gets the mousePos on the screen
{
if(ScreenToClient(hwnd, &mousePos)) //Sets the mousePos relative to the window
{
RECT mouseRect = {mousePos.x, mousePos.y, 1, 1};
if(RectCollision(rect, mouseRect))
return true;
return false;
}
}
return false;
}
}
Obviously you can do some optimizations and changes. But I hope you get the gist of it.
Sincerely
-MasterBaldwin