Frequently Asked Component Specific Questions
Options |
Display all FAQ items |
Displaying items 421 to 435 of 508, page 29 of 34
<< previous next >>
TAdvTreeView
Using the DataObject
Using the DataObject
The DataObject can hold any object you like, but you are responsible for cleaning up any references to avoid memory leaks.
A typical use:
type TPerson = class FName: string; FBirthDay: TDateTime; public constructor Create(AName: string; ABirthDay: TDateTime); property Name: string read FName; property BirthDay: TDateTime read FBirthDay; end; ... implementation ... procedure TForm1.FormCreate(Sender: TObject); var I: Integer; n: TAdvCheckedTreeViewNode; begin FPersons := TObjectList<TPerson>.Create; FPersons.Add(TPerson.Create(''Tom Jones'', EncodeDate(2016, 1, 1))); FPersons.Add(TPerson.Create(''John Appleseed'', EncodeDate(2016, 1, 2))); AdvCheckedTreeView1.Nodes.Clear; AdvCheckedTreeView1.Columns[0].Text := ''Name''; AdvCheckedTreeView1.Columns.Add.Text := ''Birthday''; for I := 0 to FPersons.Count - 1 do begin n := TAdvCheckedTreeViewNode(AdvCheckedTreeView1.Nodes.Add); n.Text[0] := FPersons[I].Name; n.Text[1] := DateToStr(FPersons[I].Birthday); n.CheckTypes[0] := tvntCheckBox; n.DataObject := FPersons[I]; end; end; { TPerson } constructor TPerson.Create(AName: string; ABirthDay: TDateTime); begin FName := AName; FBirthday := ABirthDay; end; procedure TForm1.FormDestroy(Sender: TObject); begin FPersons.Free; end;
procedure TForm1.AdvCheckedTreeView1AfterCheckNode(Sender: TObject; ANode: TAdvTreeViewVirtualNode; AColumn: Integer); var p: TPerson; begin if Assigned(ANode.Node) and Assigned(ANode.Node.DataObject) then p := TPerson(ANode.Node.DataObject); end;
TAdvTreeView
Multi-column checked listbox via TAdvCheckedTreeView
Multi-column checked listbox via TAdvCheckedTreeView
procedure TForm1.FormCreate(Sender: TObject); var c: TAdvTreeViewColumn; n: TAdvTreeViewNode; I: Integer; begin AdvCheckedTreeView1.BeginUpdate; AdvCheckedTreeView1.Columns.Clear; c := AdvCheckedTreeView1.Columns.Add; c.Text := ''Col 1''; c := AdvCheckedTreeView1.Columns.Add; c.Text := ''Col 2''; c := AdvCheckedTreeView1.Columns.Add; c.Text := ''Col 3''; AdvCheckedTreeView1.Nodes.Clear; AdvCheckedTreeView1.NodesAppearance.LevelIndent := 0; AdvCheckedTreeView1.NodesAppearance.ExpandWidth := 0; AdvCheckedTreeView1.NodesAppearance.ExpandHeight := 0; AdvCheckedTreeView1.NodesAppearance.ShowLines := False; AdvCheckedTreeView1.NodesAppearance.SelectionArea := tsaFull; for I := 0 to 9 do begin n := AdvCheckedTreeView1.Nodes.Add; n.CheckTypes[0] := tvntCheckBox; n.Text[0] := ''Item '' + inttostr(I); n.Text[1] := ''Item '' + inttostr(I); n.Text[2] := ''Item '' + inttostr(I); end; AdvCheckedTreeView1.EndUpdate; end;
TMS VCL WebGMaps
Increase maximum number of allowed waypoints when using GetDirections
Increase maximum number of allowed waypoints when using GetDirections
The number of waypoints is limited to 8. When an API key is assigned, up to 23 waypoints are allowed. This is a limitation of the Google Directions API which we have no control over.
Example:
WebGMaps1.APIKey := ''abc'';
https://developers.google.com/maps/documentation/directions/usage-limits
TMS FNC UI Pack
TTMSFNCListBox: Rating
TTMSFNCListBox: Rating
procedure TForm3.FormCreate(Sender: TObject); var I: Integer; begin for I := 0 to TMSFNCListBox1.Items.Count - 1 do TMSFNCListBox1.Items[I].DataInteger := RandomRange(1, 6) end; procedure TForm3.TMSFNCListBox1AfterDrawItem(Sender: TObject; AGraphics: TTMSFNCGraphics; ARect: TRectF; AItem: TTMSFNCListBoxItem); var r: Integer; I: Integer; bmp: TBitmap; rrt: TRectF; begin r := AItem.DataInteger; bmp := TMSFNCBitmapContainer1.FindBitmap(''rating''); for I := 0 to r - 1 do begin rrt := RectF(Round(ARect.Right - ((bmp.Width + 4) * (I + 1))), Round(ARect.Top + (ARect.Height - bmp.Height) / 2), Round(ARect.Right - ((bmp.Width + 4) * I)), Round(ARect.Top + (ARect.Height - bmp.Height) / 2 + bmp.Height)); AGraphics.DrawBitmap(rrt, bmp); end; end;
TMS FMX UI Pack
TTMSFMXDirectoryTreeView: How to display folders first followed by files as in File Explorer
TTMSFMXDirectoryTreeView: How to display folders first followed by files as in File Explorer
You could accomplish this by using the following code.
procedure TForm1.FormCreate(Sender: TObject); begin TMSFMXDirectoryTreeView1.Filter := ''''; TMSFMXDirectoryTreeView1.LoadDirectory(''E:\''); TMSFMXDirectoryTreeView1.Sort(0, True, True, nsmDescending); end; procedure TForm1.TMSFMXDirectoryTreeView1AfterExpandNode(Sender: TObject; ANode: TTMSFMXTreeViewVirtualNode); begin TMSFMXDirectoryTreeView1.Sort(0, True, True, nsmDescending); end; procedure TForm1.TMSFMXDirectoryTreeView1NodeCompare(Sender: TObject; Node1, Node2: TTMSFMXTreeViewNode; AColumn: Integer; var ACompareResult: Integer); var n1: TTMSFMXDirectoryTreeViewNode; n2: TTMSFMXDirectoryTreeViewNode; begin n1 := TTMSFMXDirectoryTreeViewNode(Node1); n2 := TTMSFMXDirectoryTreeViewNode(Node2); ACompareResult := AnsiCompareStr(ExtractFileExt(n1.FileName), ExtractFileExt(n2.FileName)); if ACompareResult = 0 then ACompareResult := AnsiCompareStr(n1.StrippedHTMLText[AColumn], n2.StrippedHTMLText[AColumn]); ACompareResult := ACompareResult * -1; end;
TMS FixInsight
W1035 Return value of function '%s' might be undefined
W1035 Return value of function '%s' might be undefined
Did you know that Delphi compiler warning "W1035 Return value of function ''%s'' might be undefined" works only with simple types like integers, but never work for managed types like strings or interfaces?
Using FixInsight''s rule W521 you can handle ANY type:
function TForm1.TestInteger: Integer;
begin
end;
Delphi Compiler: W1035 Return value of function ''TForm1.TestInteger'' might be undefined
FixInsight: W521 Return value of function ''TForm1.TestInteger'' might be undefined
function TForm1.TestString: string;
begin
end;
Delphi Compiler: NOTHING
FixInsight: W521 Return value of function ''TForm1.TestString'' might be undefined
TWebPost
Post to a https URL
Post to a https URL
TWebPost can handle HTTPS under certain circumstances. (depends largely on the server side implementation of the HTTPS POST) To use HTTPS, use the WebPost.port = 443
TWebUpdate
TimeOut & ReceiveTimeOut
TimeOut & ReceiveTimeOut
First of all, TWebUpdate has a function .Connected: boolean that can return whether the PC is connected to the internet or not.
TimeOut:
Sets or retrieves an unsigned long integer value that contains the time-out value, in milliseconds, to use for Internet connection requests. Setting this option to infinite (0xFFFFFFFF) will disable this timer.
ReceiveTimeOut:
Sets or retrieves an unsigned long integer value that contains the time-out value, in milliseconds, to receive a response to a request. If the response takes longer than this time-out value, the request is canceled
Default values are zero, meaning , these values are not configured and system defaults are used.
Serial Comms over Bluetooth
If you have a Windows virtual serial port driver for your Bluetooth hardware, you can use TMS Async to communicate via the virtual Windows serial port over Bluetooth.
TMS VCL Chart
Using the Popup ToolBar
Using the Popup ToolBar
The chart supports displaying a helper popup toolbar that offers various functionality such as changing the series type, fill and line color as well a specifying the marker type and label visibility.
To enable the popup, set Popup.Enabled := True;
AdvChartView1.Popup.Enabled := True;
When clicking on a series point, slice, or bar depending on the chosen series type the popup will be shown and initialized based on the current settings of the series.
The popup options can be configured via the Popup.Options property. This allows you to show more or less dropdown pickers depending on the series configuration. Below is a sample that demonstrates displaying the full set of options versus a limited set with line color, type and width.
AdvChartView1.Popup.Options := AllOptions;
AdvChartView1.Popup.Options := [ctpoStroke, ctpoLineStyle, ctpoLineWidth];
TAdvStringGrid
Image drag & drop
Image drag & drop
Here you can download a demo that shows how you can
- Drag and drop of an image from one TAdvStringGrid to another TAdvStringGrid
- Drag and drop of an image from Windows Explorer to TAdvStringGrid
TMS Advanced Toolbars & Menus
Toggle between TMS Office hints and regular hints
Toggle between TMS Office hints and regular hints
You can easily toggle in the application between using TMS Office hints and regular hints via the code:
begin if NormalHints.Checked then HintWindowClass := THintWindow else HintWindowClass := TAdvOfficeHintWindow; end;
TAdvTreeView
Modifying the appearance of the TAdvCheckedTreeView with custom node indicators
Modifying the appearance of the TAdvCheckedTreeView with custom node indicators
Example:
procedure TForm1.FormCreate(Sender: TObject); var pn, n: TAdvTreeViewNode; I: Integer; begin AdvCheckedTreeView1.BeginUpdate; AdvCheckedTreeView1.ClearNodes; AdvCheckedTreeView1.ClearColumns; AdvCheckedTreeView1.Columns.Add.Text := ''''; AdvCheckedTreeView1.ColumnsAppearance.Layouts := []; AdvCheckedTreeView1.NodesAppearance.ShowLines := False; AdvCheckedTreeView1.NodesAppearance.LevelIndent := 0; AdvCheckedTreeView1.Color := RGB(51, 51, 51); AdvCheckedTreeView1.NodesAppearance.FontColor := clWhite; pn := AdvCheckedTreeView1.Nodes.Add; pn.Text[0] := ''Audi''; n := pn.Nodes.Add; n.Text[0] := ''A3''; n.CheckTypes[0] := tvntCheckBox; n := pn.Nodes.Add; n.Text[0] := ''A5''; n.CheckTypes[0] := tvntCheckBox; n := pn.Nodes.Add; n.Text[0] := ''R8 Spyder''; n.CheckTypes[0] := tvntCheckBox; pn := AdvCheckedTreeView1.Nodes.Add; pn.Text[0] := ''Mercedes''; n := pn.Nodes.Add; n.Text[0] := ''SLS''; n.CheckTypes[0] := tvntCheckBox; n := pn.Nodes.Add; n.Text[0] := ''SLK''; n.CheckTypes[0] := tvntCheckBox; n := pn.Nodes.Add; n.Text[0] := ''Maybach''; n.CheckTypes[0] := tvntCheckBox; n := pn.Nodes.Add; n.Text[0] := ''Sports Tourer''; n.CheckTypes[0] := tvntCheckBox; n := pn.Nodes.Add; n.Text[0] := ''Electric Drive''; n.CheckTypes[0] := tvntCheckBox; n := pn.Nodes.Add; n.Text[0] := ''Coupé''; n.CheckTypes[0] := tvntCheckBox; AdvCheckedTreeView1.NodesAppearance.ExpandNodeIcon.LoadFromFile(''ExpandIcon.png''); AdvCheckedTreeView1.NodesAppearance.CollapseNodeIcon.LoadFromFile(''CollapseIcon.png''); AdvCheckedTreeView1.NodesAppearance.ExpandWidth := 16; AdvCheckedTreeView1.NodesAppearance.ExpandHeight := 16; AdvCheckedTreeView1.EndUpdate; AdvCheckedTreeView1.ExpandAll; end;
TMS FNC UI Pack
TMSFNCGridDatabaseAdapter: Programmatically setup a FireDac database connection via the new TTMSFNCGridDatabaseAdapter
TMSFNCGridDatabaseAdapter: Programmatically setup a FireDac database connection via the new TTMSFNCGridDatabaseAdapter
Example:
uses DateUtils, Math, DB, FireDac.Comp.Client, FMX.TMSFNCGridDatabaseAdapter, FMX.TMSFNCGrid; procedure TForm1.FormCreate(Sender: TObject); const DBName = ''Sample.sdb''; FirstNames: array[0 .. 19] of string = (''John'', ''Sarah'', ''Fred'', ''Beth'', ''Eric'', ''Tina'', ''Thomas'', ''Judy'', ''Robert'', ''Angela'', ''Tim'', ''Traci'', ''David'', ''Paula'', ''Bruce'', ''Jessica'', ''Richard'', ''Carla'', ''James'', ''Mary''); LastNames: array[0 .. 11] of string = (''Parker'', ''Johnson'', ''Jones'', ''Thompson'', ''Smith'', ''Baker'', ''Wallace'', ''Harper'', ''Parson'', ''Edwards'', ''Mandel'', ''Stone''); var idx: Integer; ds: TDataSource; tbl: TFDMemTable; adapter: TTMSFNCGridDatabaseAdapter; g: TTMSFNCGrid; begin g := TTMSFNCGrid.Create(Self); g.Parent := Self; tbl := TFDMemTable.Create(Self); tbl.FieldDefs.Add(''ID'', ftInteger, 0, True); tbl.FieldDefs.Add(''Name'', ftString, 20, True); tbl.FieldDefs.Add(''Birthday'', ftDateTime, 0, True); tbl.FieldDefs.Add(''Salary'', ftCurrency, 0, True); tbl.Open; tbl.DisableControls; try tbl.EmptyDataSet; for idx := 0 to 99999 do begin tbl.Append; tbl.FieldByName(''ID'').AsInteger := idx; tbl.FieldByName(''Name'').AsString := FirstNames[Random(20)] + '' '' + LastNames[Random(12)]; tbl.FieldByName(''Birthday'').AsDateTime := IncDay(Now, RandomRange(-10000, 10000)); tbl.FieldByName(''Salary'').AsFloat := 20000.0 + Random(600) * 100; tbl.Post; end; tbl.First; finally tbl.EnableControls; end; tbl.Active := True; ds := TDataSource.Create(nil); ds.DataSet := tbl; adapter := TTMSFNCGridDatabaseAdapter.Create(Self); g.Adapter := adapter; adapter.Grid := g; adapter.DataSource := ds; adapter.Active := True; end;
TMS FNC UI Pack
TMSFNCHint: Enable HTML formatted hints in your FMX/VCL or LCL application
TMSFNCHint: Enable HTML formatted hints in your FMX/VCL or LCL application
Drop an instance of TTMSFNCHint on the form, set ShowHint to true on your component and set a Hint property. The hint can be HTML formatted based on the miniHTML reference.