• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

Embeding form in maximised panel without resizing flash

This is one I'm sure I figured out how to do years ago..but can't remember :-)

I create a form on the fly which I embeded in a panel on a maximised form. The problem is that one can see a flicker of the form when it's created before it get's resized in the panel.

I have played around without succes at setting the Visible property.

How can I not have this "flash effect"?

Thanks, Tom.
0
boardtc
Asked:
boardtc
  • 4
  • 3
  • 3
  • +2
3 Solutions
 
Ferruccio AccalaiSenior developer, analyst and customer assistance Commented:
Do you mean something like this?

procedure TForm1.Button1Click(Sender: TObject);
begin
application.CreateForm(tform2, form2);
form2.parent := self.panel1;
form2.align := alclient;
LockWindowUpdate(form2.Handle);   //lock update of form2
form2.show;
LockWindowUpdate(0);  //unlock it
end;
0
 
boardtcAuthor Commented:
Thanks. I have a procedure which I use to embed all my forms. I tried your LockWindowUpdate suggestion (see below). Unfortunately it had no effect :-( Any ideas?

Cheers, Tom.

procedure EmbedFormInPanel(TheForm : TForm;ThePanel : TPanel;ShowForm : Boolean);
begin
  CloseEmbeddedForms(ThePanel);

  with TheForm do begin
    ParentFont  := True;
    Parent      := ThePanel;
    Align       := alClient;
    BorderIcons := [];
    BorderStyle := bsNone;

    if ShowForm then begin
      LockWindowUpdate(TheForm.Handle);   //lock update
      Show;
      LockWindowUpdate(0);  //unlock it
    end;
  end;
end;
0
 
Ferruccio AccalaiSenior developer, analyst and customer assistance Commented:
Ah yes i see...
change it to

[...]
if ShowForm then begin
      Height := Parent.height;
      Width := Parent.width;
      Show;
   end;
  end;
end
0
[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

 
DragonSlayerCommented:
or, in one operation

if ShowForm then
begin
  SetBounds(0, 0, Parent.Width, Parent.Height);
  Show;
end;
0
 
boardtcAuthor Commented:
Thanks guys. I got really excited, thinking this might work...I tried :
     SetBounds(0,0,ThePanel.Width,ThePanel.Height);
before the Show but it had no effect. Prior to this TheForm.Width is 441 (resets to 646) & height 472 to 554.

Any thoughts?

Thanks, Tom.
0
 
Ferruccio AccalaiSenior developer, analyst and customer assistance Commented:
where is the TheForm creation?
0
 
DragonSlayerCommented:
Oh, also, did you set the TheForm's Visible property to False at the Object Designer?
0
 
boardtcAuthor Commented:
Visible is not set to False. Our design is such that  is happens like this :

class procedure TMyFormDlg.Execute(ParentPanel : TPanel);
  var
    TheForm : TMyFormDlg;
begin
  TheForm := Self.Create(ParentPanel.Owner);
  EmbedFormInPanel(TheForm,ParentPanel : TPanel,True);
end;

thanks, tom.
0
 
DragonSlayerCommented:
set visible to false first, in the object inspector.

Then use setbounds to set the size, then only call Show.
0
 
cqhallCommented:
Try using the lockwindowupdate on the main form, form1.  When I've used lockwindowupdate on panels or other
subcontrols, I've noticed flicker in other parts of the main form.

Chuck
0
 
julianpointerCommented:
Below is the code I use to load form into a panel, I dont get any flicker... and I dont set anything on the form...


var
  NewDemo       : TForm;
  Save_Cursor   : TCursor;
begin
  LockWindowUpdate(GetDesktopWindow());

  Save_Cursor := Screen.Cursor;
  Screen.Cursor := crHourglass;    // Show hourglass cursor
  try

    case TControl(Sender).tag of
      402..410: begin
                      if pnlContainer.ControlCount > 0 then
                        pnlContainer.Controls[0].Free;

                      NewDemo := TfrmCOR_Account_List.Create(Self);
                      NewDemo.Hide;
                      NewDemo.BorderStyle := bsNone;
                      NewDemo.Parent := pnlContainer;
                      NewDemo.Align := alClient;
                      NewDemo.Show;
                    end;

    end;
  finally
    Screen.Cursor := Save_Cursor;
  end;

  LockWindowUpdate(0);
0
 
boardtcAuthor Commented:
Thanks you guys! I wrapped my creation and embed call in  LockWindowUpdate(GetDesktopWindow()) which worked beautifully!
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

  • 4
  • 3
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now