Solved

Embeding form in maximised panel without resizing flash

Posted on 2004-10-13
12
212 Views
Last Modified: 2010-04-04
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
Comment
Question by:tomcorcoran
  • 4
  • 3
  • 3
  • +2
12 Comments
 
LVL 22

Assisted Solution

by:Ferruccio Accalai
Ferruccio Accalai earned 25 total points
ID: 12298886
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
 

Author Comment

by:tomcorcoran
ID: 12299271
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
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 12299430
Ah yes i see...
change it to

[...]
if ShowForm then begin
      Height := Parent.height;
      Width := Parent.width;
      Show;
   end;
  end;
end
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 14

Expert Comment

by:DragonSlayer
ID: 12299491
or, in one operation

if ShowForm then
begin
  SetBounds(0, 0, Parent.Width, Parent.Height);
  Show;
end;
0
 

Author Comment

by:tomcorcoran
ID: 12299666
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
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 12299678
where is the TheForm creation?
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 12299873
Oh, also, did you set the TheForm's Visible property to False at the Object Designer?
0
 

Author Comment

by:tomcorcoran
ID: 12300057
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
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 12300111
set visible to false first, in the object inspector.

Then use setbounds to set the size, then only call Show.
0
 
LVL 2

Assisted Solution

by:cqhall
cqhall earned 25 total points
ID: 12302177
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
 
LVL 3

Accepted Solution

by:
julianpointer earned 25 total points
ID: 12302730
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
 

Author Comment

by:tomcorcoran
ID: 12309160
Thanks you guys! I wrapped my creation and embed call in  LockWindowUpdate(GetDesktopWindow()) which worked beautifully!
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Intraweb submit form as a POST request 4 303
Delphi cmd execution 6 60
Delphi XE10 Round Image 2 126
Find and Replace Stream with 0s 8 62
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question