Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread Desktop header and footer panel
Fri, Apr 27 2012 9:24 AMPermanent Link

thomh

Hi Tim,

Would it be possible to create desktop header and footer panel? This would simulate a Toolbar and Statusbar in Win app land. It would be aligned to the top and bottom of the desktop. It would be nice have to this as a way to place application-wide components.

// Thom
Fri, Apr 27 2012 10:48 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Thom,

<< Would it be possible to create desktop header and footer panel? This
would simulate a Toolbar and Statusbar in Win app land. It would be aligned
to the top and bottom of the desktop. It would be nice have to this as a way
to place application-wide components. >>

Yes, the TDesktop component is actually a TContainerControl, so you can
place any component on it by simply assigning it to the Parent property of
the control in question.

--
Tim Young
Elevate Software
www.elevatesoft.com
Fri, Apr 27 2012 11:19 AMPermanent Link

thomh

Tim,

How would go about doing this? I am unable to place a TPanel directly on the desktop.
And how would you these panels to the top and bottom of the desktop?

Thanks.

// Thom

"Tim Young [Elevate Software]" wrote:

>>Yes, the TDesktop component is actually a TContainerControl, so you can
>>place any component on it by simply assigning it to the Parent property of
>>the control in question.

--
Tim Young
Elevate Software
www.elevatesoft.com
Fri, Apr 27 2012 11:37 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Thom,

<< How would go about doing this? I am unable to place a TPanel directly on
the desktop.  And how would you these panels to the top and bottom of the
desktop? >>

You would have to do so at runtime by assigning the Application.Desktop to
the Parent property of the TPanels that you have created.  For example, this
will create a panel at the top of the desktop:

procedure TTestForm.DesktopPanelClick(Sender: TObject);
begin
  with TPanel.Create(Application.Desktop) do
     begin
     Top:=0;
     Left:=0;
     Height:=50;
     Width:=Application.Desktop.Width;
     ShowBorder:=False;
     Color:=clFormBackground;
     end;
end;

Note: you don't need to keep track of the panel using a separate variable
and explicitly free it if you make the Application.Desktop the owner in the
Create call.  In such a case, the TDesktop owner component will
automatically free the component when it is destroyed.

If you want to have the panels resize along with the desktop, just add an
event handler to the OnResize event for the TDesktop and resize accordingly:

http://www.elevatesoft.com/manual?action=viewevent&id=ewb1&comp=TDesktop&event=OnResize

--
Tim Young
Elevate Software
www.elevatesoft.com
Fri, Apr 27 2012 4:01 PMPermanent Link

thomh

Thanks for the code, Tim.

Now I am trying to dynamically create a TLabel within this panel using this code:

 FCopyrightLabel := TLabel.Create(FStatusbarPanel);
 FCopyrightLabel.Parent := FStatusbarPanel;
 FCopyrightLabel.Top := 6;
 FCopyrightLabel.Left := 6;
 FCopyrightLabel.Caption := 'Copyright 2012';
 FCopyrightLabel.Visible := True;

But it does show up.

Can anybody see what I am doing wrong?

// Thom

"Tim Young [Elevate Software]" wrote:

>>You would have to do so at runtime by assigning the Application.Desktop to
>>the Parent property of the TPanels that you have created.  For example, this
>>will create a panel at the top of the desktop:

>>procedure TTestForm.DesktopPanelClick(Sender: TObject);
>>begin
>>   with TPanel.Create(Application.Desktop) do
>>      begin
>>      Top:=0;
>>      Left:=0;
>>      Height:=50;
>>      Width:=Application.Desktop.Width;
>>      ShowBorder:=False;
>>      Color:=clFormBackground;
>>      end;
>>end;
Sun, Apr 29 2012 12:30 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Thom,

<< Now I am trying to dynamically create a TLabel within this panel using
this code: >>

Auto-sized labels are a bit special, and currently you're going to have a
problem creating one dynamically that you want to be auto-sized.  You'll
have to set AutoSize to False and specifically set the Width and Height
properties.

--
Tim Young
Elevate Software
www.elevatesoft.com
Image