Jump to content
Tom Mueller

Problem with selection markes in Delphi IDE for Controls with SubControls

Recommended Posts

Hallo all

 

I have a control (TWinControl) that contains an other control (TPanel) and registered it in a package (see demo code in the attachment),

 

First Problem: When selecting the control in the IDE, the selection markers are only partially visible.

image.png.31511053f15a24508c260485294bc920.png

Second Problem: When selecting more than one control, no selection markers are visible at all.

MultiSelect.gif.e3ad1092f7adebfbcf5942369487b4d9.gif

 

Is this a known problem and are there any solutions for it?

 

Thanks

Tom

 

TestSelectMarker.7z

Share this post


Link to post

To handle this, I could register my own IOTANotifier with a IOTAWizard to get notified when the control is selected, and then draw the markers manually.

I found some notifiers for the code editor like TNTACodeEditorNotifier but could not find a proper notifier for the form designer.

If anyone has undertaken a similar task, your assistance would be greatly appreciated.

 

Share this post


Link to post
On 2/20/2025 at 2:15 AM, Tom Mueller said:

I have a control (TWinControl) that contains an other control (TPanel)

You need to add the paint event to draw the control in the IDE plus WMSIZE to allow sizing of controls being drawn.  Changing to descend from Tpanel allows working control base to add control to.  Later the control can be switched to TCustomControl or TWinControl. 

 

unit uTestSelectMarker;

interface

uses
 Classes, Vcl.Controls, Vcl.ExtCtrls, Winapi.Messages;

type

  TTestSelectMarker = class(TPanel)  //change to TcustomControl or TWinControl
  private
    FPanel: TPanel;
  protected
    procedure Paint; override;
    procedure WMSIZE(var message:TWMSIZE); message WM_SIZE;
  public
    constructor Create(AOwner: TComponent); override;
  end;

procedure Register;

implementation

uses
  Graphics;

constructor TTestSelectMarker.Create(AOwner: TComponent);
begin
  inherited;// Create(AOwner);
 Color := clBtnFace;

  FPanel:= TPanel.Create(self);
//  FPanel.SetSubComponent(True); // Uwe mentioned this in SO post 
  FPanel.Parent:= self;
  FPanel.BevelOuter:= bvNone;
  FPanel.Color:= clCream;
  FPanel.Visible := True;
end;

procedure Register;
begin
  RegisterComponents('Test',  [TTestSelectMarker]);
end;

procedure TTestSelectMarker.Paint;
begin
  inherited;
  FPanel.Caption := Name;
end;

procedure TTestSelectMarker.WMSIZE(var message: TWMSIZE);
begin
  FPanel.setbounds(10,10,Width- 2 * 10, Height - 2 * 10);
end;

end.

 

Screenshot 2025-02-25 010433.png

Share this post


Link to post

Thank you for your response.

 

I noticed that you reduce the size of the sub-control to display the markers correctly.

This works but unfortunately, this approach prevents the sub-control from being displayed at its desired size.

 

In my case, the sub-control can be of type TEdit, TCheckBox, TComboBox, TDateTime or TMemo, and it is essential that they maintain their correct size at design time.

 

By reducing the sub-control size, a correct form layout is not possible, and it would look like:

image.png.92cdb942340bec72c0eca40c8ad58bb8.png

 

Or, is there a way to reduce the size of the sub-component only when more than one control is selected?

 

Edited by Tom Mueller

Share this post


Link to post
6 hours ago, Tom Mueller said:

I noticed that you reduce the size of the sub-control to display the markers correctly.

I should have included this

procedure TTestSelectMarker.WMSIZE(var message: TWMSIZE);
begin
 // FPanel.setbounds(10,10,Width- 2 * 10, Height - 2 * 10);
  Fpanel.Align := alClient;
end;

 

 

Screenshot 2025-02-25 084749.png

Share this post


Link to post

Thanks for your effort but you can see the partial markers only because the panel has a border of 1 pixel (due to BevelOuter=bvRaise).

Set BevelOuter=bvNone the markers are hidden completely again.

Share this post


Link to post

To reveal the markers add to source or set in Object Inspector

BorderWidth = 5

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×