Heres a function i made for drawing checkboxes. i know its messy, and some of it is probably not needed, but it works, and i did my best! Thanks nubzgetkillz for the help!
Code:
struct {
char *txt;
bool *var;
} check[100];
void Drawcheckbox(char *txt,int x, int y, int w, int h,bool *var,D3DCOLOR text, D3DCOLOR border, D3DCOLOR oncolor, D3DCOLOR offcolor,IDirect3DDevice9* pDevice )
{
check[0].var=var;
check[0].txt=txt;
DrawBox(x,y,w,h,offcolor,border,pDevice);
DrawText(x + w + 5,y + 5,text, txt, pDevice);
if(isMouseinRegion(x,y,x+w,y+h))
{
if(GetAsyncKeyState(VK_LBUTTON)&1)
{
*var =! *var;
}
}
if(*var)
{
DrawBox(x,y,w,h,oncolor,border,pDevice);
}
}
how to use:
in globals, add a boolean for your hack you want to toggle with the checkbox
then to draw it
Code:
/*Drawcheckbox(text, x, y, w, h, &+boolean for your hack, textcolor,bordercolor, oncolor, offcolor, pDevice); */
Drawcheckbox("test",60,80,76,56,&t1,Red, Blue,Green, Red, pDevice);
for your hack
Code:
if(t1)
{
//do hack for checkbox 1 here
}
In case u dont have them:
Code:
bool isMouseinRegion(int x1, int y1, int x2, int y2)
{
POINT cPos;
GetCursorPos(&cPos);
if(cPos.x > x1 && cPos.x < x2 && cPos.y > y1 && cPos.y < y2){
return true;
} else {
return false;
}
}
Code:
void FillRGB( int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* pDevice )
{
D3DRECT rec = { x, y, x + w, y + h };
pDevice->Clear( 1, &rec, D3DCLEAR_TARGET, color, 0, 0 );
}
Code:
void DrawBorder( int x, int y, int w, int h, int px, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice )
{
FillRGB( x, (y + h - px), w, px, BorderColor, pDevice );
FillRGB( x, y, px, h, BorderColor, pDevice );
FillRGB( x, y, w, px, BorderColor, pDevice );
FillRGB( (x + w - px), y, px, h, BorderColor, pDevice );
}
Code:
void DrawBox( int x, int y, int w, int h, D3DCOLOR BoxColor, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice )
{
FillRGB( x, y, w, h, BoxColor, pDevice );
DrawBorder( x, y, w, h, 1, BorderColor, pDevice );
}
Code:
void DrawText(int x,int y,DWORD color,char *text, LPDIRECT3DDEVICE9 pDevice){
RECT rect;
SetRect( &rect, x, y, x, y );
Directx_Font->DrawTextA(NULL,text,-1,&rect, DT_LEFT|DT_NOCLIP, color);
}