Knowledge Base Alert August, 2015


VCL

FIREMONKEY

INTRAWEB

TAdvStringGrid:

How to have 2 different font colors for text within 1 cell



TAdvStringGrid supports the HTML as described at: http://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;




TMS Toolpanels

Programmatically inserting a toolpanel



This code snippet shows how to programmatically insert a toolpanel:

var
  tp: TAdvToolPanel;
begin
  tp := TAdvToolPanel.Create(advtoolpanelTab1);
  tp.Caption := 'New panel';
  AdvToolPanelTab1.InsertPanel(tp);
end;


TAdvRichEditor:

How to copy formatted text from a TAdvRichEditor to a TPlannerItem



To move the content of TAdvRichEditor with formatting to a selected PlannerItem, following code can be used:

begin
  if Assigned(planner1.Items.Selected) then
  begin
    planner1.Items.Selected.Text.Text := advricheditor1.ContentAsRTF;
  end;
end;


TAdvRichEditor:

Sending TAdvRichEditor formatted text by email



Sending an email with the formatted text created by TAdvRichEditor is really simple. To do so, drop a TAdvRichEditor on the form and the Indy idSMTP component. The content of the TAdvRichEditor can be sent with:

var
  msg: TIdMessage;
  Textpart: TidText;

begin
  msg := TIdMessage.Create(self);

  try
    msg.ContentType := 'multipart/alternative';

    TextPart := TIdText.Create(msg.MessageParts);
    TextPart.ContentType := 'text/plain';
    TextPart.Body.Clear;
    TextPart.Body.Text := AdvRichEditor1.ContentAsPlainText;

    TextPart := TIdText.Create(msg.MessageParts);
    TextPart.ContentType := 'text/html';
    TextPart.Body.Clear;
    TextPart.Body.Text := AdvRichEditor1.ContentAsHTML;

    msg.From.Address := 'developer@delphi.com';
    msg.From.Text := 'Delphi Developer';

    msg.Recipients.Add.Address := 'joe.do@mailbox.com';
    msg.Subject := 'Your message subject here’;
    IdSMTP1.Send(msg);
  finally 
    msg.Free;
  end;

end;


TMS Cloud Pack:

Displaying the login page in the TWebBrowser control



If a login page from a cloud service is not correctly displayed in the TWebBrowser control, you can force your app to use a newer emulated IE version in the Windows registry by adding the executable name at the following location in the registry:

HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER
\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION

Detailed information can be found here: https://msdn.microsoft.com/en-us/library/ee330730(VS.85).aspx#browser_emulation

TTMSFMXPlanner:

Fixed background items



Fixed background items are currently not supported, but you can accomplish this with custom drawing:

procedure TForm1.TMSFMXPlanner1AfterDrawCell(Sender: TObject; ACanvas: TCanvas;
  ARect: TRectF; ACol, ARow: Integer; AStartTime, AEndTime: TDateTime;
  APosition: Integer; AKind: TTMSFMXPlannerCacheItemKind);
begin
  if (HourOf(AStartTime) = 12) and (HourOf(AEndTime) = 13) then
  begin
    ACanvas.Fill.Color := claWhite;
    ACanvas.Font.Size := 20;
    ACanvas.FillText(ARect, 'LUNCH', False, 1, [], TTextAlign.Center, TTextAlign.Center);
  end;
end;

procedure TForm1.TMSFMXPlanner1BeforeDrawCell(Sender: TObject; ACanvas: TCanvas;
  ARect: TRectF; ACol, ARow: Integer; AStartTime, AEndTime: TDateTime;
  APosition: Integer; AKind: TTMSFMXPlannerCacheItemKind; var AAllow,
  ADefaultDraw: Boolean);
begin
  if (HourOf(AStartTime) = 12) and (HourOf(AEndTime) = 13) then
  begin
    ACanvas.Fill.Color := claSteelBlue;
    ACanvas.Fill.Kind := TBrushKind.Solid;
  end;
end;




TTMSFMXPlanner:

How to change default ContentPanel (Enter form)



The ContentPanel is internally mapped to a container which contains a remove, cancel and ok button. This is by design. The ContentPanel in our sample is replaced by a TPanel that is placed on the main form and set visible = false. Mapping from controls to item and vice versa is also demonstrated with a simple TEdit <> Item Title.

Here you can download the sample that demonstrates this.

TTMSFMXGrid:

How to change spacing between cell text and cell border



You can specify a variable textrect to accomplish this:

procedure TForm1.BeforeDrawGridCell(Sender: TObject; ACanvas: TCanvas;
  var ARect, ATextRect: TRectF; var ADrawText, ADrawBackGround,
  AllowDraw: Boolean);
begin
  InflateRect(ATextRect, -5, 0);
end;

procedure TForm1.TMSFMXGrid1GetCellLayout(Sender: TObject; ACol, ARow: Integer;
  ALayout: TTMSFMXGridCellLayout; ACellState: TCellState);
begin
  ALayout.TextAlign := TTextAlign.Trailing;
end;

procedure TForm1.TMSFMXGrid1GetCellProperties(Sender: TObject; ACol,
  ARow: Integer; Cell: TFmxObject);
begin
  if (Cell is TTMSFMXGridCell) then
  begin
    (Cell as TTMSFMXGridCell).OnBeforeDraw := BeforeDrawGridCell;
  end;
end;



TIWAdvMessageDialog:

How to determine which custom button has been clicked



You can use the ButtonIndex parameter of the OnButtonClick event to determine which custom button has been clicked in the TIWAdvMessageDialog component. The indexes of the custom buttons start at 100. So a click on the first custom button will return a ButtonIndex of 100, the second custom button will return 101 and so on.


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.