?
Solved

Embeding form in maximised panel without resizing flash

Posted on 2004-10-13
12
Medium Priority
?
215 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +2
12 Comments
 
LVL 23

Assisted Solution

by:Ferruccio Accalai
Ferruccio Accalai earned 100 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 23

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 23

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 100 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 100 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month12 days, 2 hours left to enroll

752 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