procedure TForm1.Button1Click(Sender: TObject);
var
S: string;
begin
S := '你要查询的字符';
Memo1.SelStart := Pos(S, Memo1.Text);
if Memo1.SelStart > 0 then Memo1.SelLength := Length(S);
Memo1.SetFocus;
end;
var
S: string;
begin
S := '你要查询的字符';
Memo1.SelStart := Pos(S, Memo1.Text);
if Memo1.SelStart > 0 then Memo1.SelLength := Length(S);
Memo1.SetFocus;
end;
解决方案 »
- 表单以流的形式保存到数据库中
- JPG文件保存质量
- 新学delphi,关于窗体的三个问题,谢谢大哥。
- 请高手救命_SHFileOperation复制文件
- 有一个疑惑的问题,能不能赚到钱?
- fsMDIChild窗体调用fsMDIChild窗体里dbgrid上的数据,在返回时会出错!是怎么回事呀!大哥救救命呀!在线急等中!!
- 关于anywhere数据库中存储Image的问题
- 请帮忙解释一下VarArrayOf和VararrayLowBound、VararrayHighBound的用法,E文教差,看的糊涂!
- 怎么判断ClitDataSet.Delta为空
- 如何控制程序在系统里只允许打开一个(不允许一个程序在系统中同时开好几个)
- 大家帮我看一段小代码
- 不屏蔽ctrl+alt+del,但屏蔽热键alt+tab...如何实现?
首部 function SearchBuf(Buf: PChar; BufLen: Integer; SelStart, SelLength: Integer; SearchString: String; Options: TStringSearchOptions = [soDown]): PChar; $[StrUtils.pas
功能 返回第一个搜索到的指针位置
说明 这函数常用于文本中搜索字符串
参考 <NULL>
例子
///////Begin SearchBuf
function SearchEdit(EditControl: TCustomEdit; const SearchString: String;
SearchOptions: TStringSearchOptions; FindFirst: Boolean = False): Boolean;
var
Buffer, P: PChar;
Size: Word;
begin
Result := False;
if (Length(SearchString) = 0) then Exit;
Size := EditControl.GetTextLen;
if (Size = 0) then Exit;
Buffer := StrAlloc(Size + 1);
try
EditControl.GetTextBuf(Buffer, Size + 1);
P := SearchBuf(Buffer, Size, EditControl.SelStart, EditControl.SelLength,
SearchString, SearchOptions);
if P <> nil then begin
EditControl.SelStart := P - Buffer;
EditControl.SelLength := Length(SearchString);
Result := True;
end;
finally
StrDispose(Buffer);
end;
end;procedure TForm1.Button1Click(Sender: TObject);
var
SearchOptions: TStringSearchOptions;
begin
SearchOptions := [];
if CheckBox1.Checked then
Include(SearchOptions, soDown);
if CheckBox2.Checked then
Include(SearchOptions, soMatchCase);
if CheckBox3.Checked then
Include(SearchOptions, soWholeWord);
SearchEdit(Memo1, Edit1.Text, SearchOptions);
Memo1.SetFocus;
end;
///////End SearchBuf