GNU gettext for Delphi, C++ Builder and Kylix 1.2 beta
<<< Previous | How to handle specific classes | Next >>>

# TMS Software TAdvStringGrid

The TAdvStringGrid is not compatible with TranslateComponent(). You should therefore put it on ignore:

    TP_GlobalIgnoreClass (TAdvStringGrid);

But there is a solution to get it translated. The following text was provided by Sandro Wendt:

As I needed to translate one of its descendants ( a TAdvColumnGrid ), I checked with Bruno and found that the reason for the exceptions "Controls '' has no parent window" were probably the inplace editors of the grid. There are two you can get at through properties, but several you cannot as they are only contained in private member fields. However, using the components array of the grid, you can get at these as well.

This is the code I used:

    var
      i: integer;
      FCompList: TObjectList;
    begin
      FCompList := TObjectList.Create( false );
      try
        for i := 0 to FieldDefinition_grid.ComponentCount - 1 do begin
          if FieldDefinition_grid.Components[i] is TWinControl then begin
            if TWinControl( FieldDefinition_grid.Components[i] ).Parent = nil then begin
              TWinControl( FieldDefinition_grid.Components[i] ).Parent := FieldDefinition_grid;
              FCompList.Add( FieldDefinition_grid.Components[i] );
            end;
          end;
        end;
        TranslateComponent (self);
        for i := 0 to FCompList.Count - 1 do begin
          TWinControl( FCompList[i] ).Parent := nil;
        end;
      finally
        FCompList.Free;
      end;
    end;

You need to set the Parent's back to nil because otherwise especially the RichEdit editors will display on top of the grid. Also, most inplace editors actually have a parent assigned, so you only want to nil the ones you gave a parent in order for the translation to succeed.

<<< Previous | Home | Next >>>
Turbopower Essentials | Up | Frequently Asked Questions