Tips, tricks and frequently asked questions for TMS components

On this page we will collect tips and tricks and frequently asked questions for the TMS components. If you have a tip, trick or question do not hesitate to contact us.

General tips

Installing multiple trial distributions

As Delphi & C++Builder perform strict binary compatibility checks on binary distributed units such as trial versions of the components, this can cause a problem when using multiple different binary component distributions that have a shared unit (such as the PictureContainer unit) This will prevent the installation of multiple binary trial distributions at the same time in Delphi or C++Builder. The only workaround to use these different trial distribution is to install these in different folders and use the different component packages alternatingly.


Using components with trial versions of Delphi or C++Builder

Borland does NOT support the use of binary component distributions with trial version of Delphi or C++Builder. As such, it is not possible to use TMS Component evaluation distributions with trial versions of Delphi or C++Builder. You can use registered full source based versions of the TMS Components though with trial versions of Delphi or C++Builder.


Installing component updates

Before installing component updates, make sure that ALL old version files (DCU, BPL, BPI, LIB, .. files) are removed from your Delphi or C++Builder library path. After installing new component versions and compiling applications that have been build with previous component versions, property errors can be raised upon running the applications. This is a common Delphi or C++Builder problem. Solve this by first opening ALL forms in the application that use the updated component, ignore ALL property errors upon opening the forms, save the form files and after this, rebuild the application. The problem will be solved.

Design time issues with TMS Component Pack Pro

When using the TMS Component Pack Pro components and problems appear such as
- "Could not Load Image, Invalid Format" error when assigning an image to picture components
- Right click menus do not appear for TAdvNavBar, TAdvPageControl, ToolPanels, grids, planners
this means you have not installed the design time package as instructed in INSTALL.TXT and README.TXT. Make sure to install the TMSDExx.DPK package and this issue will be solved.

TMS Component Pack Pro components appear on the Delphi 2006 palette but not on the C++Builder 2006 palette

Uninstall the TMS Component Pack Pro package files (TMSD2006.bdsproj & TMSDED2006.bdsproj). Reopen the project file TMSD2006.bdsproj and verify in the options that on the linker tab, the setting "Generate all C++ files" is checked. Rebuild & install the TMSD2006.bdsproj package. Repeat these steps also for TMSDED2006.bdsproj.

When installing components in C++Builder 2006 the error : "Delphi personality is required to load project" appears

The install process of components in C++Builder 2006 requires that the Delphi personality is loaded. Start the IDE with all personalities & proceed to install the components. After installing the components, you can restart the IDE with only the C++Builder personality.

IDE updates

Always make sure to have the latest update packs installed for the IDE that is used. For Delphi 6, make sure that the RTL3 update is also installed. If this is not the case, this can for some components result in the error : "Unit XXXXX was compiled with a different version of VarUtils.VarDateFromStr".


After uninstalling a component and installing a component update, some components no longer appear on the palette

Delphi or C++Builder has most likely moved the component to hidden components because of the uninstall. Go to the Configure Palette menu and unhide the component and these should reappear correct on the component palette.


Problem with DsgnIntf or DesignIntf not found

Open the package file editor and in the requires list, add DesignIde.dcp (Delphi) or DesignIde.bpi (C++Builder)


Problem with constants declared in different units with the same name

Delphi or C++Builder supports that constants in different units with the same name are used simultanously.
For example, the constant psOffice2003Blue is declared in both AdvPanel.pas & AdvOfficePagerStylers.pas.
To use these constants in an application that uses both units, prefix the constant with its namespace, ie:

For a TAdvPanel style, use AdvPanel.psOffice2003Blue and for a TAdvOfficePager style use AdvOfficePagerStylers.psOffice2003Blue


Does the license provide royalty free use of components ?

Yes, all components come with a license for royalty free use of the components when used in binary compiled applications


Single developer license vs site license

A site license allows an unlimited number of developers within the company holding the license to use the components for commercial application development and to obtain free updates for a full version cycle and priority email support. A single developer license allows ONE developer within a company to use the components for commercial application development, to obtain free updates and priority email support.  A single developer license is NOT transferable to another developer within the company or to a developer from another company.


Email address changes for registered users


Send an email with :
- current registration email
- current registration code
- new registration email
to info@tmssoftware.com and the database will be updated.
For single developer licenses, we can NOT change the email to another user email address.


Peer to peer support in newsgroups

This is available for registered users. Information to access the newsgroups can be found after login on the website.
 

Component related tips


TPictureContainer

1. Effectively using the TPictureContainer component

Article can be read
here



TPlanner


1. Create a planner item with direct editing

For creating a planner item by just starting to type the text that should go in the planner item, the OnPlannerKeyPress can be used. To make sure that the key that is pressed to create the planner item is the first character of the planner item text, following code can be used :



procedure TForm1.Planner1PlannerKeyPress(Sender: TObject; var key:char; position, fromSel, fromSelPrecis, toSel, toSelPrecis: Integer);
begin
  with planner1.Items.Add do
  begin
    itempos := position;
    itembegin := fromSel;
    itemend := toSel;
    captiontype := ctTime;
    Text.Add(key);
    Edit;
    planner1.MemoEdit.SelStart := 1;
    planner1.MemoEdit.SelLength := 0;
  end;
end;



TAdvColumnGrid, TAdvStringGrid, TAdvSpreadGrid

1. Still using the 3D style inplace combobox editor

Use following code in the OnGetCellEditor :

grid.ComboBox.Flat:=false;

2. Use a different inplace editor color than the cell color

Normally, the inplace edit control gets the same color as the cell color. Sometimes this behaviour is not wanted, especially when the cell that is edited must be highlighted. This can be down in the following way :


procedure TForm1.FormCreate(Sender: TObject);
begin
  AdvStringGrid1.Color := clSilver;
end;

procedure TForm1.AdvStringGrid1GetCellColor(Sender: TObject; ARow,
 ACol: Integer; AState: TGridDrawState; ABrush: TBrush; AFont: TFont);
begin
  if (acol = AdvStringGrid1.Col) and
     (arow = AdvStringGrid1.Row) then
  begin
    if Assigned(AdvStringGrid1.NormalEdit) then
      if (AdvStringGrid1.NormalEdit.Visible) then
        ABrush.Color := clWhite;
  end;
end; 


3. When using RowSelect, the first cell of the row is not highlighted as the other cells.

This can be easily solved by setting the option goDrawFocusSelect to true in the Options property.


4. Problems with FILECTRL.OBJ when installing in C++Builder


In C++Builder 6 : Add following line to the package CPP file : USEPACKAGE("vclx.bpi");
In C++Builder 5 : Add following line to the package CPP file : USEPACKAGE("vclx50.bpi");
In C++Builder 4 : Add following line to the package CPP file : USEPACKAGE("vclx40.bpi");

Also, never choose a package filename equal to any of the component filenames used.


5. Forcing a visible cell editor when the form is displayed in the grid

In the FormShow event, add these 2 methods :

grid.SetFocus;
grid.ShowInplaceEdit;


6. Setting an hourglass cursor during lengthy sort operations


Before the sort starts, the OnCanSort event is called. In this event, the crHourGlass cursor can specified either for the grid or for your application. When sorting is completed, the OnClickSort event is called, where you can set the cursor back to normal.

7. Printing only selected rows in disjunct row select mode

The disjunct row select mode is flexible to let the user select several non contiguous rows in a grid. When you want to print only the selected rows, the Print functions do not provide a possibility these rows. Thanks to the grid's row hiding capabilities this can be easily done by temporarily hide the non-selected rows, print the grid and then unhide these rows again. The code to hide only the not selected rows is :


var
  i,j: Integer;
begin
  i := 1;
  with AdvStringGrid do
  begin
    j := RowCount;
    while (i < j) do
      if not RowSelect[DisplRowIndex(i)] then 
        HideRow(i);
    Inc(i);
  end;
end;


To unhide the rows again after the print, the method UnHideRowsAll can be called.

8. Setting different max. edit lengths for the inplace editor

If the max. number of characters for editing should be limited, this can be done with then LengthLimit property of the inplace editor. When LengthLimit is 0, there is no limitation to the nr. of characters that can be typed in the editor.
To set a different max. nr of characters per column, following code can be used in the OnGetCellEditor event :


procedure TForm1.AdvStringGrid1GetEditorType(Sender: TObject; ACol,
  ARow: Integer; var AEditor: TEditorType);
begin
  if Assigned(AdvStringGrid1.NormalEdit) then
  begin
    case acol of
    1:AdvStringGrid1.NormalEdit.LengthLimit := 4;
    2:AdvStringGrid1.NormalEdit.LengthLimit := 8;
    else 
      AdvStringGrid1.NormalEdit.LengthLimit := 0
    end;
  end;
end;


This sets the max. edit length for column 1 to 4 characters, for column 2 to 8 eight characters and unlimited for all other columns.


9. Saving TAdvStringGrid to a JPEG file

With code below, the output of TAdvStringGrid is sent to a JPEG file:


var
  pBitmap: TBitmap;
  jp: TJPEGImage;
  R: TRect;
begin
  pBitmap := TBitmap.Create; //create a new instance of a bitmap
  jp := TJPEGImage.Create;   //create new instance of a jpg file
  R := Rect(0,0,950,760);    //parameters for rectangle
  pBitmap.Height := 622;     //set bmp height
  pBitmap.Width := 812;      //set bmp width
  AdvStringGrid1.PrintPreview(pBitmap.Canvas,R); //call Preview to paint to BMP canvas
  jp.Assign(pBitmap); //get picture from bitmap for JPG Image
  jp.SaveToFile('c:\temp\Grid.jpg'); //save picture as JPG File
  pBitmap.Free;
  jp.Free;
end;

10. Copying a grid as image on the clipboard
Following code copies TAdvStringGrid as an image on the clipboard:

var
  bmp: TBitmap;
  clip: TClipboard;
begin
  bmp := tbitmap.create;
  bmp.Width := advstringgrid1.Width;
  bmp.Height := advstringgrid1.Height;
  AdvStringGrid1.PaintTo(bmp.Canvas,0,0);
  clip := TClipboard.Create;
  clip.Assign(bmp);
  bmp.Free;
  clip.Free;
end;
 
11. Using TAdvStringGrid with Multilizer

In order to automatically translate applications that use TAdvStringGrid with Multilizer, exclude the class TAdvRichEdit in Multilizer. TAdvRichEdit is an internal class only used in TAdvStringGrid as inplace editor for rich text editing.
 

12. Vertical bottom or center alignment in the grid

Vertical alignment and wordwrap are mutually exclusive. This is due to a limitation in the Microsoft Windows text drawing API that does not allow to have wordwrapped text with other vertical alignment than top alignment. To enable vertically centered or bottom alignment, make sure to set grid.WordWrap to false.


13. Using TAdvStringGrid printer settings dialog combined with printer selection.

This code snippet shows how you can show the print setup dialog for users after which the printer selection is done.


procedure TForm1.PrintGrid;
begin
  AdvGridPrintSettings.Form.Caption := 'Print overview';
  AdvStringGrid.PrintSettings.FitToPage := fpAlways;
  AdvStringGrid.PrintSettings.Orientation := poLandscape; // initialize to default poLandscape
  if AdvGridPrintSettings.Execute then
  begin
    Printer.Orientation := AdvStringGrid.PrintSettings.Orientation;
    if PrinterSetupDialog.Execute then
    begin
      AdvStringGrid.PrintSettings.Orientation := Printer.Orientation;
      AdvStringgrid.Print;
    end;
  end;
end;


 

TDBAdvStringGrid

1. Dataset versus internal grid sort

When an internal grid sort is used, it is required that grid.KeepLinked is set to false. For performing a dataset sort from TDBAdvStringGrid, the technique shown in sample app http://www.tmssoftware.com/dbsort.zip can be used.


TSectionListBox

1. How to retrieve the selected items in a multiselect TSectionListBox

This example code copies all selected items from a TSectionListBox to a TListBox :


procedure TForm1.Button1Click(Sender: TObject);
var
  i,j,k:integer;
begin
  for i := 1 to sectionlistbox1.Sections.Count do
    if sectionlistbox1.sections.items[i-1].State = lssExpanded then
           for j := 1 to sectionlistbox1.sections.items[i-1].SubItems.Count do
         begin
             k := SectionListBox1.GetSectionListIndex (i-1)+j-1;        
       
      if sectionlistbox1.selected[k+1] then
          
        listbox1.Items.Add(sectionlistbox1.sections.items[i-1].SubItems[j-1]);  
     
    end;
end;


2. How to delete all selected items in a multiselect TSectionListBox

This procedure will delete all selected items from a TSectionListBox :

procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
 
  sectionidx,subitemidx: Integer;
begin
   i := 0;
 
  with sectionlistbox1 do
       while (i < Items.Count) do
       begin
           if Selected[i] then
           begin
               Selected[i] := False;
       
        GetListItemIndex(i,sectionidx,subitemidx);
       
        Sections.Items[sectionidx].subitems.Delete(subitemidx);
     
      end
           else
               inc(i);
   
end
end;


Mini HTML components

1. How to use the design-time mini HTML editor at run-time.

You can easily use the mini HTML design-time editor at run-time to allow users to edit the mini-HTML controls text at run-time. To allow this, use following steps : add the HTMLPROP unit to your project and add HTMLPROP to the uses clause in the unit from where you want to invoke the mini HTML editor. Add the following code to allow for example run-time editing of the content of a HTMLabel1 component :


var
  htmledit: THTMLEditor;
begin
  htmledit := THTMLEditor.Create(Self);
 
  try
       htmledit.memo1.lines.Text := htmlabel1.htmltext.Text;
   
    htmledit.ShowModal;
   
    htmlabel1.htmltext.Text := htmledit.memo1.lines.Text;
 
  finally
      htmledit.Free;
  end;
end;

A sample Delphi project with
this code can be downloaded here (assuming the HTMLabel component is available on
the component palette.

HotSpotImage

1. How to use the hotspot design-time editor at run-time.


You can easily use the hotspot design-time editor at run-time to allow users to edit hotspot run-time. To allow this, use following steps :

1. Add HotSpotEditor in the Uses list of the unit from where you want to use this

2. Following code shows the hotspot editor (supposing there is a HotSpotImag1 component on the form you wish to edit at run-time):


uses
  HotSpotEditor;
 
procedure TForm1.Button1Click(Sender: TObject);
var
  frmEditor: TfrmHSIEditor;              
begin
  FHotSpots.Assign(HotSpotImage1.HotSpots); 
 
  FPicture.Assign(HotSpotImage1.Picture);                                                                       
 
                                      
  frmEditor := TfrmHSIEditor.Create(nil);
 
  try
       if frmEditor.ShowModal = mrOK then
       begin
           HotSpotImage1.HotSpots.Assign(FHotSpots);   
     
      HotSpotImage1.Picture.Assign(FPicture);
   
    end;
 
  finally
       frmEditor.Free;
   
    frmEditor := nil;
 
  end;
end;

TWebUpdate

1. Using TWebUpdate with C++Builder.


To use TWebUpdate with C++Builder, it is required to add the following line to the .CPP file where the component is used:

#pragma link "wininet.lib"

 

TAdvToolBar, TAdvGlowButton, TAdvOfficePager

1. Using TAdvToolBar, TAdvGlowButton, TAdvOfficePager with C++Builder.


To use TAdvToolBar, TAdvGlowButton, TAdvOfficePager with C++Builder, it is required to add the following line to the .CPP file where the component is used:

#pragma link "gdiplus.lib"

otherwise errors similar to:

Linker Error] Unresolved external 'GdiplusStartup' referenced from C:\PROGRAM FILES\....|AdvGDIP.pas

can appear.

 

 

 

 

More will be added in the near future here ...
let us know if you have questions that you want to see covered here.