Página 1 de 1

AddExistingControl - control does not select, activates

Publicado: Lun Feb 07, 2022 1:57 pm
por Hurricane
Hi,

after i inserted the control into the Form, it is not selected, (I need to click on control to activate in object inspector).
I will email you a small complete project.

Código: Seleccionar todo

   if nsBtn = BTN_MSK
      with object oCtrl:=TDbMaskEdit():New(oParent)
         :SetBounds( aPos[1], aPos[2], 80, 20 )
         //:oDataField:=cField
         :Create()
      end with
   endif
   //oPlugin:IInspector:AddControl(oCtrl, oParent) // It does not work properly, see: https://forum.xailer.com/viewtopic.php?t=14192
   oPlugin:IInspector:oActiveForm:AddExistingControl(oCtrl)
   //oPlugin:IInspector:SetControl(oCtrl)
add_control.png
add_control.png (22.69 KiB) Visto 1912 veces
Regards,

Re: AddExistingControl - control does not select, activates

Publicado: Lun Feb 07, 2022 7:34 pm
por ignacio
Hi,

You can try with:

Código: Seleccionar todo

oCtrl:PostMsg( WM_LBUTTONDOWN, 0, 0 )
oCtrl:PostMsg( WM_LBUTTONUP, 0, 0 )
BTW, maybe José Gimenez can give you a better solution. (He is the owner of that code)

Regards,

Re: AddExistingControl - control does not select, activates

Publicado: Mar Feb 08, 2022 9:48 am
por jfgimenez
Hi,

just add:

Código: Seleccionar todo

oPlugin:IInspector:oActiveForm:ReplaceSelection(oCtrl)
Regards.

Re: AddExistingControl - control does not select, activates

Publicado: Mar Feb 08, 2022 1:23 pm
por Hurricane
Hi,

it works fine when I insert the control directly into the Form, but when I insert it inside a container (groupBox...), both are selected.
I sent you an email with a small complete example.
jfgimenez escribió: Mar Feb 08, 2022 9:48 am just add:

Código: Seleccionar todo

oPlugin:IInspector:oActiveForm:ReplaceSelection(oCtrl)
add_control2.png
add_control2.png (10.67 KiB) Visto 1875 veces
I tested this but it keeps mouse clicked
ignacio escribió: Lun Feb 07, 2022 7:34 pm

Código: Seleccionar todo

oCtrl:PostMsg( WM_LBUTTONDOWN, 0, 0 )
oCtrl:PostMsg( WM_LBUTTONUP, 0, 0 )
thanks for helping.