Changer la facon de sélectionner un mot dans un richEdit en double cliquant dess

arnaud_tournier Messages postés 34 Date d'inscription jeudi 16 septembre 2004 Statut Membre Dernière intervention 25 mars 2007 - 18 nov. 2004 à 19:35
arnaud_tournier Messages postés 34 Date d'inscription jeudi 16 septembre 2004 Statut Membre Dernière intervention 25 mars 2007 - 20 nov. 2004 à 13:48
Hello,

J aurais aimer savoir si quelqu un sait comment modifier la facon de sélectionner un mot quand on double clique sur un RichEdit....

Je m explique :

si j ai une ligne dans mon RichEdit =>

function toto_titi() // exemple de fonction

si je double clique sur toto , alors toto est sélectionné, j aimerais savoir comment je pourrais automatique sélectionner toto_titi

Merci d avance pour vos réponses....

Arnaud

1 réponse

arnaud_tournier Messages postés 34 Date d'inscription jeudi 16 septembre 2004 Statut Membre Dernière intervention 25 mars 2007
20 nov. 2004 à 13:48
J ai trouvé ca et ca marche presque bien...
Le probleme est que dans lpch je n ai pas toute la ligne donc si le mot a sélectionné est trop long je n arrive pas à le sélectionner complètement.....

Est ce que quelqu un aurait une solution....
Merci d avance...

type
TNewRichEdit = class(TCustomRichEdit)
private
{ Déclarations privées }
public
{ Déclarations publiques }
procedure CreateWnd(); override;
published
end;
function EditWordBreak(lpch: PChar; index: integer; cch: integer; code: integer): integer; stdcall;

procedure TNewRichEdit.CreateWnd;
var Margins : LongInt;
begin
inherited;
SendMessage(Self.Handle, EM_SETWORDBREAKPROC, 0, LPARAM(@EditWordBreak));
end;

function EditWordBreak(lpch: PChar; index: integer; cch: integer; code: integer): integer; stdcall;
const
SPACE = [' ', #9, #10, #13];
DELIM = ['@', '$', '.', '-', '+', '/', '=', ';', '*', '(', ')', '|', ',', '{', '}', '[', ']', '<', '>', ':', '''', '"'];
ADELIM = SPACE+DELIM;
var
ichCurrent: integer;
sTmp : WideString;
begin
ichCurrent := index;
result := 0;
case code of
WB_ISDELIMITER: begin
result := ord(Char(lpch[ichCurrent]) in ADELIM);
showMessage('WB_ISDELIMITER');
end;
WB_CLASSIFY: begin
if (Char(lpch[ichCurrent]) in SPACE) then
begin
showMessage('WB_CLASSIFY');
result := WBF_ISWHITE;
end;
end;
WB_LEFTBREAK : begin
showMessage('WB_LEFTBREAK');
end;
WB_LEFT : begin
showMessage('WB_LEFT');
end;
WB_MOVEWORDLEFT:begin
while (ichCurrent > 1) and (not (Char(lpch[ichCurrent - 1]) in ADELIM)) do
begin
dec(ichCurrent);
end;
(*
if ichCurrent = 0 then
begin
result := - ord(not(Char(lpch[ichCurrent]) in ADELIM));
end
else
*)
if ichCurrent = index then Result := ichCurrent - 1 else Result := ichCurrent;
end;
WB_RIGHTBREAK : begin
showMessage('WB_RIGHTBREAK');
end;
WB_RIGHT : begin
showMessage('WB_RIGHT');
end;
WB_MOVEWORDRIGHT:begin
while (ichCurrent + 1 < cch) and (not (Char(lpch[ichCurrent + 1]) in ADELIM)) do
begin
inc(ichCurrent);
end;
Result := ichCurrent + 1;
end;
end;
end;

Arnaud
0
Rejoignez-nous