luciano_f 5 Posted October 3, 2023 (edited) Every form I open I have to deactivate and activate "Lock Control" again. Is there any tool or way to do this automatically ? Edited October 3, 2023 by luciano_f Share this post Link to post
aehimself 396 Posted October 3, 2023 By locking you mean they cannot be interacted with? If yes, just write a recursive method to walk through your form, disabling / enabling your controls in the process: Procedure TForm3.LockControls(Const inLockControls: Boolean; inParent: TWinControl = nil); Var a: Integer; Begin If Not Assigned(inParent) Then inParent := Self; For a := 0 To inParent.ControlCount - 1 Do Begin inParent.Controls[a].Enabled := Not inLockControls; If inParent.Controls[a] Is TWinControl Then LockControls(inLockControls, inParent.Controls[a] As TWinControl); End; End; Share this post Link to post
luciano_f 5 Posted October 3, 2023 2 minutes ago, aehimself said: By locking you mean they cannot be interacted with? If yes, just write a recursive method to walk through your form, disabling / enabling your controls in the process: Procedure TForm3.LockControls(Const inLockControls: Boolean; inParent: TWinControl = nil); Var a: Integer; Begin If Not Assigned(inParent) Then inParent := Self; For a := 0 To inParent.ControlCount - 1 Do Begin inParent.Controls[a].Enabled := Not inLockControls; If inParent.Controls[a] Is TWinControl Then LockControls(inLockControls, inParent.Controls[a] As TWinControl); End; End; In Delphi there is an option in "Edit" -> "Lock Controls" but this option I have to disable and enable again for each form that opens, I would like to do this automatically once only and all the forms that I open are already locked I believe it must be something related to OTA but I don't know how to do it https://github.com/DGH2112/DGH-IDE-Notifiers/blob/master/Source/DGHIDENotifiers.FormNotifier.pas Share this post Link to post
Anders Melander 1783 Posted October 3, 2023 3 minutes ago, aehimself said: If yes, just write a recursive method to walk through your form, disabling / enabling your controls in the process: No, He means this: Share this post Link to post
luciano_f 5 Posted October 3, 2023 Just now, Anders Melander said: No, He means this: Yes Share this post Link to post
aehimself 396 Posted October 3, 2023 Hah, I didn't even know this feature existed 😄 Share this post Link to post
luciano_f 5 Posted October 3, 2023 Based on this link, I believe it is possible to create a BPL that can automatically Disable and Enable the "Lock Controls" for each form that is opened. https://github.com/DGH2112/DGH-IDE-Notifiers/blob/master/Source/DGHIDENotifiers.FormNotifier.pas Share this post Link to post
luciano_f 5 Posted October 8, 2023 (edited) For those who want to fix the bug, the correction was made with CnPack https://github.com/cnpack/cnwizards/issues/181 Edited October 8, 2023 by luciano_f Share this post Link to post