DELPHI XE8 : No refresh for TRectangle on Android during OnCreate event

  

I created this function on DELPHI XE5, it’s work very well.
You create a single image with all your icons, you load this image in a TBitmap (IDE in my exemple), and you create a lot of small TRECTANGLE in the form.

During the onCreate, i call Mapping method to set the background of each Trectangle.

BUT IN DELPHI XE8, It’s not working on ANDROID

This is the mapping function.

Procedure TForm1.Mapping(Const Obj:TRectangle;Const ofx,ofy:Integer);
Var
Arect : TRectF;
FBitmap : TBitmap;
Begin
Arect:=TRectF.Create(0,0,Obj.Width,Obj.Height);
Obj.Stroke.Kind := TBrushKind.None;
Obj.Fill.Kind := TBrushKind.Bitmap;
Obj.Fill.Bitmap.WrapMode := TWrapMode.TileOriginal;
//Create Crop Bitmap
FBitmap:=TBitmap.create( Round(Obj.Width), Round(Obj.Height)) ;
Try
FBitmap.Canvas.BeginScene();
FBitmap.Canvas.ClearRect(ARect,StringToAlphaColor(‘$00000000’));
FBitmap.Canvas.DrawBitmap(IDE,
TRectF.Create(ofx,ofy,ofx+Obj.Width,ofy+Obj.Height),
Arect, 100) ;
FBitmap.Canvas.EndScene;
//Assign Crop image to Rectangle object
Obj.Fill.Bitmap.Bitmap.Assign(FBitmap);

Finally
FBitmap.Free;
End;
End;

The picture (delphiXE.png) is deploying in “asset/internal”, and opening in oncreate.

procedure TForm1.FormCreate(Sender: TObject);
Var Mfile:String;
begin
IDE := TBitmap.Create(ClientWidth,ClientHeight);
{$IFDEF ANDROID}
Mfile:=TPath.Combine(TPath.GetDocumentsPath, ‘delphiXE.png’);
{$ELSE}
Mfile:=TPath.Combine(ExtractFilePath(ParamStr(0)), ‘delphiXE.png’);
{$ENDIF}
If FileExists(MFile)
Then begin
IDE.LoadFromFile(MFile);
Mapping(Logo,0,0);
End
Else ShowMessage(‘NO ‘+MFile);
end;

In Windows, everythings works fine, but no in Android, but if i add a simple onclick event with Mapping(Logo,0,0); call, the mapping work, but i need to click first on the grey Trectangle to set it background

Any idea ?

UPDATED :
Using a Timer, the mapping function is working and the trectangle have the good picture, but if i switch to another application and go back to my application, the picture disappear and the Trectangle turn back to solid gray.

That mean that the internal paint of the TRectangle is not updated. Why ?

Comments are closed.