Frequently Asked Component Specific Questions
Options |
Display all FAQ items |
Displaying items 181 to 195 of 886, page 13 of 60
<< previous next >>
TMS VCL Cloud Pack
Putting data in the cloud with myCloudData.net and component TAdvmyCloudData
Putting data in the cloud with myCloudData.net and component TAdvmyCloudData
If we’d want to persist application settings information in the cloud on http://myCloudData.net, this is very simple to do in Delphi.
After connecting with TAdvmyCloudData, we can test for the presence of the table that holds the data to persist, create table & metadata when it doesn’t exist and persist the data.
Code:
var table: TmyCloudDataTable; entity: TmyCloudDataEntity; doins: boolean; begin table := AdvMyCloudData1.TableByName(''APPDATA''); // create table with metadata on the fly if it doesn’t exist for the myCloudData.net account if not Assigned(table) then begin table := AdvMyCloudData1.CreateTable(''APPDATA''); table.MetaData.Add(''WINWIDTH'', ftInteger); table.MetaData.Add(‘WINHEIGHT’,ftInteger); table.MetaData.Add(''WINLEFT'', ftInteger); table.MetaData.Add(''WINTOP'', ftInteger); table.MetaData.Add(''USERNAME'', ftString,50); end; // check for existing entity holding the data table.Query; doins := table.Entities.Count = 0; if doins then entity := table.Entities.Add else entity := table.Entities[0]; // setting data to persist in the entity entity.Value[‘WINWIDTH’] := form.Width; entity.Value[‘WINHEIGHT’] := form.Height; entity.Value[‘WINLEFT’] := form.Left; entity.Value[‘WINTOP’] := form.Top; entity.Value[‘USERNAME’] := GetWindowsUser(); // inserting or updating entity if doins then entity.Insert else entity.Update; end;
TMS FMX UI Pack
TTMSFMXGrid: changing fixed cell font color
TTMSFMXGrid: changing fixed cell font color
To change the text color of fixed cells in the grid, following code can be used:
procedure TForm1.TMSFMXGrid1GetCellLayout(Sender: TObject; ACol, ARow: Integer; ALayout: TTMSFMXGridCellLayout; ACellState: TCellState); begin if (ARow = 0) then ALayout.FontFill.Color := claOrange; end;
After installing a new version of the TMS Async and running my application, I get an error similar to : [Dcc32 Fatal Error] VaClasses.pas (25): F2613 Unit 'Graphics' not found.
Make sure that in your project, unit scope names are set to:
Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell
TMS VCL Chart
Exporting to PDF
Exporting to PDF
To print the chart to a PDF, you can use following code:
with printer do begin BeginDoc; AdvChartView2.PrintAllPanes(Printer.Canvas,Rect(0, 0, printer.PageWidth, printer.PageHeight)); EndDoc; end;
TAdvStringGrid
Remove the context menu at right mouse click
Remove the context menu at right mouse click
When the inplace editor is active in the TAdvStringGrid, a menu appears when you right click the mouse. This is the default Windows context menu for an edit control. You also see this when dropping a standard VCL TEdit on the form. If you want to remove this, drop a new (empty) TPopupMenu on the form and use the event handler:
procedure TForm4.AdvStringGrid1GetEditorProp(Sender: TObject; ACol, ARow: Integer; AEditLink: TEditLink); begin advstringgrid1.NormalEdit.PopupMenu := PopupMenu1; end;
TAdvStringGrid
Raw sort compare with virtual grid
Raw sort compare with virtual grid
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;
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;
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;
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;
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;
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;
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;
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 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;