Knowledge Base Alert June, 2015


VCL

FIREMONKEY

INTRAWEB

DEVELOPER TOOLS

TAdvOfficeHint:

How to use TAdvOfficeHint for controls that do not have an OfficeHint property



You can use TAdvOfficeHint also for controls that do not have an OfficeHint property, for example in our HTML controls. By implementing the event OnBeforeShowHint, you can control the information for the hint also for controls that do not have an OfficeHint property, only a hint property. This way, you do not need to use THTMLHint. TAdvOfficeHint can also display HTML formatted text.

TMS Advanced Charts:

How to use gantt charts



Included is a sample that demonstrates how to use gantt charts.

TMS Advanced Charts:

How to configure the y-axis and y-grid of a spider chart



Simply drop a chart on the form and set the code in the formcreate. The y-axis and y-grid are configured to display every 20 units.

Sample code:

var
  s: TChartSerie;
  p: TChartPane;
  I: Integer;
begin
  AdvGDIPChartView1.BeginUpdate;
  AdvGDIPChartView1.Panes.Clear;
  p := AdvGDIPChartView1.Panes.Add;
  p.YAxis.AutoUnits := False;
  p.YGrid.AutoUnits := False;
  s := p.Series.Add;
  s.ChartType := ctSpider;
  s.Pie.Size := 300;
  s.YAxis.AutoUnits := False;

  s.YAxis.MajorUnit := 50;
  s.YAxis.MinorUnit := 10;

  p.YGrid.MinorDistance := 10;
  p.YGrid.MajorDistance := 50;

  p.YGrid.MajorLineColor := clRed;

  for I := 0 to 9 do
  begin
    s.AddSinglePoint((I + 1) * 10);
  end;

  AdvGDIPChartView1.EndUpdate;



TColumnComboBox:

How to copy columns and their items from one TColumnComboBox to another instance



This code performs a fast copy of all columns and their items from one TColumnComboBox to another instance:

begin
  ColumnComboBox2.BeginUpdate;

  ColumnComboBox2.Columns.Assign(ColumnComboBox1.Columns);

  ColumnComboBox2.ComboItems.Assign(ColumnComboBox1.ComboItems);

  ColumnComboBox2.EndUpdate;
end;


TTMSFMXGrid:

How to set a bitmap client-aligned in a grid cell



Sample code:

procedure TForm1.TMSFMXGrid1GetCellProperties(Sender: TObject; ACol,
  ARow: Integer; Cell: TFmxObject);
begin
  if Cell is TTMSFMXBitmapGridCell then
    (Cell as TTMSFMXBitmapGridCell).Bitmap.Align := TAlignLayout.Client; 
end;


TTMSFMXGrid:

How to have multiple columns with etComboBox type



To have several columns in the combobox, you need to fill the CellComboBox through an event, that is triggered before the combobox is shown.

Sample code:
procedure TForm1.FormCreate(Sender: TObject);
begin
  TMSFMXGrid1.DefaultColumnWidth := 100;
end;

procedure TForm1.TMSFMXGrid1CellEditGetData(Sender: TObject; ACol,
  ARow: Integer; CellEditor: TFmxObject; var CellString: string);
begin
  if CellEditor is TComboBox then
  begin
    (CellEditor as TComboBox).Items.Clear;
    (CellEditor as TComboBox).Items.Add('Item 1 for ' + IntToStr(ACol) + ':' + IntToStr(ARow));
    (CellEditor as TComboBox).Items.Add('Item 2 for ' + IntToStr(ACol) + ':' + IntToStr(ARow));
    (CellEditor as TComboBox).Items.Add('Item 3 for ' + IntToStr(ACol) + ':' + IntToStr(ARow));
  end;
end;

procedure TForm1.TMSFMXGrid1GetCellEditorType(Sender: TObject; ACol,
  ARow: Integer; var CellEditorType: TTMSFMXGridEditorType);
begin
  CellEditorType := etComboBox;
end;


TTMSFMXPlanner:

LiveBindings



The TTMSFMXPlanner is currently not LiveBindings enabled. We have already added this on our feature request list for investigation. Currently, the planner needs to display items by adding them to the collection manually. If you want to retrieve them from a database, you will need to write the traditional first next loop. Each item has a DBKey property that can be filled with the unique key of the item in the database. I suggest to write a query that fetches the items between the display start and end time in the planner. The current display start and end time can be retrieved with:

  TMSFMXPlanner1.DisplayStartDateTime;
  TMSFMXPlanner1.DisplayEndDateTime;

You can navigate to the next or previous date / time with the navigation buttons at the top (Interaction.TopNavigationButtons), or programmatically with:

  TMSFMXPlanner1.NavigateToNextDateTime / TMSFMXPlanner1.NavigateToPreviousDateTime.

Reloading the query can be done in the OnAfterNavigateToDateTime.

TTMSFMXPlanner:

How to use a custom editor for inserting and updating items



Using a custom editor is demonstrated in the Editing demo. You need to drop a custom content panel / control on the form and pass it through the OnGetCustomContentPanel event. The OnItemToCustomContentPanel and OnCustomContentPanelToItem is used to transfer data between item and panel.

procedure TForm1.TMSFMXPlanner1CustomContentPanelToItem(Sender: TObject;
  AContentPanel: TControl; AItem: TTMSFMXPlannerItem); var
  c: TCheckBox;
  b: TColorComboBox;
begin
  c := FindChild(AContentPanel, 'chkOperation') as TCheckBox;
  b := FindChild(AContentPanel, 'cboCategory') as TColorComboBox;
  AItem.BeginUpdate;
  AItem.Color := b.Color;
  AItem.DataBoolean := c.IsChecked;
  AItem.EndUpdate;
end;

procedure TForm1.TMSFMXPlanner1GetCustomContentPanel(Sender: TObject;
  AItem: TTMSFMXPlannerItem; var AContentPanel: TControl); begin
  if Assigned(AItem) and (AItem.Resource = 1) then
    AContentPanel := Panel1;
end;

procedure TForm1.TMSFMXPlanner1ItemToCustomContentPanel(Sender: TObject;
  AItem: TTMSFMXPlannerItem; AContentPanel: TControl); var
  l: TLabel;
  c: TCheckBox;
  img: TImage;
  b: TColorComboBox;
begin
  l := FindChild(AContentPanel, 'lblPatient') as TLabel;
  l.Text := 'Patiënt: ' + AItem.Title;
  c := FindChild(AContentPanel, 'chkOperation') as TCheckBox;
  c.IsChecked := AItem.DataBoolean;
  img := FindChild(AContentPanel, 'imgPatient') as TImage;
  img.Bitmap.Assign(TMSFMXBitmapContainer1.FindBitmap(AItem.DataString));
  b := FindChild(AContentPanel, 'cboCategory') as TColorComboBox;
  b.Color := AItem.Color;
end;

TIWAdvEdit:

+ and - signs



The - sign is only allowed if Signed is set to true and if it is placed in the first position of the TIWAdvEdit text.
The + sign is not allowed with EditType set to edFloat.

TTIWResponsiveList:

How to add a section to the TTIWResponsiveList.



To add a section to the IWResponsiveList set the IsSection property to true of an Item in the Items collection.

TTIWResponsiveList:

How to add an item with an input field and a button that retrieves the value of the input field



You can use HTML tags to add form controls to an item. Assign the onclick handler of an HTML button to trigger the OnAsyncControlEvent. Use the OnAsyncControlEvent to execute the AsyncGetAttributes call. For a text field you can use the “value” attribute. The OnAsyncGetAttributes event then returns the requested attribute value(s).

Sample code:
procedure TformResponsiveList1.IWAppFormCreate(Sender: TObject);
var
  li: TIWListItem;
begin
    li := TIWResponsiveList1.Items.Add;
    li.Text.Add('
<input type="text" id="textid" value="test">'); li.Text.Add('
<input type="button" id="button" value="Button" onclick="' + TIWResponsiveList1.HTMLName + 'ControlEventHandler(event, ''ButtonClick'')">'); end; procedure TformResponsiveList1.TIWResponsiveList1AsyncControlEvent( Sender: TObject; EventParams: TStringList; EventType, ControlID: string; ItemIndex: Integer); var id, att: TStringList; begin if EventType = 'ButtonClick' then begin id := TStringList.Create; id.Add('textid'); att := TStringList.Create; att.Add('value'); TIWResponsiveList1.AsyncGetAttributes(ItemIndex, id, att); id.Free; att.Free; end; end; procedure TformResponsiveList1.TIWResponsiveList1AsyncGetAttributes( Sender: TObject; EventParams: TStringList; ItemIndex: Integer; ControlIDs, AttributeNames, AttributeValues: TStringList); begin WebApplication.ShowMessage(AttributeValues.Text); end;


TMS Aurelius:

Changing the way Aurelius saves dates in SQLite database



By default, Aurelius saves date values in SQLite as native Delphi TDateTime values, i.e., as double (float) values. This works fine if you are only using Aurelius to access the SQLite database. But if you have a legacy SQLite database or want other applications to read the database directly, you might need to use a different format. Aurelius offers two other alternative formats, which is Julian (saves the date values as Julian date times) or Text (which saves in text format “yyyy-mm-dd”).

To do that, add this code to the beginning of your application (choose the date time you want and uncomment the correct line).
Uses
 Aurelius.Sql.SQLite, Aurelius.Sql.Register;

Var
 SQLiteGenerator: TSQLiteSQLGenerator;
begin
 SQLiteGenerator := TSQLiteSQLGenerator.Create; 
//  SQLiteGenerator.DateType := TSQLiteSQLGenerator.TDateType.Delphi;
//  SQLiteGenerator.DateType := TSQLiteSQLGenerator.TDateType.Julian;
 SQLiteGenerator.DateType := TSQLiteSQLGenerator.TDateType.Text;
 TSQLGeneratorRegister.GetInstance.RegisterGenerator(SQLiteGenerator);





As always, we thank all users for the numerous inputs, feedback, comments and suggestions. This is an invaluable help to steer our developments here at TMS software. We continue to look forward to all your further communications to direct our team to provide you better tools and components for your needs.

Kind regards,
TMS software team
Email: info@tmssoftware.com
Web: http://www.tmssoftware.com
Support, FAQ & Manuals: http://www.tmssoftware.com/site/support.asp


Follow latest developments at tmssoftware.com


NOTICE: If you wish to unsubscribe from the TMS software Newsletter, please click here.