Frequently Asked Component Specific Questions
Options |
Display all FAQ items |
Displaying items 361 to 375 of 508, page 25 of 34
<< previous next >>
TDBAdvGrid
Multi-column sorting in TDBAdvGrid
Multi-column sorting in TDBAdvGrid
When:
DBAdvGrid.PageMode := False; DBAdvGrid.SortSettings.Show := True; DBAdvGrid.SortSettings.IndexShow := True;
TCalcEdit
Supported functions
Supported functions
TCalcEdit uses the same formula parsing engine as TAdvSpreadGrid. You can find information on the supported functions in the TAdvSpreadGrid doc, revelant information starts on page 175.
TMS Logging
Supported Delphi versions
Supported Delphi versions
TMS Logging requires Delphi XE7 or newer due to technical Delphi language feature compatibility issues.
TAdvMultiInputQueryDialog
Sample code
Sample code
TAdvMultiInputQueryDialog is capable of displaying a dialog with multiple queries. After clicking OK, the values property can retrieve the value that has been entered, as demonstrated in the following sample.
var qv, qv2: TAdvMultiInputQueryValue; v, v2: String; begin AdvMultiInputQueryDialog1.LabelWidth := 150; qv := AdvMultiInputQueryDialog1.QueryValues.Add; qv.&Label := ''This is a question?''; qv.Name := ''value1''; qv := AdvMultiInputQueryDialog1.QueryValues.Add; qv.&Label := ''This is another question?''; qv.Name := ''value2''; AdvMultiInputQueryDialog1.Execute(True); v := AdvMultiInputQueryDialog1.Values[''value1''].ResultValue; v2 := AdvMultiInputQueryDialog1.Values[''value2''].ResultValue; end;
After clicking OK, v and v2 string values contain "Hello" & "World!"
TMS Sparkle
Using client-certificates with Sparkle in Windows
Using client-certificates with Sparkle in Windows
You can send client-certificates when performing HTTP requests using Sparkle, from Windows. The following code snippet shows how to do it. Two comments about the code:
a) You have to declare TInternalHTTPClient in the same unit you use the code below, preferable in the implementation section
b) This code snippet shows also how to retrieve the certificate from Windows store. It’s there as an example but you can and should replace with your own code to retrieve the certificate. That part of the code is not Sparkle-related and you should be familiar with the Windows API that handles certificates. The relevant Sparkle code is highlighted in bold.
TInternalHTTPClient = class(THttpClient) end; var httpClient: THttpClient; httpEngine: TWinHttpEngine; httpRequest: THttpRequest; httpResponse: THttpResponse; Store: HCERTSTORE; Cert: PCERT_CONTEXT; begin httpClient := THttpClient.Create; // Open the ''Personal'' SSL certificate store for the local machine and locate the required client-side certificate Cert := nil; Store := CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, CERT_SYSTEM_STORE_LOCAL_MACHINE, PChar(''MY'')); if (Store <> nil) then Cert := CertFindCertificateInStore(Store, X509_ASN_ENCODING, 0, CERT_FIND_SUBJECT_STR, PChar(''mycertsubject''), nil); // If a valid certificate was found then OK to create and send the HTTP request if (Cert <> nil) then begin // Setup HTTP request properties httpRequest := httpClient.CreateRequest; ... // Use ''BeforeWinHttpSendRequest'' event to set any HTTP request properties such as client-side SSL certificate httpEngine := TWinHttpEngine(TInternalHTTPClient(httpClient).Engine); httpEngine.BeforeWinHttpSendRequest := procedure (Req: HINTERNET) begin WinHttpCheck(WinHttpSetOption(Req, WINHTTP_OPTION_CLIENT_CERT_CONTEXT, Cert, SizeOf(CERT_CONTEXT))); end; // Execute HTTP request httpResponse := httpClient.Send(httpRequest); end;
TMS FMX UI Pack
TTMSFMXTableView: How to hide the header & footer
TTMSFMXTableView: How to hide the header & footer
To hide the header / footer you can use the following code:
procedure TForm1.FormCreate(Sender: TObject); begin TMSFMXTableView1.NeedStyleLookup; TMSFMXTableView1.ApplyStyleLookup; TMSFMXTableView1.GetHeaderRectangle.Visible := False; TMSFMXTableView1.GetFooterRectangle.Visible := False; end;
To make sure the header and footer rectangle elements are created, call NeedStyleLookup and ApplyStyleLookup once. An alternative way of hiding the those elements is in the OnApplyStyleLookup event:
procedure TForm1.TMSFMXTableView1ApplyStyleLookup(Sender: TObject); begin TMSFMXTableView1.GetHeaderRectangle.Visible := False; TMSFMXTableView1.GetFooterRectangle.Visible := False; end;
TMS LCL Cloud Pack
Using TMS LCL Components for Raspberry Pi
Using TMS LCL Components for Raspberry Pi
With the recently introduced TMS LCL Cloud Pack and the open-source TMS LCL HW Pack, building small Raspberry Pi based projects is easier than ever. In this example, the code for an appliance is presented that displays the number of visitors on a website on a Raspberry Pi 16x2 LCD backpanel.
This code fetches the page statistics from Google Analytics with the TMS LCL Cloud Pack TMSLCLCloudGAnalytics component
function TForm1.GetRTVisitors: string; var RT: TRealtimeMetricsArray; StartDate, EndDate: string; i: integer; error: string; Res: TGStringArray; begin Result := ‘’; StartDate := ''today''; EndDate := ''today''; SetLength(RT,1); RT[0] := rtActiveUsers; TMSLCLCloudGAnalytics1.RequestData.RealtimeMetrics := RT; // fetches data for the page coupled with Google Analytics ID set via ViewID Error := TMSLCLCloudGAnalytics1.GetData(TMSLCLCloudGAnalytics1.App.ViewID); If Error = ‘’ then begin Res := TMSLCLCloudGAnalytics1.Data.Data[0]; Result := Res[0]; end; end;
procedure TForm1.ButtonClick1 (Sender: TObject); begin TMSLCLAdaDispl16x2.Init; TMSLCLCloudGAnalytics1.Connect; end;
procedure TForm1.TMSLCLCloudGAnalytics1Connected(Sender: TObject); var s: string; begin s := GetRTVisitors; TMSLCLAdaDispl16x2.DrawText(‘Visitors:’ +s); end;
TMS VCL Cloud Pack
Simplified code to have our cloud components connect to a cloud service
Simplified code to have our cloud components connect to a cloud service
We have simplified the code that needs to be written to have our cloud components connect to a cloud service. Before it was needed to load persisted tokens, test the tokens, refresh tokens when needed or start a new authentication / authorization process. From now on, this is all simplified. When the cloud component application key & secret are set and the location where to persist tokens is specified, the code can be reduced to a call to Connect and handling the OnConnected event from where you can start calling the cloud service methods:
procedure TForm1.Button1Click(Sender: TObject); begin AdvOneDrive1.Connect; end; procedure TForm1.AdvOneDrive1Connected(Sender: TObject); begin Init; end;
TAdvOfficeTabSet
How to set the first left displayed tab
How to set the first left displayed tab
When there are a lot of tabs in TAdvOfficeTabSet, it is now possible to programmatically set the first left displayed tab so the user immediately sees the tab you want to focus instead of requiring a lengthy scroll operation. This is done via the new AdvOfficeTabSet.ScrollPosition property.
Example:
var i: integer; begin AdvOfficeTabSet1.AdvOfficeTabs.Clear; // enable fast inserting of many tabs AdvOfficeTabSet1.BeginUpdate; for i := 0 to 50 do begin AdvOfficeTabSet1.AdvOfficeTabs.Add.Caption := ''Tab ''+ inttostr(i + 1); end; AdvOfficeTabSet1.EndUpdate; // first tab will be tab 25 AdvOfficeTabSet1.ScrollPosition := 25; end;
TAdvRichEditor
How to use a watermark
How to use a watermark
It is easy to use a watermark for TAdvRichEditor. To do this, simply implement the OnDrawBackground event and in this event, you can use the canvas to draw whatever watermark you may want for the TAdvRichEditor.
Example:
var png: TPNGImage; procedure TForm4.FormCreate(Sender: TObject); begin png := TPNGImage.Create; png.LoadFromFile(''e:\tms\temp\watermark-news.png''); end; procedure TForm4.FormClose(Sender: TObject; var Action: TCloseAction); begin png.Free; end; procedure TForm4.AdvRichEditor1DrawBackground(Sender: TObject; ACanvas: TCanvas; ARect: TRect); begin ACanvas.Draw(0,0,png); end;
TMS VCL Chart
Custom x-axis value drawing
Custom x-axis value drawing
The distance between X-Axis values is determined by the X-Scale, which is calculated based on the RangeFrom and RangeTo properties on pane level. Additionally, the X-Axis can display major units and minor units with their own font size. Below is a sample that demonstrates this:
procedure TForm127.DrawXAxisValue(Sender: TObject; Serie: TChartSerie; Canvas: TCanvas; ARect: TRect; ValueIndex, XMarker: integer; Top: Boolean; var defaultdraw: Boolean); var s: string; tw: Integer; begin if Odd(ValueIndex) then begin DefaultDraw := False; s := IntToStr(ValueIndex); tw := Canvas.TextWidth(s); Canvas.Pen.Color := clRed; Canvas.MoveTo(XMarker, ARect.Top); Canvas.LineTo(XMarker, ARect.Top + 15); Canvas.Font.Color := clRed; Canvas.TextOut(XMarker - tw div 2, ARect.Top + 17, s); end; end; procedure TForm127.FormCreate(Sender: TObject); var I: Integer; begin AdvGDIPChartView1.BeginUpdate; AdvGDIPChartView1.InitSample; AdvGDIPChartView1.Panes[0].Range.RangeTo := 15; AdvGDIPChartView1.Panes[0].XAxis.AutoSize := True; AdvGDIPChartView1.Panes[0].Series[2].Free; AdvGDIPChartView1.Panes[0].Series[1].Free; AdvGDIPChartView1.Panes[0].Series[0].ClearPoints; AdvGDIPChartView1.Panes[0].Series[0].AutoRange := arEnabled; AdvGDIPChartView1.Panes[0].Series[0].XAxis.AutoUnits := False; AdvGDIPChartView1.Panes[0].Series[0].XAxis.MajorUnit := 2; AdvGDIPChartView1.Panes[0].Series[0].XAxis.MinorUnit := 1; AdvGDIPChartView1.Panes[0].Series[0].OnXAxisDrawValue := DrawXAxisValue; for I := 0 to 14 do AdvGDIPChartView1.Panes[0].Series[0].AddSinglePoint(Random(100)); AdvGDIPChartView1.EndUpdate; end;
TDBPlanner
Position gap area colors
Position gap area colors
With the new OnPositionGapProp() event in T(DB)Planner, it is now possible to color code particular things in the position gap area. The position gap is enabled with setting Planner.PositionGap to a value different from zero. When this is enabled, the event OnPositionGapProp is triggered and via ABrush & APen properties, the position gap area color can be dynamically changed.
Sample code:
var workhourstart: TDateTime; workhourend: TDateTime; lunchhourstart: TDateTime; lunchhourend: TDateTime; procedure TForm4.FormCreate(Sender: TObject); begin Planner1.PositionGap := 10; workhourstart := EncodeTime(8,0,0,0); workhourend := EncodeTime(17,0,0,0); lunchhourstart := EncodeTime(12,0,0,0); lunchhourend := EncodeTime(13,0,0,0); end; procedure TForm4.Planner1PositionGapProp(Sender: TObject; Position, Index: Integer; ABrush: TBrush; APen: TPen); var dt: TDateTime; begin dt := Frac(Planner1.CellToTime(Position, Index)); if (dt >= workhourstart) and (dt <= workhourend) then begin ABrush.Color := clYellow; APen.Color := clYellow; end; if (dt >= lunchhourstart) and (dt <= lunchhourend) then begin ABrush.Color := clWebOrange; APen.Color := clWebOrange; end; end;
TPlanner
Position gap area colors
Position gap area colors
With the new OnPositionGapProp() event in T(DB)Planner, it is now possible to color code particular things in the position gap area. The position gap is enabled with setting Planner.PositionGap to a value different from zero. When this is enabled, the event OnPositionGapProp is triggered and via ABrush & APen properties, the position gap area color can be dynamically changed.
Sample code:
var workhourstart: TDateTime; workhourend: TDateTime; lunchhourstart: TDateTime; lunchhourend: TDateTime; procedure TForm4.FormCreate(Sender: TObject); begin Planner1.PositionGap := 10; workhourstart := EncodeTime(8,0,0,0); workhourend := EncodeTime(17,0,0,0); lunchhourstart := EncodeTime(12,0,0,0); lunchhourend := EncodeTime(13,0,0,0); end; procedure TForm4.Planner1PositionGapProp(Sender: TObject; Position, Index: Integer; ABrush: TBrush; APen: TPen); var dt: TDateTime; begin dt := Frac(Planner1.CellToTime(Position, Index)); if (dt >= workhourstart) and (dt <= workhourend) then begin ABrush.Color := clYellow; APen.Color := clYellow; end; if (dt >= lunchhourstart) and (dt <= lunchhourend) then begin ABrush.Color := clWebOrange; APen.Color := clWebOrange; end; end;
TAdvStringGrid
How to customize colors in the dropdown color cube
How to customize colors in the dropdown color cube
You can customize the colors of each cell in the color cube selection of TAdvColorPickerDropDown by implementing the OnDropDown event and in this event handler write the code:
procedure TForm4.AdvColorPickerDropDown1DropDown(Sender: TObject; var acceptdrop: Boolean); begin AdvColorPickerDropDown1.CubePanel.CubeCellColor[0] := clred; AdvColorPickerDropDown1.CubePanel.CubeCellColor[1] := clgreen; AdvColorPickerDropDown1.CubePanel.CubeCellColor[2] := clblue; AdvColorPickerDropDown1.CubePanel.CubeCellColor[3] := clblack; end;
TAdvStringGrid
Raw sort compare with virtual grid
Raw sort compare with virtual grid