Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

graphical keyboard?

Status
Not open for further replies.

legos

Programmer
Jul 2, 2003
151
US
Hi everyone, I am making my first attempts at VC++ programming, and I could use a bit of help. Here is what I am trying to make, it is something similar to a visual keyboard and I just need an example to get me started.
The user will press buttons in the GUI representing keys on a keyboard, each keypress will add the letter to a textbox. When the enter button on the GUI is pressed, the textbox clears and the line of text from the textbox is saved in a listbox that is above the textbox. If someone could show me how this can be implemented It would be very helpful.

Durible Outer Casing to Prevent Fall-Apart
 
This is easily done using either a dialog or formview. I'm basing this on VC++ 6.0, the sequence is a little different in .NET but you will end up with the same steps in a slightly different way.
Create a dialog application and start adding buttons (this is the hard part). Change the text on each button to a keyboard character. Right click each button and go to ClassWizard. Create a 'button clicked' function for each, they will look like OnButtonClickedA, etc.
Add an edit control to your dialog - give it a variable of type CString.
Add the listbox and give it a control variable such as 'm_list'.
Add a CString variable to the dialog class. For each button click, add the letter (or number) to your string. This will look like 'm_str += m_edit'.
When the enter button is pressed, use the list control AddString method to put the whole string into the listbox. This will look like 'm_list.AddString(m_str)'.
Now clear the edit window by setting the string to "".
Last use 'UpdateData(FALSE)' to update everything.
Hope this is clear enough to be of help.
 
Thanks for your help, I actually just finished everything I was attempting to do today.
These are the two functions that control the text in the cursor and then the one in the listbox.
// enter text, click event
void newText_Click(Object^ sender, EventArgs^)
{
FormatEditField(((Button^)sender)->Text);
}
// helper to format the entry in the text box!
void FormatEditField(String^ ButtonText)
{
String^ strValue = textField->Text;

if (strValue->CompareTo(s_strZero) == 0)
strValue = ButtonText;
else
{
strValue = String::Concat(strValue, ButtonText);
}

textField->Text = strValue;
}
//display text line in listbox
void ReturnKey_Click(Object^ sender, EventArgs^)
{
String^ strValue = textField->Text;
if (strValue->Length != 0)
{
textScreen->Items->Add(strValue);
textField->Text = s_strZero;
}
}



Does anyone know of a way to make some of the fields in the listbox left justified, and other fields right justified?

Durible Outer Casing to Prevent Fall-Apart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top