wwwbetyar
asked on
Image on a TcustomPanel
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;
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
begin
FBkGround.Assign(Value);
Fimage.Picture:=FBkGround;
end;
ASKER
It doesn't work.
ASKER
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 ?
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 ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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(FBkG round);
End;
end;
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(FBkG
End;
end;
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
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
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;