Solved

Embeding form in maximised panel without resizing flash

Posted on 2004-10-13
12
210 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now