Putting TImage inside TPanel as one object

Both are TGraphicControl descendants
1/ I need TImage’s sides inside TPanel’s boarders
2/ I need the TPanel’s boarder sizes to be the object size all as one object

So is the descendant order TGraphicControl TImage TCustomPanel TPanel?

TGraphicControl TCustomPanel TCustomImage, TImage?

thanks

Both of what? TImage and TPanel?

TPanel isn’t a TGraphicControl descendant.

Just put the TImage inside the TPanel and set the TImage.Alignment to alClient. The TImage will resize when the TPanel is resized. You’ll want to set TImage.Stretch and TImage.Proportional to the appropriate values for your application also.

These you can just get from the documentation for TImage and TPanel.

Or you could just look it up in the VCL source code directly.

Ok I’m not checking properly
I need to combine TImage with the borders of tPanel some how

correct me
TPanel does not use TGraphicControl but TCustomControl that is used for a example TStringGrid to give more user inputs into the object.
TGraphicControl is low on user inputs that i do not care about
TGraphicControl and TCustomControl still run the same canvas in the paint

So taking TPanel with heaps of user inputs gives me sizing to implant many TImage parts into TPanel
TPanel.paint gives sizes for the Image’s StretchDraw inside the bevels of TPanel

should work?
just remove the displaying the caption from TPanel

You should stop saying the word “use”, it could mean anything. It makes your posts very difficult to understand. Use more specific words that describe the real relationship between the classes.

For example my interpretation of your original sentence is:

TPanel does not inherit from TGraphicControl but instead inherits from TCustomControl. TCustomControl provides access to the native Windows handle of the underlying control, as can be seen in use by TStringGrid which also inherits from TCustomControl.

TGraphicControl is far less common and is for controls that do not have an underlying Windows handle. You’re basically taking responsibility for almost everything. Only inherit from TGraphicControl if you have no other choice.

Try something like this first before you go overcomplicating things unnecessarily.

procedure TMyComponent.ShowImagePanel;
begin
  MyPanel := TPanel.Create(Self);
  MyPanel.Parent := Self;
  MyPanel.Caption := '';

  MyImage := TImage.Create(MyPanel);
  MyImage.Parent := MyPanel;
  MyImage.Align := alClient;
  MyImage.Stretch := your choice
  MyImage.Proportional := your choice
end;

That will give you a TImage inside a TPanel with the TImage resizing as the TPanel resizes.

1 Like

Yes I’m taking on board use words like descendants of not use

    FPicture: TPicture;  // TImage data
    FOnProgress: TProgressEvent;
    FStretch: Boolean;
    FCenter: Boolean;
    FIncrementalDisplay: Boolean;
    FTransparent: Boolean;
    FDrawing: Boolean;

    FAutoSizeDocking: Boolean; // TPanel data
    FBevelInner: TPanelBevel;
    FBevelOuter: TPanelBevel;
    FBevelWidth: TBevelWidth;
    FBorderWidth: TBorderWidth;
    FBorderStyle: TBorderStyle;
    FFullRepaint: Boolean;
    FLocked: Boolean;
    FAlignment: TAlignment;

and making it into a single object
Procedure paint - Stretch drawing in Image in after the frame is on the canvas

all sorts of other bells and Wessels too