?
Solved

Create compoennt with TPanel and TImage

Posted on 2005-03-03
10
Medium Priority
?
327 Views
Last Modified: 2010-04-05

Hello,
I want to create a component.  A TImage on a TPanel.  The user should be abled to select the image.  How can I do that ??
0
Comment
Question by:frdep
[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
10 Comments
 
LVL 12

Expert Comment

by:esoftbg
ID: 13451972
It is easy to create a component:  TImage on a TPanel, but it it is not easy (for me) to able to select the Image ....
I remember there is an old question that was answered by Ferruccio68 about the selection ....
Do you need an example about: TImage on a TPanel, but without ability for selection ?
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13452241
Does the OnClick event of a TImage not work very well esoftbg?
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 13452297
Hi mikelittlewood, I just tested my component:

procedure TForm1.Panel_with_Image1ImageClick(Sender: TObject);
begin
  ShowMessage('Test Image OnClick');
end;

It works (It raises above message) on every clicking on it ....
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 15

Expert Comment

by:mikelittlewood
ID: 13452464
ok ..
I just wondered why you wrote
>It is easy to create a component:  TImage on a TPanel, but it it is not easy (for me) to able to select the Image <
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 13452659
I really never have been programmed any Image selection, so it is not easy for me. I mean may be partial selection and / or full Image selection ....
0
 
LVL 11

Expert Comment

by:ZhaawZ
ID: 13455330
frdep, what do you mean with "the user should be abled to select the image"?
0
 

Author Comment

by:frdep
ID: 13455593

The programmer who use the component should be abled to assign a picture, not the final user.
So, I drop the component on the form.  On the component, I have a property "Picture" I can select ( like a normal TImage ) or assigne the image by programmation ( TPanelImage1.Picture := ... )
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 13456513
you will be abled to assign a picture both at design time and at runtime .... No problem about that .... It is like a normal TImage. It is possible to be used under Delphi 6, Delphi 7 and Later versions ....
0
 
LVL 12

Accepted Solution

by:
esoftbg earned 500 total points
ID: 13456579
download the component and an example application from:
page:        http://www.geocities.com/esoftbg/
  link:        Q_21336613.zip        Create compoennt with TPanel and TImage
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 13471255
This is not a new answer:

unit Panel_with_Image;

interface

uses
  SysUtils, Classes, Controls, StdCtrls, ExtCtrls;

type
  TPanel_with_Image  =  class(TPanel)
    private     { Private declarations }
      FImage:     TImage;
      procedure   SetImage(const Value: TImage);
    protected   { Protected declarations }
    public      { Public declarations }
      constructor Create(AOwner: TComponent); override;
      procedure   Paint; override;
      destructor  Destroy; override;
    published   { Published declarations }
      property    Image: TImage read FImage write SetImage;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('ESoft', [TPanel_with_Image]);
end;

constructor TPanel_with_Image.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  Caption := ' ';
  FImage := TImage.Create(Self);
  FImage.SetSubComponent(True);
  FImage.Parent := Self as TWinControl;
  FImage.Name := 'Image';

  RePaint;
end;

procedure TPanel_with_Image.Paint;
begin
  inherited;
  if Assigned(FImage) then
  begin
    FImage.Height := Self.Height;
    FImage.Width := Self.Width;
    FImage.Left := 0;
    FImage.Top := 0;
  end;
end;

procedure TPanel_with_Image.SetImage(const Value: TImage);
begin
  FImage.Assign(Value);
  Invalidate;
end;

destructor  TPanel_with_Image.Destroy;
begin
  if Assigned(Image) then
    Image.Destroy;
  inherited Destroy;
end;

end.
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

765 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