Fix TreeView control double click

Use this forum to ask questions after your subscription maintenance expires or before you buy. Need information on licensing or pricing? Questions about a trial version? This is the right place for you. No scripting questions, please.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
This topic is 1 year and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
ALIENQuake
Posts: 112
Last visit: Mon Jan 29, 2024 7:35 am
Has voted: 4 times

Fix TreeView control double click

Post by ALIENQuake »

- Windows Forms TreeView control has a very ugly bug: https://stackoverflow.com/questions/146 ... t-checkbox
I'm currently facing the same issue
- the working fix for this issue is https://stackoverflow.com/a/15760762 :

Code: Select all

class NewTreeView : TreeView
{
    protected override void WndProc(ref Message m)
    {
        if (m.Msg == 0x203) // identified double click
        {
            var localPos = PointToClient(Cursor.Position);
            var hitTestInfo = HitTest(localPos);
            if (hitTestInfo.Location == TreeViewHitTestLocations.StateImage)
                m.Result = IntPtr.Zero;
            else
                base.WndProc(ref m);
        }
        else base.WndProc(ref m);
    }
}
- This code demonstrates that it works: https://paste.ofcode.org/jQunnaGsJy2KYgvwaSNpsr
- The fix requires c# inheritance of the existing TreeView class
- AFAIK, such a fix cannot be applied to the existing TreeView object after the main window load

Proposed solutions:
1. SPS includes this fix by default so that when we are adding TreeView control, it uses a fixed class
2. Give the users extended control over Show_MainForm_psf function content so I can manually replace

Code: Select all

$tvModList = New-Object 'System.Windows.Forms.TreeView'
with

Code: Select all

$tvModList = New-Object 'FixedTreeView.FixedTreeView'
User avatar
brittneyr
Site Admin
Posts: 1649
Last visit: Mon Mar 18, 2024 1:47 pm
Answers: 38
Been upvoted: 30 times

Re: Fix TreeView control double click

Post by brittneyr »

We will look into this and get back to you.
Brittney
SAPIEN Technologies, Inc.
User avatar
brittneyr
Site Admin
Posts: 1649
Last visit: Mon Mar 18, 2024 1:47 pm
Answers: 38
Been upvoted: 30 times

Re: Fix TreeView control double click

Post by brittneyr »

After some quick research, did the solution offered to you before not work:
viewtopic.php?t=13078
Brittney
SAPIEN Technologies, Inc.
User avatar
ALIENQuake
Posts: 112
Last visit: Mon Jan 29, 2024 7:35 am
Has voted: 4 times

Re: Fix TreeView control double click

Post by ALIENQuake »

Nope, those solutions didn't work. The main problem is not the 'Expand' on double-click. It's the checkbox check being unregistered. You can clearly see this using my example code when you click on the checkbox but instead of it being checked, TreeViewDoubleClick and NodeMouseDoubleClick events are fired at once after a single left mouse button click.
User avatar
brittneyr
Site Admin
Posts: 1649
Last visit: Mon Mar 18, 2024 1:47 pm
Answers: 38
Been upvoted: 30 times

Re: Fix TreeView control double click

Post by brittneyr »

Please fill out a feature request here and we will look into it:
https://www.sapien.com/requests
Brittney
SAPIEN Technologies, Inc.
User avatar
ALIENQuake
Posts: 112
Last visit: Mon Jan 29, 2024 7:35 am
Has voted: 4 times

Re: Fix TreeView control double click

Post by ALIENQuake »

I can do that but I can this be classified as a bug, not as a feature request? I know that Windows Forms is not something that you created and the bug is inherited. But if there is an easy and straightforward way to fix this, why not do it?
User avatar
brittneyr
Site Admin
Posts: 1649
Last visit: Mon Mar 18, 2024 1:47 pm
Answers: 38
Been upvoted: 30 times

Re: Fix TreeView control double click

Post by brittneyr »

Please fill out a feature request here and we will evaluate how to provide a workaround:
https://www.sapien.com/requests
Brittney
SAPIEN Technologies, Inc.
User avatar
ALIENQuake
Posts: 112
Last visit: Mon Jan 29, 2024 7:35 am
Has voted: 4 times

Re: Fix TreeView control double click

Post by ALIENQuake »

This topic is 1 year and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.