.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

TreeView label edit in a palette

11 REPLIES 11
Reply
Message 1 of 12
Anonymous
666 Views, 11 Replies

TreeView label edit in a palette

My .NET application creates a new PaletteSet using a user control that has a
TreeView on it. The TreeView allows label editing, but once you are in label
editing mode, the control does not respond to either ESC or ENTER. I seem to
recall having to deal with this issue in a similar ObjectARX application,
but I'm not sure how to fix it in .NET.

Below is a snippet of code that demonstrates this issue:

With New Autodesk.AutoCAD.Windows.PaletteSet("Test Palette")
Dim objTreeView As New System.Windows.Forms.TreeView
With objTreeView
.Dock = Windows.Forms.DockStyle.Fill
.LabelEdit = True
.Nodes.Add("Edit this node")
End With
.Add("Test Palette", objTreeView)
.Visible = True
End With

Any ideas?

Scott
11 REPLIES 11
Message 2 of 12
Anonymous
in reply to: Anonymous

I assume you have coded the node's KeyUp event to handle Enter and/or
Escape?

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
Message 3 of 12
Anonymous
in reply to: Anonymous

Oops, let me rephrase that.! What I meant to say was have you tried
throwing code into the keyup event for the treeview and the palette to see
if the event registering at all one either of those keys? If not, you may
need the same fix for focus as the combobox control.

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
Message 4 of 12
Anonymous
in reply to: Anonymous

Hi Mike,

Thanks for the reply. The PaletteSet and Palette classes don't appear to
expose any keyboard events themselves. I tried putting some code into the
TreeView's KeyUp event and found that it responds to ESC and ENTER. But when
you go into label edit mode (and the TreeView control creates a temporary
edit box control to edit the label) those keys seem to be ignored - in fact,
the TreeView_KeyUp event is not fired at all when the label edit box is
visible.

- Scott


"Mike Tuersley" wrote in message
news:4939864@discussion.autodesk.com...
Oops, let me rephrase that.! What I meant to say was have you tried
throwing code into the keyup event for the treeview and the palette to see
if the event registering at all one either of those keys? If not, you may
need the same fix for focus as the combobox control.

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
Message 5 of 12
Anonymous
in reply to: Anonymous

"Mike Tuersley" wrote:

> If not, you may need the same fix for focus
> as the combobox control.

Hi Mike. You might be interested in knowing that
the 'fix' you posted for the ComboBox problem (for
not dropping down when you click on the control
while the palette is floating), actually creates more
problems than it solves.

One of those problems is that it corrupts the behavior
of any control that displays an "in-place" edit window
(e.g, TreeView, ListView, DataGrid, etc.).

With your fix, if you try editing a label in a treeview
or listview, and you click inside the label edit window
with the mouse, the label edit window looses and
regains focus, with the entire label text selected.
What should happen is that you should get a vertical
blinking bar cursor at the point where you clicked in
the control, but that doesn't happen.

I haven't looked at the problem with the treeview
(and it should also affect ListViews as well), so I
don't know exactly what's causing it.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com
Message 6 of 12
Anonymous
in reply to: Anonymous

Ouch! Sorry, I didn't mean for that to happen =( Chalk another one up to
"slap it in and see if it works to get me to the due date and I'll sort it
out later"

I'll look at it and weed out the crap and see if I can't revise it with
just the focus you mentioned, Tony. Thanks!

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
Message 7 of 12
Anonymous
in reply to: Anonymous

This TreeView control descendent should solve your problem.
Just use it in lieu of the Syste.Windows.Forms.TreeView.

Sorry about the C#, but I don't do VB. Hopefully, somoene can
translate it for you, or you can build it a separate assembly and
reference it from your VB project.

//////////////////////////////////////////////////////////////////////////////////////
/// DialogTreeView.cs Cooyright (c) 2005 Tony Tanzillo All rights reserved
///
/// For private use only. Do not distribute or
/// publish this code without the express written
/// consent of the author.
///
/// This TreeView descendent addresses the issue
/// described in KB 130691
///
/// See http://support.microsoft.com/default.aspx?scid=kb;en-us;130691

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace StupidControlThunks
{
public class DialogTreeView : TreeView
{
public DialogTreeView()
{
}

private const int TVM_GETEDITCONTROL = 0x110F;

[DllImport("user32.dll", CharSet=CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr hWnd,
int msg, int wParam, int lParam);

private class LabelEditWindowHook : NativeWindow
{
private const int WM_GETDLGCODE = 135;
private const int DLGC_WANTALLKEYS = 0x0004;

public LabelEditWindowHook()
{
}
protected override void WndProc(ref Message m)
{
if( m.Msg == WM_GETDLGCODE )
m.Result = (IntPtr) DLGC_WANTALLKEYS;
else
base.WndProc(ref m);
}
}

private LabelEditWindowHook m_Hook = new LabelEditWindowHook();

protected override void OnBeforeLabelEdit( NodeLabelEditEventArgs e )
{
IntPtr handle = SendMessage(this.Handle, TVM_GETEDITCONTROL, 0, 0);
if( handle != IntPtr.Zero )
m_Hook.AssignHandle(handle);
base.OnBeforeLabelEdit( e );
}

protected override void OnAfterLabelEdit( NodeLabelEditEventArgs e )
{
m_Hook.ReleaseHandle();
base.OnAfterLabelEdit( e );
}
}
}

/////// DialogTreeView.cs ///////////////////////////////////////////////////

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Scott McFarlane" wrote in message news:4939035@discussion.autodesk.com...
My .NET application creates a new PaletteSet using a user control that has a
TreeView on it. The TreeView allows label editing, but once you are in label
editing mode, the control does not respond to either ESC or ENTER. I seem to
recall having to deal with this issue in a similar ObjectARX application,
but I'm not sure how to fix it in .NET.

Below is a snippet of code that demonstrates this issue:

With New Autodesk.AutoCAD.Windows.PaletteSet("Test Palette")
Dim objTreeView As New System.Windows.Forms.TreeView
With objTreeView
.Dock = Windows.Forms.DockStyle.Fill
.LabelEdit = True
.Nodes.Add("Edit this node")
End With
.Add("Test Palette", objTreeView)
.Visible = True
End With

Any ideas?

Scott
Message 8 of 12
Anonymous
in reply to: Anonymous

Fixed version:

//////////////////////////////////////////////////////////////////////////////////////
/// DialogTreeView.cs Cooyright (c) 2005 Tony Tanzillo All rights reserved
///
/// For private use only. Do not distribute or
/// publish this code without the express written
/// consent of the author.
///
/// This TreeView descendent addresses the issue
/// described in KB 130691
///
/// See http://support.microsoft.com/default.aspx?scid=kb;en-us;130691

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace StupidControlThunks
{
public class DialogTreeView : TreeView
{
public DialogTreeView()
{
}

private const int TVM_GETEDITCONTROL = 0x110F;

[DllImport("user32.dll", CharSet=CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr hWnd,
int msg, int wParam, int lParam);

private class LabelEditWindowHook : NativeWindow
{
private const int WM_GETDLGCODE = 135;
private const int DLGC_WANTALLKEYS = 0x0004;

public LabelEditWindowHook()
{
}
protected override void WndProc(ref Message m)
{
if( m.Msg == WM_GETDLGCODE )
m.Result = (IntPtr) DLGC_WANTALLKEYS;
else
base.WndProc(ref m);
}
}

private LabelEditWindowHook m_Hook = new LabelEditWindowHook();

protected override void OnBeforeLabelEdit( NodeLabelEditEventArgs e )
{
base.OnBeforeLabelEdit( e );
if( ! e.CancelEdit )
{
IntPtr handle = SendMessage(this.Handle, TVM_GETEDITCONTROL, 0, 0);
if( handle != IntPtr.Zero )
m_Hook.AssignHandle(handle);
}
}
}
}

/////// DialogTreeView.cs ///////////////////////////////////////////////////



--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Tony Tanzillo" wrote in message news:4941045@discussion.autodesk.com...
This TreeView control descendent should solve your problem.
Just use it in lieu of the Syste.Windows.Forms.TreeView.

Sorry about the C#, but I don't do VB. Hopefully, somoene can
translate it for you, or you can build it a separate assembly and
reference it from your VB project.

//////////////////////////////////////////////////////////////////////////////////////
/// DialogTreeView.cs Cooyright (c) 2005 Tony Tanzillo All rights reserved
///
/// For private use only. Do not distribute or
/// publish this code without the express written
/// consent of the author.
///
/// This TreeView descendent addresses the issue
/// described in KB 130691
///
/// See http://support.microsoft.com/default.aspx?scid=kb;en-us;130691

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace StupidControlThunks
{
public class DialogTreeView : TreeView
{
public DialogTreeView()
{
}

private const int TVM_GETEDITCONTROL = 0x110F;

[DllImport("user32.dll", CharSet=CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr hWnd,
int msg, int wParam, int lParam);

private class LabelEditWindowHook : NativeWindow
{
private const int WM_GETDLGCODE = 135;
private const int DLGC_WANTALLKEYS = 0x0004;

public LabelEditWindowHook()
{
}
protected override void WndProc(ref Message m)
{
if( m.Msg == WM_GETDLGCODE )
m.Result = (IntPtr) DLGC_WANTALLKEYS;
else
base.WndProc(ref m);
}
}

private LabelEditWindowHook m_Hook = new LabelEditWindowHook();

protected override void OnBeforeLabelEdit( NodeLabelEditEventArgs e )
{
IntPtr handle = SendMessage(this.Handle, TVM_GETEDITCONTROL, 0, 0);
if( handle != IntPtr.Zero )
m_Hook.AssignHandle(handle);
base.OnBeforeLabelEdit( e );
}

protected override void OnAfterLabelEdit( NodeLabelEditEventArgs e )
{
m_Hook.ReleaseHandle();
base.OnAfterLabelEdit( e );
}
}
}

/////// DialogTreeView.cs ///////////////////////////////////////////////////

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Scott McFarlane" wrote in message news:4939035@discussion.autodesk.com...
My .NET application creates a new PaletteSet using a user control that has a
TreeView on it. The TreeView allows label editing, but once you are in label
editing mode, the control does not respond to either ESC or ENTER. I seem to
recall having to deal with this issue in a similar ObjectARX application,
but I'm not sure how to fix it in .NET.

Below is a snippet of code that demonstrates this issue:

With New Autodesk.AutoCAD.Windows.PaletteSet("Test Palette")
Dim objTreeView As New System.Windows.Forms.TreeView
With objTreeView
.Dock = Windows.Forms.DockStyle.Fill
.LabelEdit = True
.Nodes.Add("Edit this node")
End With
.Add("Test Palette", objTreeView)
.Visible = True
End With

Any ideas?

Scott
Message 9 of 12
Anonymous
in reply to: Anonymous

The code below has a major bug. Don't use it.

See the next post for a fixed version.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Tony Tanzillo" wrote in message news:4941045@discussion.autodesk.com...
This TreeView control descendent should solve your problem.
Just use it in lieu of the Syste.Windows.Forms.TreeView.

Sorry about the C#, but I don't do VB. Hopefully, somoene can
translate it for you, or you can build it a separate assembly and
reference it from your VB project.

//////////////////////////////////////////////////////////////////////////////////////
/// DialogTreeView.cs Cooyright (c) 2005 Tony Tanzillo All rights reserved
///
/// For private use only. Do not distribute or
/// publish this code without the express written
/// consent of the author.
///
/// This TreeView descendent addresses the issue
/// described in KB 130691
///
/// See http://support.microsoft.com/default.aspx?scid=kb;en-us;130691

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace StupidControlThunks
{
public class DialogTreeView : TreeView
{
public DialogTreeView()
{
}

private const int TVM_GETEDITCONTROL = 0x110F;

[DllImport("user32.dll", CharSet=CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr hWnd,
int msg, int wParam, int lParam);

private class LabelEditWindowHook : NativeWindow
{
private const int WM_GETDLGCODE = 135;
private const int DLGC_WANTALLKEYS = 0x0004;

public LabelEditWindowHook()
{
}
protected override void WndProc(ref Message m)
{
if( m.Msg == WM_GETDLGCODE )
m.Result = (IntPtr) DLGC_WANTALLKEYS;
else
base.WndProc(ref m);
}
}

private LabelEditWindowHook m_Hook = new LabelEditWindowHook();

protected override void OnBeforeLabelEdit( NodeLabelEditEventArgs e )
{
IntPtr handle = SendMessage(this.Handle, TVM_GETEDITCONTROL, 0, 0);
if( handle != IntPtr.Zero )
m_Hook.AssignHandle(handle);
base.OnBeforeLabelEdit( e );
}

protected override void OnAfterLabelEdit( NodeLabelEditEventArgs e )
{
m_Hook.ReleaseHandle();
base.OnAfterLabelEdit( e );
}
}
}

/////// DialogTreeView.cs ///////////////////////////////////////////////////

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Scott McFarlane" wrote in message news:4939035@discussion.autodesk.com...
My .NET application creates a new PaletteSet using a user control that has a
TreeView on it. The TreeView allows label editing, but once you are in label
editing mode, the control does not respond to either ESC or ENTER. I seem to
recall having to deal with this issue in a similar ObjectARX application,
but I'm not sure how to fix it in .NET.

Below is a snippet of code that demonstrates this issue:

With New Autodesk.AutoCAD.Windows.PaletteSet("Test Palette")
Dim objTreeView As New System.Windows.Forms.TreeView
With objTreeView
.Dock = Windows.Forms.DockStyle.Fill
.LabelEdit = True
.Nodes.Add("Edit this node")
End With
.Add("Test Palette", objTreeView)
.Visible = True
End With

Any ideas?

Scott
Message 10 of 12
Anonymous
in reply to: Anonymous

Hi Tony,

Works like a charm. Thanks!

Scott


"Tony Tanzillo" wrote in message
news:4941243@discussion.autodesk.com...
Fixed version:

//////////////////////////////////////////////////////////////////////////////////////
/// DialogTreeView.cs Cooyright (c) 2005 Tony Tanzillo All rights
reserved
///
/// For private use only. Do not distribute or
/// publish this code without the express written
/// consent of the author.
///
/// This TreeView descendent addresses the issue
/// described in KB 130691
///
/// See http://support.microsoft.com/default.aspx?scid=kb;en-us;130691

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace StupidControlThunks
{
public class DialogTreeView : TreeView
{
public DialogTreeView()
{
}

private const int TVM_GETEDITCONTROL = 0x110F;

[DllImport("user32.dll", CharSet=CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr hWnd,
int msg, int wParam, int lParam);

private class LabelEditWindowHook : NativeWindow
{
private const int WM_GETDLGCODE = 135;
private const int DLGC_WANTALLKEYS = 0x0004;

public LabelEditWindowHook()
{
}
protected override void WndProc(ref Message m)
{
if( m.Msg == WM_GETDLGCODE )
m.Result = (IntPtr) DLGC_WANTALLKEYS;
else
base.WndProc(ref m);
}
}

private LabelEditWindowHook m_Hook = new LabelEditWindowHook();

protected override void OnBeforeLabelEdit( NodeLabelEditEventArgs e )
{
base.OnBeforeLabelEdit( e );
if( ! e.CancelEdit )
{
IntPtr handle = SendMessage(this.Handle, TVM_GETEDITCONTROL, 0,
0);
if( handle != IntPtr.Zero )
m_Hook.AssignHandle(handle);
}
}
}
}

/////// DialogTreeView.cs
///////////////////////////////////////////////////



--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Tony Tanzillo" wrote in message
news:4941045@discussion.autodesk.com...
This TreeView control descendent should solve your problem.
Just use it in lieu of the Syste.Windows.Forms.TreeView.

Sorry about the C#, but I don't do VB. Hopefully, somoene can
translate it for you, or you can build it a separate assembly and
reference it from your VB project.

//////////////////////////////////////////////////////////////////////////////////////
/// DialogTreeView.cs Cooyright (c) 2005 Tony Tanzillo All rights
reserved
///
/// For private use only. Do not distribute or
/// publish this code without the express written
/// consent of the author.
///
/// This TreeView descendent addresses the issue
/// described in KB 130691
///
/// See http://support.microsoft.com/default.aspx?scid=kb;en-us;130691

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace StupidControlThunks
{
public class DialogTreeView : TreeView
{
public DialogTreeView()
{
}

private const int TVM_GETEDITCONTROL = 0x110F;

[DllImport("user32.dll", CharSet=CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr hWnd,
int msg, int wParam, int lParam);

private class LabelEditWindowHook : NativeWindow
{
private const int WM_GETDLGCODE = 135;
private const int DLGC_WANTALLKEYS = 0x0004;

public LabelEditWindowHook()
{
}
protected override void WndProc(ref Message m)
{
if( m.Msg == WM_GETDLGCODE )
m.Result = (IntPtr) DLGC_WANTALLKEYS;
else
base.WndProc(ref m);
}
}

private LabelEditWindowHook m_Hook = new LabelEditWindowHook();

protected override void OnBeforeLabelEdit( NodeLabelEditEventArgs e )
{
IntPtr handle = SendMessage(this.Handle, TVM_GETEDITCONTROL, 0, 0);
if( handle != IntPtr.Zero )
m_Hook.AssignHandle(handle);
base.OnBeforeLabelEdit( e );
}

protected override void OnAfterLabelEdit( NodeLabelEditEventArgs e )
{
m_Hook.ReleaseHandle();
base.OnAfterLabelEdit( e );
}
}
}

/////// DialogTreeView.cs
///////////////////////////////////////////////////

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Scott McFarlane" wrote in message
news:4939035@discussion.autodesk.com...
My .NET application creates a new PaletteSet using a user control that has a
TreeView on it. The TreeView allows label editing, but once you are in label
editing mode, the control does not respond to either ESC or ENTER. I seem to
recall having to deal with this issue in a similar ObjectARX application,
but I'm not sure how to fix it in .NET.

Below is a snippet of code that demonstrates this issue:

With New Autodesk.AutoCAD.Windows.PaletteSet("Test Palette")
Dim objTreeView As New System.Windows.Forms.TreeView
With objTreeView
.Dock = Windows.Forms.DockStyle.Fill
.LabelEdit = True
.Nodes.Add("Edit this node")
End With
.Add("Test Palette", objTreeView)
.Visible = True
End With

Any ideas?

Scott
Message 11 of 12
Anonymous
in reply to: Anonymous

You may want to fix that "cooyright" too. ;^)

--
R. Robert Bell


"Tony Tanzillo" wrote in message
news:4941709@discussion.autodesk.com...
The code below has a major bug. Don't use it.

See the next post for a fixed version.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Tony Tanzillo" wrote in message
news:4941045@discussion.autodesk.com...
This TreeView control descendent should solve your problem.
Just use it in lieu of the Syste.Windows.Forms.TreeView.

Sorry about the C#, but I don't do VB. Hopefully, somoene can
translate it for you, or you can build it a separate assembly and
reference it from your VB project.

//////////////////////////////////////////////////////////////////////////////////////
/// DialogTreeView.cs Cooyright (c) 2005 Tony Tanzillo All rights
reserved
///
/// For private use only. Do not distribute or
/// publish this code without the express written
Message 12 of 12
Anonymous
in reply to: Anonymous

Well, at least you were able to see that flaw,
if nothing else.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"R. Robert Bell" wrote in message news:4942183@discussion.autodesk.com...
You may want to fix that "cooyright" too. ;^)

--
R. Robert Bell


"Tony Tanzillo" wrote in message
news:4941709@discussion.autodesk.com...
The code below has a major bug. Don't use it.

See the next post for a fixed version.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Tony Tanzillo" wrote in message
news:4941045@discussion.autodesk.com...
This TreeView control descendent should solve your problem.
Just use it in lieu of the Syste.Windows.Forms.TreeView.

Sorry about the C#, but I don't do VB. Hopefully, somoene can
translate it for you, or you can build it a separate assembly and
reference it from your VB project.

//////////////////////////////////////////////////////////////////////////////////////
/// DialogTreeView.cs Cooyright (c) 2005 Tony Tanzillo All rights
reserved
///
/// For private use only. Do not distribute or
/// publish this code without the express written

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost