Draw CheckBox Function

Posts 1–11 of 11 · Page 1 of 1
Draw CheckBox Function
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
Code:
bool t1;
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);
}
Really not that complicated.

Now make it OOP.
What's with everyone and their checkboxes lately?
Quote Originally Posted by NOOB View Post
What's with everyone and their checkboxes lately?
@ fk127 good job
@noob.. Lol it is because I released it jk.. SOLIFY STARTED UP Checkboxes AGAIN WITH HIS BASE I GUESS... hehe u doing checkboxes too and acid and everyone
Quote Originally Posted by Nubzgetkillz View Post
@ fk127 good job
@noob.. Lol it is because I released it jk.. SOLIFY STARTED UP Checkboxes AGAIN WITH HIS BASE I GUESS... hehe u doing checkboxes too and acid and everyone
I prefer hotkeys.
Quote Originally Posted by NOOB View Post
What's with everyone and their checkboxes lately?
one person does it, and then the rest of the monkeys follow.
Quote Originally Posted by ac1d_buRn View Post


one person does it, and then the rest of the monkeys follow.
who started? probably Solify? and his base?
Quote Originally Posted by Nubzgetkillz View Post
who started? probably Solify? and his base?
Probably some caveman a long time ago made it first. It's a shame we don't credit him/her.
Quote Originally Posted by NOOB View Post


Probably some caveman a long time ago made it first. It's a shame we don't credit him/her.
u are right

credits:
[IMG]http://1.bp.********.com/_bY-Gu4Mr7eU/RznVjwxKEwI/AAAAAAAAAyw/Rz5pjNX1LEQ/s400/GeicoCaveman.jpg[/IMG]
Quote Originally Posted by Nubzgetkillz View Post
who started? probably Solify? and his base?
but he is good
Posts 1–11 of 11 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Talk with us