Frequently Asked Component Specific Questions
Options |
|
Display all FAQ items |
Displaying items 391 to 405 of 888, page 27 of 60
<< previous next >>

TMS Smooth Controls PackDrag drop in TAdvSmoothImageListBox
A sample which demonstrates drag drop on a TAdvSmoothImageListBox http://www.tmssoftware.net/public/Demo_DragDrop.zip

TAdvSysKeyBoardHookHow to disable a key
To disable a key, handle AdvSysKeyboardHook and set Allow parameter = false for key you want to display

TAdvListViewDrag & drop
This component is functionally equivalent to a standard TListView.
Drag & drop is handled by either setting AdvListView.DragMode = dmManual and implement a BeginDrag from an OnMouseMove for example or set AdvListView.DragMode = dmAuto and handle OnDragStart and other drag & drop related events.

TAdvPanelMoving and resizing panels at runtime
To move the panel, you'll need to set AdvPanel.CanMove = true and also set AdvPanel.Caption.Visible = true as moving is done by dragging the caption.
To re-size the panel, set AdvPanel.CanSize := true;

TAdvOfficeImageHow to autosize the component after loading a PNG file with AdvOfficeImage.Picture.LoadFromFile
Please use code similar to:
begin
AdvOfficeImage1.Picture.LoadFromFile('c:\temp\weather.png');
AdvOfficeImage1.Width := AdvOfficeImage1.Picture.Width;
AdvOfficeImage1.Height := AdvOfficeImage1.Picture.Height;
end;
TAdvAlertWindowCreate descending class with custom TMsgCollectionItem classes
Starting from version 1.8, it is possible to create a descendent class of TAdvAlertWindow where it is possible to use a custom extended class of TMsgCollectionItem as AlertMessages collection. This code makes it clear how this can be done:
type
TMsgCollectionItemEx = class(TMsgCollectionItem)
private
FExtra: string;
published
property Extra: string read FExtra write FExtra;
end;
TMsgCollectionEx = class(TMsgCollection)
protected
function GetItemClass: TCollectionItemClass; override;
end;
TAdvAlertWindowEx = class(TAdvAlertWindow)
protected
function CreateMsgCollection: TMsgCollection; override;
end;
implementation
{ TMsgCollectionEx }
function TMsgCollectionEx.GetItemClass: TCollectionItemClass;
begin
Result := TMsgCollectionItemEx;
end;
{ TAdvAlertWindowEx }
function TAdvAlertWindowEx.CreateMsgCollection: TMsgCollection;
begin
Result := TMsgCollectionEx.Create(Self);
end;
TMS FMX UI PackCompiling / Distribution for iOS
When creating your project in Delphi, and afterwards, generate a xcode compatible project (dpr2xcode.exe) there are some additional steps to be taken before the project will compile in xcode.
In the generated iOS version you will notice an xcode folder, with an xcode project file. Before opening this project file in xcode you need to copy the correct source files from the installation directory to the directory of this your xcode project:
- All the FMX_*.pas files - All the FMX_*.res files - The tmsdefsios.inc file
The last step to take is to rename the tmsdefsios.inc file to tmsdefs.inc file in order to compile correctly. After opening the project in xcode, click the run button, which will automatically compile and run the project in the simulator. Of course you can select to run it on a real device as well.

TMS FMX UI PackMy First FireMonkey Component
Below is a sample that is useful to understand the design of a new FireMonkey component. These three code snippets will result in your first control which has a backgroundrectangle, a button, an edit, and an additional rectangle.
This component only loads the style file as a layout, and is static. You can click on the button and type in the edit field, but the component has no properties to interact with.
fmx.MyFirstControl.pas
unit fmx.MyFirstControl;
interface
uses
FMX.Types, Types, Classes;
TMyFirstControl = class(TStyledControl)
private
public
constructor Create(AOwner: TComponent); override;
protected
function GetClassName: String; virtual;
function GetClassStyleName: String; virtual;
function GetStyleObject: TControl; override;
function LoadFromResource: TControl;
end;
procedure Register;
implementation
{$R fmx.myfirstcontrol.res}
procedure Register;
begin
RegisterComponents(‘My First FireMonkey Control’, [TMyFirstControl]);
end;
function TMyFirstControl.GetClassName: String;
begin
Result := ClassName;
end;
constructor TMyFirstControl.Create(AOwner: TComponent); override;
begin
inherited;
Width := 209;
Height := 105;
end;
function TMyFirstControl.GetClassStyleName: String;
begin
Result := GetClassName + 'style';
Delete(Result, 1, 1);
end;
function TMyFirstControl.GetStyleObject: TControl;
var
obj: TControl;
begin
obj := inherited GetStyleObject;
if not Assigned(obj) then
begin
// not found in default or custom style book, so create from resource
obj := LoadFromResource;
end;
Result := obj;
end;
function TMyFirstControl.LoadFromResource: TControl;
var
S: TResourceStream;
str: String;
begin
Result := nil;
// create resource class name
str := GetClassStyleName;
if FindRCData(HInstance, str) then
begin
// load from RT_RCDATA resource type
S := TResourceStream.Create(HInstance, str, RT_RCDATA);
try
Result := TControl(CreateObjectFromStream(nil, S));
finally
S.Free;
end;
end;
end;
initialization
RegisterFmxClasses([TMyFirstControl]);
end. fmx.myfirstcontrol.style
object TRectangle
StyleName = 'MyFirstControlStyle'
Position.Point = '(184,248)'
Width = 209.000000000000000000
Height = 105.000000000000000000
Fill.Kind = bkNone
Stroke.Kind = bkNone
object TRectangle
StyleName = 'background'
Align = alClient
Width = 209.000000000000000000
Height = 105.000000000000000000
object TButton
StyleName = 'Button1'
Position.Point = '(10,20)'
Width = 80.000000000000000000
Height = 22.000000000000000000
TabOrder = 0
Text = 'Button1'
end
object TEdit
StyleName = 'Edit1'
Position.Point = '(102,20)'
Width = 100.000000000000000000
Height = 22.000000000000000000
TabOrder = 1
KeyboardType = vktDefault
Password = False
end
object TRectangle
StyleName = 'rectangleElement'
Position.Point = '(11,48)'
Width = 65.000000000000000000
Height = 49.000000000000000000
Fill.Color = xFFFF4B4B
end
end
end fmx.myfirstcontrol.rc MyFirstControlStyle RCDATA "fmx.myfirstcontrol.style"
rt := (FindStyleResource(‘rectangleElement’) as TRectangle); rt.RotationAngle := MyRotationAngleProperty; //sample below 45°

TMS FMX UI PackFireMonkey Guidelines
More information on developing FireMonkey components and building / deploying on other platforms can be found on http://docwiki.embarcadero.com/RADStudio/en/FireMonkey_Components_Guide

TMS FMX UI PackUpdating the FireMonkey controls at runtime
To increase the performance, and to make sure all properties functions methods are executed and set, encapsulate every runtime update with a BeginUpdate and EndUpdate call.
var
i: integer;
begin
TMSFMXTableView1.BeginUpdate;
for i := 0 to 1000 do
begin
TMSFMXTableView1.Items.Add.Caption := 'item '+ inttostr(i);
end;
TMSFMXTableView1.EndUpdate;
end; var i: integer; begin TMSFMXGrid1.BeginUpdate; TMSFMXGrid1.ColumnWidths[2] := 100; TMSFMXGrid1.EndUpdate; end;

TAdvSmoothPageSliderHow to create a new page at runtime
To create a new page at runtime the following code can be used:
var sp: TAdvSmoothPage; begin sp:= TAdvSmoothPage.Create(AdvSmoothPageSlider1); sp.PageSlider := AdvSmoothPageSlider1; sp.Header := 'Runtime created page'; end;
AdvSmoothPage.Free;

TMS ToolPanelsHow to know if a panel is Rolled In or Rolled Out
You can retrieve this via
AdvToolPanelTab.Panels[index].State = psOpened

TDBAdvGridGeneral tips
For optimum performance, grid.PageMode should be set to true. Depending on the TDataSet used, it might further improve performance to implement the OnGetRecordCount event.
The grid supports internal sorting, filtering, grouping, lookupbar as opposed to sorting, filtering, grouping performed on dataset level. When it is preferred to use the grids internal implementation as opposed to the dataset level implementation, set grid.PageMode = false.
Features like disjunct row selection, rearranging data (with goRowMoving = true in grid.Options or via drag & drop) also require that grid.PageMode = false

TMS TableView for FireMonkeyUpdating the tableview
Updating the list will be done whenever an item is added but to increase the performance, encapsulate every list update with a BeginUpdate and EndUpdate call.
var
i: integer;
begin
TMSFMXTableView1.BeginUpdate;
for i := 0 to 1000 do
begin
TMSFMXTableView1.Items.Add.Caption := 'item '+ inttostr(i);
end;
TMSFMXTableView1.EndUpdate;
end; 
TDBAdvGridThe scrollbar is only limited to three positions
This behavior is caused by the dataset. When grid.PageMode = true and DataSetType = dtNonSequenced the grid only displays a buffer of visible records, the grid has no information at all where this buffer is positioned in the database except that it is the first buffer, last buffer or not the first or last buffer. Hence, there are only 3 possible scrollbar positions.
When you set grid.PageMode = false, the grid loads & shows all records and can thus show an exact scrollbar position.