Difference between revisions of "TFindDialog"

From Free Pascal wiki
Jump to navigationJump to search
Line 1: Line 1:
 
'''TFindDialog''' [[Image:tfinddialog.png]] is a component that aids in finding information. It can be found on the [[Dialogs tab]] of the [[Component Palette]].
 
'''TFindDialog''' [[Image:tfinddialog.png]] is a component that aids in finding information. It can be found on the [[Dialogs tab]] of the [[Component Palette]].
 +
 +
To activate a FindDalilog, just call its <tt>Execute()</tt> function. Create an <tt>OnFind</tt> method to perform the actual find.
  
 
[[image:component-TFindDialog.png]]
 
[[image:component-TFindDialog.png]]
Line 5: Line 7:
 
== Usage ==
 
== Usage ==
 
<syntaxhighlight>
 
<syntaxhighlight>
procedure TForm1.Button1Click(Sender: TObject);
+
procedure TMyForm.Button1Click(Sender: TObject);
 +
begin
 +
  FindDialog1.FindText := 'findme';
 +
  FindDialog1.Execute();
 +
end;
 +
 
 +
procedure TMyForm.FindDialog1Find(Sender: TObject);
 
var
 
var
   found: string;
+
   src: String;
 
begin
 
begin
   FindDialog1.FindText := 'findme';
+
   with Sender as TFindDialog do begin
  if FindDialog1.Execute() then
+
    src := ReplaceDialog1.FindText;
     found := FindDialog1.FindText
+
    k := Pos( src, Memo1.Lines.Text );
 +
    if k>0 then begin
 +
      Memo1.Selstart := k;
 +
      Memo1.SelLength := length( src );
 +
     end else
 +
      Beep();
 +
  end;
 
end;
 
end;
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 11:31, 11 September 2016

TFindDialog tfinddialog.png is a component that aids in finding information. It can be found on the Dialogs tab of the Component Palette.

To activate a FindDalilog, just call its Execute() function. Create an OnFind method to perform the actual find.

component-TFindDialog.png

Usage

procedure TMyForm.Button1Click(Sender: TObject);
begin
  FindDialog1.FindText := 'findme';
  FindDialog1.Execute();
end;

procedure TMyForm.FindDialog1Find(Sender: TObject);
var
  src: String;
begin
  with Sender as TFindDialog do begin
    src := ReplaceDialog1.FindText;
    k := Pos( src, Memo1.Lines.Text );
    if k>0 then begin
      Memo1.Selstart := k;
      Memo1.SelLength := length( src );
    end else
      Beep();
  end;
end;

See also


LCL Components
Component Tab Components
Standard TMainMenu • TPopupMenu • TButton • TLabel • TEdit • TMemo • TToggleBox • TCheckBox • TRadioButton • TListBox • TComboBox • TScrollBar • TGroupBox • TRadioGroup • TCheckGroup • TPanel • TFrame • TActionList
Additional TBitBtn • TSpeedButton • TStaticText • TImage • TShape • TBevel • TPaintBox • TNotebook • TLabeledEdit • TSplitter • TTrayIcon • TControlBar • TFlowPanel • TMaskEdit • TCheckListBox • TScrollBox • TApplicationProperties • TStringGrid • TDrawGrid • TPairSplitter • TColorBox • TColorListBox • TValueListEditor
Common Controls TTrackBar • TProgressBar • TTreeView • TListView • TStatusBar • TToolBar • TCoolBar • TUpDown • TPageControl • TTabControl • THeaderControl • TImageList • TPopupNotifier • TDateTimePicker
Dialogs TOpenDialog • TSaveDialog • TSelectDirectoryDialog • TColorDialog • TFontDialog • TFindDialog • TReplaceDialog • TTaskDialog • TOpenPictureDialog • TSavePictureDialog • TCalendarDialog • TCalculatorDialog • TPrinterSetupDialog • TPrintDialog • TPageSetupDialog
Data Controls TDBNavigator • TDBText • TDBEdit • TDBMemo • TDBImage • TDBListBox • TDBLookupListBox • TDBComboBox • TDBLookupComboBox • TDBCheckBox • TDBRadioGroup • TDBCalendar • TDBGroupBox • TDBGrid • TDBDateTimePicker
Data Access TDataSource • TCSVDataSet • TSdfDataSet • TBufDataset • TFixedFormatDataSet • TDbf • TMemDataset
System TTimer • TIdleTimer • TLazComponentQueue • THTMLHelpDatabase • THTMLBrowserHelpViewer • TAsyncProcess • TProcessUTF8 • TProcess • TSimpleIPCClient • TSimpleIPCServer • TXMLConfig • TEventLog • TServiceManager • TCHMHelpDatabase • TLHelpConnector
Misc TColorButton • TSpinEdit • TFloatSpinEdit • TArrow • TCalendar • TEditButton • TFileNameEdit • TDirectoryEdit • TDateEdit • TTimeEdit • TCalcEdit • TFileListBox • TFilterComboBox • TComboBoxEx • TCheckComboBox • TButtonPanel • TShellTreeView • TShellListView • TXMLPropStorage • TINIPropStorage • TJSONPropStorage • TIDEDialogLayoutStorage • TMRUManager • TStrHolder
LazControls TCheckBoxThemed • TDividerBevel • TExtendedNotebook • TListFilterEdit • TListViewFilterEdit • TLvlGraphControl • TShortPathEdit • TSpinEditEx • TFloatSpinEditEx • TTreeFilterEdit • TExtendedTabControl •
RTTI TTIEdit • TTIComboBox • TTIButton • TTICheckBox • TTILabel • TTIGroupBox • TTIRadioGroup • TTICheckGroup • TTICheckListBox • TTIListBox • TTIMemo • TTICalendar • TTIImage • TTIFloatSpinEdit • TTISpinEdit • TTITrackBar • TTIProgressBar • TTIMaskEdit • TTIColorButton • TMultiPropertyLink • TTIPropertyGrid • TTIGrid
SQLdb TSQLQuery • TSQLTransaction • TSQLScript • TSQLConnector • TMSSQLConnection • TSybaseConnection • TPQConnection • TPQTEventMonitor • TOracleConnection • TODBCConnection • TMySQL40Connection • TMySQL41Connection • TMySQL50Connection • TMySQL51Connection • TMySQL55Connection • TMySQL56Connection • TMySQL57Connection • TSQLite3Connection • TIBConnection • TFBAdmin • TFBEventMonitor • TSQLDBLibraryLoader
Pascal Script TPSScript • TPSScriptDebugger • TPSDllPlugin • TPSImport_Classes • TPSImport_DateUtils • TPSImport_ComObj • TPSImport_DB • TPSImport_Forms • TPSImport_Controls • TPSImport_StdCtrls • TPSCustomPlugin
SynEdit TSynEdit • TSynCompletion • TSynAutoComplete • TSynMacroRecorder • TSynExporterHTML • TSynPluginSyncroEdit • TSynPasSyn • TSynFreePascalSyn • TSynCppSyn • TSynJavaSyn • TSynPerlSyn • TSynHTMLSyn • TSynXMLSyn • TSynLFMSyn • TSynDiffSyn • TSynUNIXShellScriptSyn • TSynCssSyn • TSynPHPSyn • TSynTeXSyn • TSynSQLSyn • TSynPythonSyn • TSynVBSyn • TSynAnySyn • TSynMultiSyn • TSynBatSyn • TSynIniSyn • TSynPoSyn
Chart TChart • TListChartSource • TRandomChartSource • TUserDefinedChartSource • TCalculatedChartSource • TDbChartSource • TChartToolset • TChartAxisTransformations • TChartStyles • TChartLegendPanel • TChartNavScrollBar • TChartNavPanel • TIntervalChartSource • TDateTimeIntervalChartSource • TChartListBox • TChartExtentLink • TChartImageList
IPro TIpFileDataProvider • TIpHtmlDataProvider • TIpHttpDataProvider • TIpHtmlPanel
Virtual Controls TVirtualDrawTree • TVirtualStringTree • TVTHeaderPopupMenu