Subject: Range check error |
From: "Efird Jr, Carl R \(O7K\)" |
Date: Wed, 12 Oct 2005 13:51:47 -0400 |
To: |
When I built my application with range check on, Speller had a range check error. I have included my fix for the problem. You can locate my changes by searching for the //cre
In Spellers.pas -
procedure TSpellChecker.GetTextRange(Buf: PChar; StartPos, EndPos: Integer; CP: Word);
type
{ The declarations of TTextRangeA and TTextRangeW in Richedit.pas are incorrect}
TTextRangeA = record
chrg: TCharRange;
lpstrText: PAnsiChar; {not AnsiChar!}
end;
var
W: WideString;
S: String;
GTL: TGetTextLengthEx;
GT: TGetTextEx;
L: Integer;
begin
GTL.flags:= GTL_DEFAULT;
GTL.codepage:= 1200;
L:= FMemo.Perform(EM_GETTEXTLENGTHEX, Integer(@GTL), 0);
if L>0 then
begin
SetLength(W, L);
GT.cb:= L*2+2;
GT.flags:= GT_DEFAULT;
GT.codepage:= 1200;
GT.lpDefaultChar:= nil;
GT.lpUsedDefChar:= nil;
FMemo.Perform(EM_GETTEXTEX, Integer(@GT), Integer(@W[1]));
WideCharToMultiByte(CP, 0, @W[StartPos+1], EndPos-StartPos, Buf, EndPos-StartPos, nil, nil);
Buf[EndPos-StartPos]:= #0;
end
else
begin
S:= FBackMemo.Text;
if StartPos<Length(S) then //cre
StrLCopy(Buf, @S[StartPos+1], EndPos-StartPos)
else //cre
Buf[1] := #0; //cre
end;
end;
Carl Efird
Email: efirdcr@bechteljacobs.org
Phone - (865)241-1191
Pager - (865)873-7259
Fax - (865)576-7489