Firemonkey – BeginUpdate/EndUpdate not working as expected

  

I have couple of panels one which have the buttons and other having two TWebbrowsers as depicted in below image.

I need to set browser panel visible based on certain conditions. Whenever I set the visibility, the controls are not updated correctly. I tried BeginUpdate/EndUpdate but that wont effect the output.

My Code:

type
TForm1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
WebBrowser1: TWebBrowser;
WebBrowser2: TWebBrowser;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.fmx}

procedure TForm1.Button1Click(Sender: TObject);
begin
Panel2.BeginUpdate;
Panel2.Visible := True;
WebBrowser1.BringToFront;
Panel2.EndUpdate;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
Panel2.Visible := True;
WebBrowser2.BringToFront;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
Panel2.Visible := False;
end;

Output:
Please see the highlighted area in below image. My original design has only buttons but I see highlighted part whenever I made the panel visible.

Edit:
Updated FMX

object Form1: TForm1
Left = 0
Top = 0
Caption = ‘Form1’
ClientHeight = 480
ClientWidth = 640
FormFactor.Width = 320
FormFactor.Height = 480
FormFactor.Devices = [Desktop]
DesignerMasterStyle = 0
object Panel1: TPanel
Align = Top
Size.Width = 640.000000000000000000
Size.Height = 73.000000000000000000
Size.PlatformDefault = False
TabOrder = 0
object Button1: TButton
Position.X = 56.000000000000000000
Position.Y = 24.000000000000000000
TabOrder = 0
Text = ‘Button1’
OnClick = Button1Click
end
object Button2: TButton
Position.X = 176.000000000000000000
Position.Y = 24.000000000000000000
TabOrder = 1
Text = ‘Button2’
OnClick = Button2Click
end
object Button3: TButton
Position.X = 299.000000000000000000
Position.Y = 24.000000000000000000
TabOrder = 2
Text = ‘Button3’
OnClick = Button3Click
end
end
object Panel2: TPanel
Align = Client
Size.Width = 640.000000000000000000
Size.Height = 407.000000000000000000
Size.PlatformDefault = False
Visible = False
TabOrder = 1
object WebBrowser1: TWebBrowser
Align = Client
Size.Width = 640.000000000000000000
Size.Height = 407.000000000000000000
Size.PlatformDefault = False
URL = ‘https://www.gmail.com’
end
object WebBrowser2: TWebBrowser
Align = Client
Size.Width = 640.000000000000000000
Size.Height = 407.000000000000000000
Size.PlatformDefault = False
URL = ‘https://www.google.com’
end
end
end

Comments are closed.