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