Forum > Packages and Libraries

Disable resize of a control during design time.

(1/1)

CM630:
I have a TCustomControl which shall not be resizeable.

I have the Height and Width properties disabled with the code below.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure Register;begin  RegisterPropertyEditor(TypeInfo(integer), TWGCursorPlacers, 'Width', THiddenPropertyEditor);  RegisterPropertyEditor(TypeInfo(integer), TWGCursorPlacers, 'Height', THiddenPropertyEditor);    RegisterComponents('Instrumentation',[TWGCursorPlacers]);end;    But during design time the control can be resized by the mouse. It is not a great issue, but it is still annoying.
Could anyone propose a good way to disable resizin (by the mouse) during design time?

Thaddy:
Disconnect OnResize for the control? i.e. set it to nil in your designer.

CM630:
It occurred that OnResize := nil; destroys the event once and forever, but it does not prevent resizing.
That is what works for me:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  TWGCursorPlacers = class(TCustomControl)  private...    procedure SetOnResize (Sender: TObject);  ...constructor TWGCursorPlacers.Create(AOwner: TComponent);begin  inherited;  ...  OnResize := @SetOnResize;  ...end;  procedure TWGCursorPlacers.SetOnResize (Sender: TObject);begin  //FWidth and Fheight are constants  Width := FWidth;  Height := FHeight;  end;



EDIT: There occurred to be some abnormalities when anchoring.

Navigation

[0] Message Index

Go to full version