[D3D] TxtBox Class!!!!!!!!!!!!!!!!
Ok so I've been working on this for most of this morning. Credz to crash for the inspiration lack of support, and some code.
This can be used to make a custom PTC feature in your d3d hack.
It can also be used to make a password, to keep your hack private.
Now we need a few functions to get us started.
You will be missing some D3D functions you can find them in acid burn's thread.
Then we have the class itself:
Then these functions get defined in the global scope:
You can retrieve text through either getTextC or getTextL
Then it can be initialized in the global scope like so:
In your main loop you would need this:
Then it would get drawn as so:

This can be used to make a custom PTC feature in your d3d hack.
It can also be used to make a password, to keep your hack private.
Now we need a few functions to get us started.
Code:
bool press(int key)
{
if(GetAsyncKeyState(key)<0){
return true;
} else {
return false;
}
}
char getChar()
{
if(press(VK_SHIFT)){
if(press(0x30)){
return '0';
}
if(press(0x31)){
return '1';
}
if(press(0x32)){
return '2';
}
if(press(0x33)){
return '3';
}
if(press(0x34)){
return '4';
}
if(press(0x35)){
return '5';
}
if(press(0x36)){
return '6';
}
if(press(0x37)){
return '7';
}
if(press(0x38)){
return '8';
}
if(press(0x39)){
return '9';
}
if(press(0x41)){
return 'A';
}
if(press(0x42)){
return 'B';
}
if(press(0x43)){
return 'C';
}
if(press(0x44)){
return 'D';
}
if(press(0x45)){
return 'E';
}
if(press(0x46)){
return 'F';
}
if(press(0x47)){
return 'G';
}
if(press(0x48)){
return 'H';
}
if(press(0x49)){
return 'I';
}
if(press(0x4A)){
return 'J';
}
if(press(0x4B)){
return 'K';
}
if(press(0x4C)){
return 'L';
}
if(press(0x4D)){
return 'M';
}
if(press(0x4E)){
return 'N';
}
if(press(0x4F)){
return 'O';
}
if(press(0x50)){
return 'P';
}
if(press(0x51)){
return 'Q';
}
if(press(0x52)){
return 'R';
}
if(press(0x53)){
return 'S';
}
if(press(0x54)){
return 'T';
}
if(press(0x55)){
return 'U';
}
if(press(0x56)){
return 'V';
}
if(press(0x57)){
return 'W';
}
if(press(0x58)){
return 'X';
}
if(press(0x59)){
return 'Y';
}
if(press(0x5A)){
return 'Z';
}
} else {
if(press(0x30)){
return '0';
}
if(press(0x31)){
return '1';
}
if(press(0x32)){
return '2';
}
if(press(0x33)){
return '3';
}
if(press(0x34)){
return '4';
}
if(press(0x35)){
return '5';
}
if(press(0x36)){
return '6';
}
if(press(0x37)){
return '7';
}
if(press(0x38)){
return '8';
}
if(press(0x39)){
return '9';
}
if(press(0x41)){
return 'a';
}
if(press(0x42)){
return 'b';
}
if(press(0x43)){
return 'c';
}
if(press(0x44)){
return 'd';
}
if(press(0x45)){
return 'e';
}
if(press(0x46)){
return 'f';
}
if(press(0x47)){
return 'g';
}
if(press(0x48)){
return 'h';
}
if(press(0x49)){
return 'i';
}
if(press(0x4A)){
return 'j';
}
if(press(0x4B)){
return 'k';
}
if(press(0x4C)){
return 'l';
}
if(press(0x4D)){
return 'm';
}
if(press(0x4E)){
return 'n';
}
if(press(0x4F)){
return 'o';
}
if(press(0x50)){
return 'p';
}
if(press(0x51)){
return 'q';
}
if(press(0x52)){
return 'r';
}
if(press(0x53)){
return 's';
}
if(press(0x54)){
return 't';
}
if(press(0x55)){
return 'u';
}
if(press(0x56)){
return 'v';
}
if(press(0x57)){
return 'w';
}
if(press(0x58)){
return 'x';
}
if(press(0x59)){
return 'y';
}
if(press(0x5A)){
return 'z';
}
}
if(press(0xBE)){
return '.';
}
if(press(VK_SPACE)){
return ' ';
}
return '`';
}
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;
}
}
void ins(int loc, char * arPtr, char chr){
for(int i = strlen(arPtr)-1; i>loc+1; i--){
*(arPtr+i+1) = *(arPtr+i);
}
*(arPtr+loc) = chr;
}
void del(int loc, char *arPtr){
*(arPtr+loc) = NULL;
for(int i = loc; *(arPtr+i+1)!=NULL; i++){
*(arPtr+i) = *(arPtr+i+1);
*(arPtr+i+1) = NULL;
}
}
Then we have the class itself:
Code:
class caTxtBox{
private:
char textbuf[512], passbuf[512];
POINT position;
SIZE maxDimensions;
public:
bool active, pass;
int cursor;
caTxtBox();
caTxtBox(int inX, int inY, int width, int height, bool password){
position.x = inX; position.y = inY;
active = false; pass = password;
maxDimensions.cx = width; maxDimensions.cy = height;
}
void drawTxtBox(IDirect3DDevice9* pDevice);
void eventCode();
char * getTextC();
LPCSTR getTextL();
};
Code:
void caTxtBox::drawTxtBox(IDirect3DDevice9* pDevice){
if(pass){
for(int i = 0; i < 512; i++){
if(textbuf[i] == '|'){
passbuf[i]='|';
}else if(textbuf[i] == NULL){
passbuf[i]=NULL;
}else{
passbuf[i]='*';
}
}
}
if(active){
DrawBox(position.x,position.y,maxDimensions.cx,maxDimensions.cy,BLACK,GREEN,pDevice);
if(!pass){
DrawString(position.x+3,position.y+2,ORANGE,(LPCSTR)textbuf);
}else{
DrawString(position.x+3,position.y+2,ORANGE,(LPCSTR)passbuf);
}
}else{
if(isMouseinRegion(position.x,position.y,position.x+maxDimensions.cx,position.y+maxDimensions.cy)){
DrawBox(position.x,position.y,maxDimensions.cx,maxDimensions.cy,GREY,GREEN,pDevice);
}else{
DrawBox(position.x,position.y,maxDimensions.cx,maxDimensions.cy,BLACK,RED,pDevice);
}
if(!pass){
DrawString(position.x+3,position.y+2,RED,(LPCSTR)textbuf);
}else{
DrawString(position.x+3,position.y+2,RED,(LPCSTR)passbuf);
}
}
}
void caTxtBox::eventCode()
{
if(active){
if(strstr(textbuf,"|")==NULL){
ins(cursor,(char*)textbuf,'|');
}
SIZE tempSZ;
myFont->GetTextExtent((TCHAR*)textbuf,&tempSZ);
if(getChar() != '`' && tempSZ.cx < maxDimensions.cx - 6){
ins(cursor,(char*)textbuf,getChar());
textbuf[cursor+1] = '|';
cursor+=1;
//Sleep(125);
}
if(press(VK_BACK)){
if(cursor > 0){
del(cursor,(char*)textbuf);
textbuf[cursor-1] = '|';
cursor-=1;
//Sleep(175);
}
}
if(press(VK_LEFT) && cursor > 0){
cursor-=1;
textbuf[cursor+1] = NULL;
textbuf[cursor+1] = textbuf[cursor];
textbuf[cursor] = NULL;
textbuf[cursor] = '|';
//Sleep(25);
}
if(press(VK_RIGHT) && cursor < (int)strlen((char*)textbuf)-1){
cursor+=1;
textbuf[cursor-1] = NULL;
textbuf[cursor-1] = textbuf[cursor];
textbuf[cursor] = NULL;
textbuf[cursor] = '|';
//Sleep(25);
}
}else{
if(strstr(textbuf,"|")!=NULL){
del(cursor,(char*)textbuf);
}
}
if(GetAsyncKeyState(VK_LBUTTON)<0){
if(isMouseinRegion(position.x,position.y,position.x+maxDimensions.cx,position.y+maxDimensions.cy)){
active = true;
}else{
active = false;
}
}
}
You can retrieve text through either getTextC or getTextL
Then it can be initialized in the global scope like so:
Code:
caTxtBox txtBox(300,300,150,24);
Code:
txtBox.eventCode();
Code:
txtBox.drawTxtBox(pDevice);



.
;