文字列の最後の文字を消去し、編集コントロールのテキストをその新しい文字列に設定するコードを持っています。問題は、その後、次にタイプされる文字の位置が変更されることです。 例:MFCからエディットコントロールに次の文字を配置する位置を変更するにはどうすればいいですか?
[12345 | ](入力された次の文字 が配置される場所スラッシュがある)
エディットコントロールボックス言及したコードを実行した後:[を| 12345](今すぐ手前に移動した位置、 前1)
位置を文字列の最後にもう一度移動するにはどうすればよいですか? マイコード:
CString str1 = ""; //Temporary CString
eb1->GetWindowText(str1); //Store text from Edit Control to the CString
string strCheck1 = str1.GetString(); //Place the CString into a regular string
int s1 = strCheck1.length() -1; //Get index of last character and new size
bool check1 = true; //Boolean variable for the checking
//Get if character is valid
if((strCheck1[s1] <= '0' || strCheck1[s1] >='9') && strCheck1[s1] != '.') {check1 = false;}
//If is invalid I erase last character and put it back intact into the Edit Control
if(check1 == false) {strCheck1.erase(s1,1); eb1->SetWindowTextA(strCheck1.c_str());}
私はCEdit :: SetSelがそれを強調表示するような文字を選択すると考えていた機能をブラウズしていましたが、これはそうではありません。私は試してみたはずです。ありがとう。 – Artie