Recent

Author Topic: Disable resize of a control during design time.  (Read 1145 times)

CM630

  • Hero Member
  • *****
  • Posts: 1220
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Disable resize of a control during design time.
« on: June 04, 2024, 11:17:25 am »
I have a TCustomControl which shall not be resizeable.

I have the Height and Width properties disabled with the code below.
Code: Pascal  [Select][+][-]
  1. procedure Register;
  2. begin
  3.   RegisterPropertyEditor(TypeInfo(integer), TWGCursorPlacers, 'Width', THiddenPropertyEditor);
  4.   RegisterPropertyEditor(TypeInfo(integer), TWGCursorPlacers, 'Height', THiddenPropertyEditor);
  5.  
  6.  
  7.   RegisterComponents('Instrumentation',[TWGCursorPlacers]);
  8. end;  
  9.  
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?
« Last Edit: June 05, 2024, 10:08:19 am by CM630 »
Лазар 4,0RC2 32 bit (sometimes 64 bit); FPC3,2,2

Thaddy

  • Hero Member
  • *****
  • Posts: 16343
  • Censorship about opinions does not belong here.
Re: Disable resisign of a cotrol during design time.
« Reply #1 on: June 04, 2024, 03:58:28 pm »
Disconnect OnResize for the control? i.e. set it to nil in your designer.
There is nothing wrong with being blunt. At a minimum it is also honest.

CM630

  • Hero Member
  • *****
  • Posts: 1220
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Disable resize of a control during design time.
« Reply #2 on: June 05, 2024, 08:47:48 am »
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  [Select][+][-]
  1.   TWGCursorPlacers = class(TCustomControl)
  2.   private
  3. ...
  4.     procedure SetOnResize (Sender: TObject);  
  5. ...
  6. constructor TWGCursorPlacers.Create(AOwner: TComponent);
  7. begin
  8.   inherited;
  9.   ...
  10.   OnResize := @SetOnResize;
  11.   ...
  12. end;
  13.  
  14.  
  15. procedure TWGCursorPlacers.SetOnResize (Sender: TObject);
  16. begin
  17.   //FWidth and Fheight are constants
  18.   Width := FWidth;
  19.   Height := FHeight;  
  20. end;




EDIT: There occurred to be some abnormalities when anchoring.
« Last Edit: June 05, 2024, 10:08:08 am by CM630 »
Лазар 4,0RC2 32 bit (sometimes 64 bit); FPC3,2,2

 

TinyPortal © 2005-2018