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
|