Jump to content
Larry Hengen

Left Click Does not Focus Control

Recommended Posts

I have a TForm descendant that contains a scrollbox, and the form is nested within two panels on the main form of my application.  It displays values in a manner similar to the object inspector, and the user needs to be able to edit the values.  For some reason, I cannot focus the TLabeledEdit controls using the mouse left button click.  Right clicking on the control works and selects all text in the TEdit, but left click does not.  I see that a WM_SETFOCUS message is sent, but false is returned.  Before I start digging into the the VCL's message handling, I was wondering if anyone might know the cause of such behaviour, or have suggestions on how to best track it down.

 

I just converted the "inspector" form to a TFrame.  In doing so I loose some functionality like the ability to close the form, but I can now focus the edit control using the left mouse button, and I also get a right click local menu for the editor.  Is there anyway to make the embedded form behave in the same way as the frame with respect to embedded controls?

Edited by Larry Hengen
clarify situation and document new finding

Share this post


Link to post
5 hours ago, Fr0sT.Brutal said:

I'd say it's easier to add necessary form functions to frame (adding header and close button shouldn't be too complex)

Of course you are right.  Thanks for the suggestion.

Share this post


Link to post
On 9/22/2019 at 6:26 PM, Larry Hengen said:

I have a TForm descendant that contains a scrollbox, and the form is nested within two panels on the main form of my application.  It displays values in a manner similar to the object inspector, and the user needs to be able to edit the values.  For some reason, I cannot focus the TLabeledEdit controls using the mouse left button click.  Right clicking on the control works and selects all text in the TEdit, but left click does not.  I see that a WM_SETFOCUS message is sent, but false is returned.  Before I start digging into the the VCL's message handling, I was wondering if anyone might know the cause of such behaviour, or have suggestions on how to best track it down.

 

I just converted the "inspector" form to a TFrame.  In doing so I loose some functionality like the ability to close the form, but I can now focus the edit control using the left mouse button, and I also get a right click local menu for the editor.  Is there anyway to make the embedded form behave in the same way as the frame with respect to embedded controls?

Maake sure you set the form borderstyle to bsNone, so it has no caption bar. Windows does not like controls with the WS_Caption window style (and that is what the form becomes when you embed it), they have focus issues likr the one you observed.

  • Thanks 1

Share this post


Link to post
1 hour ago, PeterBelow said:

set the form borderstyle to bsNone, so it has no caption bar.

Thanks for the answer.  It's always nice to know why.  Actually the Caption bar is one of the things I liked about using embedded forms, that and the OnCreate/OnClose events.  I have switched things to use TFrame descendants, which works reasonably well, but I had to introduce my own caption bar and deal with the lack of the events I mentioned.

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

×