Solved

Image on a TcustomPanel

Posted on 2003-12-12
6
243 Views
Last Modified: 2010-04-05
Hi

I want to write a desktop component, which works as the windows desktop.
It's inherit from TCustomPanel that contain a Timage. This Image is the background.
The background is showing in design-time, but I cannot see it in run time.
Can you help me ? Can I write something in the Paint methode ?
Here is the code.

...
    FBkGround : TPicture;
    FImage : TImage;
...

constructor Tdesktop.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  Self.DoubleBuffered:=True;
  if FBkGround=nil then FBkGround:=TPicture.Create;
  Fimage:=TImage.Create(Self);
  Fimage.Align:=alClient;
  Fimage.Stretch:=true;  
  FImage.Picture:=FBkGround;
  Fimage.Parent:=Self;
end;

procedure Tdesktop.SetBkGround(Value: TPicture);
begin
  FBkGround.Assign(Value);
  Fimage.Picture:=FBkGround;
end;
0
Comment
Question by:wwwbetyar
[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
  • 3
  • 2
6 Comments
 
LVL 26

Expert Comment

by:Russell Libby
ID: 9928638

Have you tried setting the Visible property for the FImage? (sorry, can't test at the moment).

Regards,
Russell

constructor Tdesktop.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  Self.DoubleBuffered:=True;
  if FBkGround=nil then FBkGround:=TPicture.Create;
  Fimage:=TImage.Create(Self);
  Fimage.Align:=alClient;
  Fimage.Stretch:=true;  
  FImage.Picture:=FBkGround;
  Fimage.Parent:=Self;

  Fimage.Visible:=True; // <---

end;
0
 

Author Comment

by:wwwbetyar
ID: 9928751
It doesn't work.
0
 

Author Comment

by:wwwbetyar
ID: 9928778
I wrote a procedure

procedure Tdesktop.Start;
begin
  Fimage.Picture:=FBkGround;
end;

If I call this procedure from the code (not in the components) it works.
But I don't want to call any procedure to work...
Does it have any triks for aftershow ?
Or any good solve ?
0
Independent Software Vendors: 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 5

Accepted Solution

by:
delphized earned 50 total points
ID: 9936881
in your original code

 instead of  FImage.Picture:=FBkGround;
use:
 FImage.Picture.assign(FBkGround);

and I wouldn't use the separate tpicure variable FBkGround, use instead the FImage.picture property
 

0
 

Author Comment

by:wwwbetyar
ID: 9937146
Your solution, does not work, but here is a good :

constructor Tdesktop.Create(AOwner: TComponent);
begin
...
  FDrawing:=True;
...
End;

procedure Tdesktop.Paint;
begin
  inherited;
  If (FBkGround<>nil) and (FDrawing) then
  Begin
    FDrawing:=False;
    Fimage.Picture.Assign(FBkGround);
  End;
end;
0
 
LVL 5

Expert Comment

by:delphized
ID: 9938655
yes, the point is the assign statement as I told you.
You can't use := to copy an image
the fact that you don't want to repaint the picture is not mentioned in this question
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

Suggested Solutions

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…
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…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

710 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