Solved

Image on a TcustomPanel

Posted on 2003-12-12
6
239 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
  • 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

9 Experts available now in Live!

Get 1:1 Help Now