Solved

Embeding form in maximised panel without resizing flash

Posted on 2004-10-13
12
214 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 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
Technology Partners: 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 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

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

696 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