[Help] Button Menu
Hey guys.
Ive run into some trouble with my button menu.
It works and all, But when I click the button to activate the hack, It turn on, Then turns straight off again.
Here is the AddButton && RenderButton function:
And the usage of the button:
Im really stuck here. And dont know whats wrong.
Help me please!!
Thanks,
acid
Ive run into some trouble with my button menu.
It works and all, But when I click the button to activate the hack, It turn on, Then turns straight off again.
Here is the AddButton && RenderButton function:
Code:
void AddButton(int bnum, char *bcaption, int bx, int by, int bw, int bh )
{
Button[bnum].num = bnum;
Button[bnum].caption = bcaption;
Button[bnum].x = bx;
Button[bnum].y = by;
Button[bnum].w = bw;
Button[bnum].h = bh;
Button[bnum].clicked = false;
}
void RenderButton(int butnum)
{
int mw = Button[butnum].x + Button[butnum].w;
int mh = Button[butnum].y + Button[butnum].h;
//Defualt apperance
DrawBox(Button[butnum].x, Button[butnum].y, Button[butnum].w, Button[butnum].h, Black, Red,g_pDevice);
PrintText(pFont, Button[butnum].x + 15, Button[butnum].y + 3, White, Button[butnum].caption);
POINT cur;
GetCursorPos( &cur );
//if the mouse coords are the same as the buttons coords
if ( cur.x > Button[butnum].x && cur.x < mw && cur.y > Button[butnum].y && cur.y < mh )
{
DrawBox(Button[butnum].x, Button[butnum].y, Button[butnum].w, Button[butnum].h, Black, Blue, g_pDevice);
PrintText(pFont, Button[butnum].x + 15, Button[butnum].y + 3, White, Button[butnum].caption);
//if mouse button is clicked
if ( GetAsyncKeyState( VK_LBUTTON )&1)
{
Button[butnum].clicked = !Button[butnum].clicked;
}
}
if ( Button[butnum].clicked )
{
DrawBox(Button[butnum].x, Button[butnum].y, Button[butnum].w, Button[butnum].h, Black, Green, g_pDevice);
PrintText(pFont, Button[butnum].x + 15, Button[butnum].y + 3, White, Button[butnum].caption);
}
}
Code:
if ( Button[1].clicked )
//HackOn
else
//HackOff
Help me please!!
Thanks,
acid

