Frequently Asked Component Specific Questions
Options |
Display all FAQ items |
Displaying items 226 to 240 of 886, page 16 of 60
<< previous next >>
TMS FMX UI Pack
TTMSFMXTreeView: How to dynamically add nodes
TTMSFMXTreeView: How to dynamically add nodes
This code snippet shows how to dynamically add nodes to the TMSFMXTreeView:
procedure TForm1.FormCreate(Sender: TObject); var n: TTMSFMXTreeViewNode; v: TTMSFMXTreeViewNode; begin TMSFMXTreeView1.BeginUpdate; TMSFMXTreeView1.Nodes.Clear; TMSFMXTreeView1.Columns.Clear; TMSFMXTreeView1.Columns.Add.Text := 'Test'; n := TMSFMXTreeView1.AddNode; n.Text[0] := 'Need load childs after in onBeforeExpandNode event'; v := TMSFMXTreeView1.AddNode(n); v.DataString := 'virtual'; TMSFMXTreeView1.EndUpdate; end; procedure TForm1.TMSFMXTreeView1BeforeExpandNode(Sender: TObject; ANode: TTMSFMXTreeViewVirtualNode; var ACanExpand: Boolean); var v: TTMSFMXTreeViewNode; I: Integer; begin if not Assigned(ANode.Node) then Exit; if ANode.Node.GetChildCount > 0 then begin v := ANode.Node.Nodes[0]; if v.DataString = 'virtual' then begin TMSFMXTreeView1.RemoveNode(v); for I := 0 to 9 do TMSFMXTreeView1.AddNode(ANode.Node).Text[0] := 'Dynamically added node ' + inttostr(I); end; end; end;
TMS FMX UI Pack
TTMSFMXDirectoryTreeView: Custom painting node
TTMSFMXDirectoryTreeView: Custom painting node
This code snippet shows how to paint a directory node with a trackbar that indicades the free space:
procedure TForm1.FormCreate(Sender: TObject); begin TMSFMXDirectoryTreeView1.NodesAppearance.FixedHeight := 40; TMSFMXDirectoryTreeView1.AddColumn(tvckFreeSpaceAndTotalSize); TMSFMXDirectoryTreeView1.Columns[1].VerticalTextAlign := tvtaLeading; TMSFMXDirectoryTreeView1.LoadDrives; end; procedure TForm1.TMSFMXDirectoryTreeView1AfterDrawNodeText(Sender: TObject; ACanvas: TCanvas; ARect: TRectF; AColumn: Integer; ANode: TTMSFMXTreeViewVirtualNode; AText: string); var r, rs: TRectF; fs, fst: Int64; s: String; begin if AColumn = 1 then begin s := TTMSFMXDirectoryTreeViewNode(ANode.Node).FileName; if ExtractFileDrive(s) + PathDelim = s then begin fst := DiskSize(Ord(UpperCase(s)[1]) - 64); fs := DiskFree(Ord(UpperCase(s)[1]) - 64); if (fst > -1) and (fs > -1) then begin r := ARect; r.Top := r.Bottom - 20; r.Height := 20; InflateRect(r, 0, -2); r.Width := r.Width - 2; r := RectF(Int(r.Left) + 0.5, Int(r.Top) + 0.5, Int(r.Right) - 0.5, Int(r.Bottom) - 0.5); rs := r; rs.Width := rs.Width * fs / fst; ACanvas.Fill.Kind := TBrushKind.Solid; ACanvas.Fill.Color := claWhite; ACanvas.FillRect(r, 0, 0, AllCorners, 1); ACanvas.Fill.Color := claSteelblue; ACanvas.FillRect(rs, 0, 0, AllCorners, 1); if TMSFMXDirectoryTreeView1.IsNodeSelected(ANode.Node) then ACanvas.Stroke.Color := claWhite else ACanvas.Stroke.Color := claDarkgray; ACanvas.DrawRect(r, 0, 0, AllCorners, 1); end; end; end; end;
TMS FlexCel for VCL & FMX
When generating xls/xlsx files with formulas, Excel shows a message to save when you are closing the file
When generating xls/xlsx files with formulas, Excel shows a message to save when you are closing the file
This message happens when you have any formula in the Excel file, and open it with different Excel versions.
The thing is: If you create a file with formulas in say Excel 2007 and then open the file in Excel 2010, Excel will recalculate all cells and show that message. Sometimes (not always) it also happens in the reverse: If you save with Excel 2010 it might ask you to save when you open in Excel 2007.
This isn’t a FlexCel issue: But in Excel you will normally not see this because in your test machine you will use the same Excel version to save and open the file. But as soon as you start delivering the file to customers, they will start seeing the message.
Now, FlexCel is only one “version": It is not Excel 2003, or 2007, or 2010. So when it creates a file, it needs to say “this file was created with Excel version …” in the file, and this is the value Excel will use to decide if it shows the message or not. If you know that say all your users are in Excel 2013, then you can tell FlexCel to say “this file was saved with Excel 2013” and Excel 2013 users won’t see the dialog. But users of a different version of Excel might.
If you are opening the file in Excel 2013 for example, you can get rid of the dialog by doing:
xls.RecalcVersion = TRecalcVersion.Excel2013;
or just do
xls.RecalcVersion = TRecalcVersion.SameAsInputFile;
to make FlexCel save the “version” used in recalculation as the same version the input file had.
TMS VCL WebGMaps
Using latitude/longitude coordinates instead of an address
Using latitude/longitude coordinates instead of an address
It is possible to use latitude/longitude coordinates for the Origin and Destination parameters instead of an address. There is an overload of the GetDirections method available which takes the OriginLatitude, OriginLongitude, DestinationLatitude and DestinationLongitude parameters.
Coordinates are also supported for WayPoints. There is no overload for this, but you can provide the coordinates as a string.
Example:
WayPoints.Clear; WayPoints.Add('48, 5'); WebGMaps1.GetDirections(50, 4, 47, 3, false, tmDriving, usMetric, lnDefault, false, false, WayPoints, false);
TAdvSmoothListBox
Customizing the ItemAppearance
Customizing the ItemAppearance
The appearance of the TAdvSmoothListBox and its items can be fully customized.
Following code:
procedure TForm1.AdvSmoothListBox1ItemBkgDraw(Sender: TObject; Canvas: TCanvas; itemindex: Integer; itemRect: TRect; var defaultdraw: Boolean); var g: TGPGraphics; begin defaultdraw := AdvSmoothListBox1.SelectedItemIndex <> itemindex; if not defaultdraw then begin g := TGPGraphics.Create(Canvas.Handle); g.SetSmoothingMode(SmoothingModeAntiAlias); AdvSmoothListBox1.ItemAppearance.FillSelected.Fill(g, MakeRect(itemrect.Left, itemrect.Top, itemrect.Width, itemrect.Height)); g.Free; end; end; procedure TForm1.FormCreate(Sender: TObject); var it: TAdvSmoothListBoxItem; I: Integer; begin AdvSmoothListBox1.BeginUpdate; AdvSmoothListBox1.Fill.Color := clBlack; AdvSmoothListBox1.ItemAppearance.Fill.Color := clBlack; AdvSmoothListBox1.ItemAppearance.Fill.ColorMirror := clNone; AdvSmoothListBox1.ItemAppearance.Fill.BorderColor := clBlack; AdvSmoothListBox1.ItemAppearance.Fill.GradientType := gtSolid; AdvSmoothListBox1.ItemAppearance.Fill.GradientMirrorType := gtNone; AdvSmoothListBox1.Header.Visible := False; AdvSmoothListBox1.Footer.Visible := False; AdvSmoothListBox1.Sections.BorderColor := AdvSmoothListBox1.ItemAppearance.Fill.Color; AdvSmoothListBox1.ItemAppearance.FillSelected.Assign(AdvSmoothListBox1.ItemAppearance.Fill); AdvSmoothListBox1.ItemAppearance.FillSelected.Color := clWebOrange; AdvSmoothListBox1.ItemAppearance.FillSelected.Rounding := 10; AdvSmoothListBox1.ItemAppearance.FillSelected.RoundingType := rtBoth; AdvSmoothListBox1.DefaultItem.CaptionFont.Color := clWhite; AdvSmoothListBox1.Items.Clear; for I := 0 to 19 do begin it := AdvSmoothListBox1.Items.Add; it.Caption := ''Item '' + inttostr(I + 1); end; AdvSmoothListBox1.EndUpdate; end;
Results in:
TDBAdvGrid
Persisting column sizes & column order for a TDBAdvGrid
Persisting column sizes & column order for a TDBAdvGrid
Assuming a user can resize & move columns around in a TDBAdvGrid and it is desirable that the last state is saved & restored when the application is restarted, this can be done in following way:
- Set default column order & size state after making the dataset active in the TDBAdvGrid with grid.SetColumnOrder
- When column states are found, restore these from INI file with grid.StringToColumnStates
- When the application closes, save the last state to INI file with grid.ColumnStatesToString
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean); var inif: TINIFile; begin inif := TINIFile.Create('.\settings.ini'); inif.WriteString('STATES','DBADVGRID1',DBAdvGrid1.ColumnStatesToString); inif.Free; end; procedure TForm1.FormCreate(Sender: TObject); var inif: TINIFile; colstates: string; begin adotable1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\CARS.mdb;Persist Security Info=False'; adotable1.Active := true; DBAdvGrid1.SetColumnOrder; DBAdvGrid1.Options := DBAdvGrid1.Options + [goColSizing, goColMoving]; inif := TINIFile.Create('.\settings.ini'); colstates := inif.ReadString('STATES','DBADVGRID1',''); inif.Free; if colstates <> '' then DBAdvGrid1.StringToColumnStates(colstates); end;
TAdvRichEditor
How to add color & font style formatted text
How to add color & font style formatted text
Adding color & font style formatted text to TAdvRichEditor can be done with setting a selection and calling AdvRichEditor.SetSelectionColor() or AdvRichEditor.SetSelectionBold(), etc.. but it can also be done by changing the AdvRichEditor.Font before adding new text.
Sample code:
begin AdvRichEditor1.Font.Style := [fsBold]; AdvRichEditor1.Font.Color := clBlue; AdvRichEditor1.AddText('Hello world,'); AdvRichEditor1.Font.Style := [fsItalic]; AdvRichEditor1.Font.Color := clRed; AdvRichEditor1.AddText('this text is in red italic'); end;
TMS FMX WebOSMaps
Fixing the FMX TWebBrowser issue on iOS 9
Fixing the FMX TWebBrowser issue on iOS 9
TMS FMX WebGMaps
Fixing the FMX TWebBrowser issue on iOS 9
Fixing the FMX TWebBrowser issue on iOS 9
TMS iCL
Fixing the FMX TWebBrowser issue on iOS 9
Fixing the FMX TWebBrowser issue on iOS 9
TMS FMX Cloud Pack
Fixing the FMX TWebBrowser issue on iOS 9
Fixing the FMX TWebBrowser issue on iOS 9
TMS FMX UI Pack
Fixing the FMX TWebBrowser issue on iOS 9
Fixing the FMX TWebBrowser issue on iOS 9
TAdvRichEditor
Supported Delphi versions
Supported Delphi versions
The oldest version of Delphi that is supported for TAdvRichEditor is Delphi XE. TAdvRichEditor internally uses generics which are not available in older versions of Delphi.
TMS IntraWeb Component Pack Pro
TMS IntraWeb Component Pack in Win64
TMS IntraWeb Component Pack in Win64
You can use IntraWeb components to build 64bit applications. Make sure the 64bit library path includes the folder where you installed TMS IntraWeb Component Pack sources. Design your app in 32bit and then switch project target to 64bit to compile it as a 64bit application.
TAdvStringGrid
How to have 2 different font colors for text within 1 cell
How to have 2 different font colors for text within 1 cell
TAdvStringGrid supports the HTML as described at: https://www.tmssoftware.com/site/minihtml.asp As such, to have different font colors, background colors,... in 1 cell, you can write:
procedure TForm4.FormCreate(Sender: TObject); begin AdvStringGrid1.Cells[1,1] := ''<P>Here is <FONT bgcolor="clBlue" color="clWhite">some</FONT> text</P>''; AdvStringGrid1.Cells[1,2]:= ''<P>Have <FONT color="clGreen">green</FONT> and <FONT color="clRed">red</FONT> text</P>''; AdvStringGrid1.Cells[1,3] := ''<P>This is a <FONT face="Arial" size="12" color="#FF0000">test</FONT></P>''; end;