Retour de chariot automatique
Dans un RichEdit, j'ai besoin de faire un retour de chariot automatique après 40 caractères, j'utilise ce code, probleme après l'envoie du VK_RETURN, j'ai des retours de chariot à l'infinie :!:
Comment corriger le bug ? :?
Merci.
Code:
1 2 3 4 5 6 7 8 9 10 11
| void __fastcall TForm1::RichEdit1KeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
//Pour trouver le nombre de caractère sur la ligne
longLigne = (RichEdit1->Perform(EM_LINELENGTH, (LPARAM) (DWORD) numCaractere, 0));
if (longLigne > 40)
{
Key = VK_RETURN;
}
} |
Retour de Chariot automatique
:D
Merci,
J'ai trouver, une ligne de code dans RichEdit1Change causer le Bug.
Maintenant ceci est nickel :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| void __fastcall TForm1::RichEdit1KeyPress(TObject *Sender, char &Key)
{
//Pour trouver le numéro de ligne(s) et de caratère(s)
numLigne = RichEdit1->Perform(EM_EXLINEFROMCHAR, 0, (LPARAM) (DWORD) RichEdit1->SelStart);
numCaractere = (RichEdit1->SelStart - RichEdit1->Perform(EM_LINEINDEX, (LPARAM) (DWORD) numLigne, 0));
AnsiString LigneCol(IntToStr(numLigne) + ": " + IntToStr(numCaractere));
//Form1->StatusBar->Panels->Items[0]->Text = LigneCol;
if (numCaractere > 39)//Maximum de 40 caracteres par ligne
{
Key = VK_RETURN;
}
} |
Merci.