   C++/DirectX 9 Textbox
  Hey guys,I need to make a textbox for a UI.I'm using Unmanaged C++ and DirectX 9.I searched over the internet, but couldn't find something about how to create textboxes.Do I have to make it totally from nothing, or are there some help-options or soemthing included into C++ or directX?I need it for a gamewindow by the way.(like login and password field.)Best regards,Martin   
  There isn't much in DX and C++ that can help you create a GUI text box.You can draw sprites with DX and get WM_CHAR messages and send the pressed char to your text box if it has focus.In my game I made a class to handle edit boxes where the user can input text.It has a few members like the size of the rectangle of the text box the texture to draw for the editbox,the text title on the left of the edit box and the text that is inside the editbox.It also has an variable to keep track if the editbox is focused.When the user presses a mouse button I check if he clicked on the editbox,if so I set the focused flag to true.When drawing the edit box if it is focused I draw a blinking caret.Also when the user pressed a key I get it through WM_CHAR which handles repeat count and keyboard settings,and send it to the editbox.The editbox adds the new received char to its string and deletes chars from the string if its backspace.If enter or escape is pressed I set focused flag to false.You can add a password flag and if this is set you can draw all characters as "*"s.Hope it gives some ideas.   ;.;  Okay, Thanks very much both.I just started to try to make it.First of all I'm making a(1) simple textbox and no focus etc.For that I am using LPCSTR variables.But I don't know how to concatenate them.This is (a bit of) my code.// textbox variablesLPCSTR testText = "";LPCSTR newChar = "";//key detectionif(keystate[DIK_A] & 0x80){    // if the 'A' key was pressed...newChar = "a";testText = testText << newChar; //testText = testText + newChar; //testText = testText && newChar; //All doesn't work.}//draw variable in messageboxstatic RECT textbox; SetRect(&textbox, 0, 0, 640, 480);// draw the messagebox text    dxfont->DrawTextA(NULL,  testText,  strlen(testText),  &textbox,  DT_CENTER | DT_VCENTER,  D3DCOLOR_ARGB(255, 255, 255, 255));my problem is in the second code block.I just can't add another character to the Variable(testText)What's the solution?   ;  You want to use std::string or std::wstring to compile the string.Also, never use DirectInput for keyboard input, and especially not for text input.   ;Quote:Original post by Evil SteveYou want to use std::string or std::wstring to compile the string.Also, never use DirectInput for keyboard input, and especially not for text input.But DrawTextA uses LPCSTR.I get this error using std::stringcannot convert parameter 2 from 'std::string' to 'LPCSTR';  Use the c_str() member of string.string blah;func(blah.c_str());   ;Quote:Original post by Black KnightUse the c_str() member of string.string blah;func(blah.c_str());I usestring testText;string newChar;func(testText.c_str());func(newChar.c_str());now.But I get 7 errors- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int- error C2440: 'initializing' : cannot convert from 'const char *' to 'int'- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int- error C2374: 'func' : redefinition; multiple initialization- error C2440: 'initializing' : cannot convert from 'const char *' to 'int'- error C2664: 'strlen' : cannot convert parameter 1 from 'std::string' to 'const char *'1>   No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called- error C2664: 'ID3DXFont::DrawTextA' : cannot convert parameter 2 from 'std::string' to 'LPCSTR'1>   No user-defined-conversion operator available that can perform this conversion, or the operator cannot be calledI've included #include <string>using namespace std;by the way.   ;  Um, he was giving an example of how to do what you want. You shouldn't have copied/pasted his exact code without understanding it first. In every place that says to use an LPCSTR you would instead call the member function c_str() of std::string. That is, if you had code like this:LPCSTR testText;// codeRandomLibraryFunctionThatTakesAnLPCSTRAndLengthOfString(testText, strlen(testText));You would replace that with code that might go something like this:std::string testText;// codeRandomLibraryFunctionThatTakesAnLPCSTRAndLengthOfString(testText.c_str(), testText.length());;  Oh my god, I'm just really noob at C++ at the moment.It works now.Thanks for all your help!   