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

ComboBox Problem on Tool Palette (ObjectARX managed API)

10 REPLIES 10
Reply
Message 1 of 11
Anonymous
1167 Views, 10 Replies

ComboBox Problem on Tool Palette (ObjectARX managed API)

I am exploring ObjectARX managed API for a possible CAD application (ACAD
MAP2006)

I have built a small Windows form user conrol with a combo box. This user
control is to be placed on Acad's tool palette. The problem occurs when the
tool palette is docked: I cannot select item in the combobox' dropdown list
(whther the dropdown style is set to DropDown or DropDownList, no
difference). As soon as the mouse pointer leaves the "Dropdown Arrow", the
dropdown list dispears, thus no selection can be made. However, if I drag
the tool palette to floating, the combobox acts normally.

Does anyone exeprience the same behaviour of tool palette, built in
ObjectARX .NET API?

Code snippet as following:

public class MapSearchPalette
{
static Autodesk.AutoCAD.Windows.Palette ps=null;

[Autodesk.AutoCAD.Runtime.CommandMethod("MapSearch")]
public static void ShowMapSearchPalette()
{
if (ps!=null) return;

//Create MapSearchControl
//which is in a seperate *.dll file with a few Windows User Controls
defined
MapSearchControl ctrl=new MapSearchControl();

ps=new Autodesk.AutoCAD.Windows.PaletteSet("Map Search",
new Guid("63B8DB5B-10E4-4924-B8A2-A9CF9158E4F6"));
ps.Style = Autodesk.AutoCAD.Windows.PaletteSetStyles.NameEditable |
Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowPropertiesMenu |
Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowAutoHideButton |
Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowCloseButton |
Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowTabForSingle;
ps.MinimumSize = new System.Drawing.Size(400,250);
ps.Add("Map Search",ctrl);
ps.Visible=true;
}
}
10 REPLIES 10
Message 2 of 11
Anonymous
in reply to: Anonymous

Use the following derivative instead of the standard
.NET ComboBox control, and that should do it.

public class AcadPaletteCombo : System.Windows.Forms.ComboBox
{
protected override void WndProc( ref Message m )
{
if( m.Msg != 0x0167 )
base.WndProc( ref m );
}
}

--
http://www.caddzone.com

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

"Norman Yuan" wrote in message news:4929045@discussion.autodesk.com...
I am exploring ObjectARX managed API for a possible CAD application (ACAD
MAP2006)

I have built a small Windows form user conrol with a combo box. This user
control is to be placed on Acad's tool palette. The problem occurs when the
tool palette is docked: I cannot select item in the combobox' dropdown list
(whther the dropdown style is set to DropDown or DropDownList, no
difference). As soon as the mouse pointer leaves the "Dropdown Arrow", the
dropdown list dispears, thus no selection can be made. However, if I drag
the tool palette to floating, the combobox acts normally.

Does anyone exeprience the same behaviour of tool palette, built in
ObjectARX .NET API?

Code snippet as following:

public class MapSearchPalette
{
static Autodesk.AutoCAD.Windows.Palette ps=null;

[Autodesk.AutoCAD.Runtime.CommandMethod("MapSearch")]
public static void ShowMapSearchPalette()
{
if (ps!=null) return;

//Create MapSearchControl
//which is in a seperate *.dll file with a few Windows User Controls
defined
MapSearchControl ctrl=new MapSearchControl();

ps=new Autodesk.AutoCAD.Windows.PaletteSet("Map Search",
new Guid("63B8DB5B-10E4-4924-B8A2-A9CF9158E4F6"));
ps.Style = Autodesk.AutoCAD.Windows.PaletteSetStyles.NameEditable |
Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowPropertiesMenu |
Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowAutoHideButton |
Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowCloseButton |
Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowTabForSingle;
ps.MinimumSize = new System.Drawing.Size(400,250);
ps.Add("Map Search",ctrl);
ps.Visible=true;
}
}
Message 3 of 11
Anonymous
in reply to: Anonymous

Tony,

Thanks for the code, but it is not working: the combobox behaves the same
way.
I did use the derived combo box in my UserControl (it works well in a Win
Form test app, either with Windows.Forms.ComboBox or the derived ComboBox,
BTW).

Actually, my previous post was not very accurate: the Windows.Forms.ComboBox
also behaves slightly abnormal on floating custom tool palette.

The abnormality of ComboBox on tool palette is list below:

1. When the custom palette is docked:

Clicking on the combobox, dropdown list pops up. You can use arrow up/down
key to select items in the list. As soon as you move mouse pointer into the
dropdown list (to select item), the dropdown list disappears (so you cannot
select with mouse). Also, When the dropdown list is shown, you can move the
mouse pointer within the custom palette with the dropdown list still being
shown, as soon as the mouse pointer moves to outside the custom palette, the
dropdown list disappears (while Acad built-in combobox on its native
palette/toolbar keeps its dropdown list shown no matter where the mouse
pointer moves, until you click).

2. When the custom palette is floating:

If the custom palette has focus, the combobox works normally. However, if
the custom palette does not have focus before you click the combobox, you
need click it twice to get dropdown list shown (the first click gets the
dropdown list shows and disappears in a flash, the effect is only to get the
combobox focus). With Acad native palette (floating, having focus or not),
single click on combobox pops up its dropdown list.

So, I guess, this behaviour of Windows.Forms.ComboBox could be a buggy
implement of managed API for the ObjectARX's tool palette. If so, where to
report it? Might it be too late for Acad2006 SP1 to get it fixed?

"Tony Tanzillo" wrote in message
news:4930564@discussion.autodesk.com...
Use the following derivative instead of the standard
.NET ComboBox control, and that should do it.

public class AcadPaletteCombo : System.Windows.Forms.ComboBox
{
protected override void WndProc( ref Message m )
{
if( m.Msg != 0x0167 )
base.WndProc( ref m );
}
}

--
http://www.caddzone.com

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

"Norman Yuan" wrote in message
news:4929045@discussion.autodesk.com...
I am exploring ObjectARX managed API for a possible CAD application (ACAD
MAP2006)

I have built a small Windows form user conrol with a combo box. This user
control is to be placed on Acad's tool palette. The problem occurs when the
tool palette is docked: I cannot select item in the combobox' dropdown list
(whther the dropdown style is set to DropDown or DropDownList, no
difference). As soon as the mouse pointer leaves the "Dropdown Arrow", the
dropdown list dispears, thus no selection can be made. However, if I drag
the tool palette to floating, the combobox acts normally.

Does anyone exeprience the same behaviour of tool palette, built in
ObjectARX .NET API?

Code snippet as following:

public class MapSearchPalette
{
static Autodesk.AutoCAD.Windows.Palette ps=null;

[Autodesk.AutoCAD.Runtime.CommandMethod("MapSearch")]
public static void ShowMapSearchPalette()
{
if (ps!=null) return;

//Create MapSearchControl
//which is in a seperate *.dll file with a few Windows User Controls
defined
MapSearchControl ctrl=new MapSearchControl();

ps=new Autodesk.AutoCAD.Windows.PaletteSet("Map Search",
new Guid("63B8DB5B-10E4-4924-B8A2-A9CF9158E4F6"));
ps.Style = Autodesk.AutoCAD.Windows.PaletteSetStyles.NameEditable |
Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowPropertiesMenu |
Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowAutoHideButton |
Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowCloseButton |
Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowTabForSingle;
ps.MinimumSize = new System.Drawing.Size(400,250);
ps.Add("Map Search",ctrl);
ps.Visible=true;
}
}
Message 4 of 11
Anonymous
in reply to: Anonymous

Autodesk is already aware of the issue and being this late in their year, I
wouldn't expect to see it till Acad2007 is released. Throw the code below
on your usercontrol [that represents the tool palette] and you shouldn't
have any more issues.

Regarding the code, there may be more here than is necessary and it is
hacky, but it works and I haven't had time to go through and optimize it.
Beware of word wrap!

Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_CONTROLPARENT As Integer = 65536
Private Const CBN_DROPDOWN As Integer = &H7
Private Const CBN_CLOSEUP As Integer = &H8
Private Const WM_COMMAND As Integer = &H111
Private Const WM_MOUSEACTIVATE As Integer = &H21
Private Const MA_ACTIVATE As Integer = &H1
Private Const WinformReflectionBase As Integer = &H2000

_
Private Shared Function SetWindowLong(ByVal hWnd As IntPtr, _
ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
End Function

_
Private Shared Function GetWindowLong(ByVal hWnd As IntPtr, _
ByVal nIndex As Integer) As Integer
End Function

_
Private Shared Function GetParent(ByVal hWnd As IntPtr) As IntPtr
End Function

#Region "UserControl Extras"

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
'check to see if control is activated
If m.Msg = 133 Then
'set the focus and populate the control is needed
Me.Focus()
ElseIf m.Msg = WinformReflectionBase + WM_COMMAND Then
Dim notifyCode As Integer = m.WParam.ToInt32()
notifyCode = notifyCode / &H10000
'''NOTE: ps is your global/local PaletteSet object
If notifyCode = CBN_DROPDOWN Then
ps.KeepFocus = True
ElseIf notifyCode = CBN_CLOSEUP Then
ps.KeepFocus = False
Else
'nothing for now
End If
'Watch out for the WM_MOUSEACTIVATE message and activate the control.
ElseIf m.Msg = WM_MOUSEACTIVATE Then
m.Result = New IntPtr(MA_ACTIVATE)
Return
End If
'make sure to continue with the normal flow of the message
MyBase.WndProc(m)
End Sub

Protected Overloads Overrides Sub OnLoad(ByVal e As EventArgs)
Dim hwndParent As IntPtr = GetParent(Me.Handle)
SetWindowLong(hwndParent, GWL_EXSTYLE, GetWindowLong(hwndParent, _
GWL_EXSTYLE) Or WS_EX_CONTROLPARENT)
MyBase.OnLoad(e)
End Sub

#End Region


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

Thank yo very much for the code. I'll give it a try later.

"Mike Tuersley" wrote in message
news:4931205@discussion.autodesk.com...
Autodesk is already aware of the issue and being this late in their year, I
wouldn't expect to see it till Acad2007 is released. Throw the code below
on your usercontrol [that represents the tool palette] and you shouldn't
have any more issues.

Regarding the code, there may be more here than is necessary and it is
hacky, but it works and I haven't had time to go through and optimize it.
Beware of word wrap!

Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_CONTROLPARENT As Integer = 65536
Private Const CBN_DROPDOWN As Integer = &H7
Private Const CBN_CLOSEUP As Integer = &H8
Private Const WM_COMMAND As Integer = &H111
Private Const WM_MOUSEACTIVATE As Integer = &H21
Private Const MA_ACTIVATE As Integer = &H1
Private Const WinformReflectionBase As Integer = &H2000

_
Private Shared Function SetWindowLong(ByVal hWnd As IntPtr, _
ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
End Function

_
Private Shared Function GetWindowLong(ByVal hWnd As IntPtr, _
ByVal nIndex As Integer) As Integer
End Function

_
Private Shared Function GetParent(ByVal hWnd As IntPtr) As IntPtr
End Function

#Region "UserControl Extras"

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
'check to see if control is activated
If m.Msg = 133 Then
'set the focus and populate the control is needed
Me.Focus()
ElseIf m.Msg = WinformReflectionBase + WM_COMMAND Then
Dim notifyCode As Integer = m.WParam.ToInt32()
notifyCode = notifyCode / &H10000
'''NOTE: ps is your global/local PaletteSet object
If notifyCode = CBN_DROPDOWN Then
ps.KeepFocus = True
ElseIf notifyCode = CBN_CLOSEUP Then
ps.KeepFocus = False
Else
'nothing for now
End If
'Watch out for the WM_MOUSEACTIVATE message and activate the control.
ElseIf m.Msg = WM_MOUSEACTIVATE Then
m.Result = New IntPtr(MA_ACTIVATE)
Return
End If
'make sure to continue with the normal flow of the message
MyBase.WndProc(m)
End Sub

Protected Overloads Overrides Sub OnLoad(ByVal e As EventArgs)
Dim hwndParent As IntPtr = GetParent(Me.Handle)
SetWindowLong(hwndParent, GWL_EXSTYLE, GetWindowLong(hwndParent, _
GWL_EXSTYLE) Or WS_EX_CONTROLPARENT)
MyBase.OnLoad(e)
End Sub

#End Region


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

Hi Mike - while as it turns out the problem is the KeepFocus
property of the PaletteSet, I don't understand the 'fix'.

What's wrong with just setting the PaletteSet's KeepFocus
property to true ?

--
http://www.caddzone.com

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

"Mike Tuersley" wrote in message news:4931205@discussion.autodesk.com...
Autodesk is already aware of the issue and being this late in their year, I
wouldn't expect to see it till Acad2007 is released. Throw the code below
on your usercontrol [that represents the tool palette] and you shouldn't
have any more issues.

Regarding the code, there may be more here than is necessary and it is
hacky, but it works and I haven't had time to go through and optimize it.
Beware of word wrap!

Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_CONTROLPARENT As Integer = 65536
Private Const CBN_DROPDOWN As Integer = &H7
Private Const CBN_CLOSEUP As Integer = &H8
Private Const WM_COMMAND As Integer = &H111
Private Const WM_MOUSEACTIVATE As Integer = &H21
Private Const MA_ACTIVATE As Integer = &H1
Private Const WinformReflectionBase As Integer = &H2000

_
Private Shared Function SetWindowLong(ByVal hWnd As IntPtr, _
ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
End Function

_
Private Shared Function GetWindowLong(ByVal hWnd As IntPtr, _
ByVal nIndex As Integer) As Integer
End Function

_
Private Shared Function GetParent(ByVal hWnd As IntPtr) As IntPtr
End Function

#Region "UserControl Extras"

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
'check to see if control is activated
If m.Msg = 133 Then
'set the focus and populate the control is needed
Me.Focus()
ElseIf m.Msg = WinformReflectionBase + WM_COMMAND Then
Dim notifyCode As Integer = m.WParam.ToInt32()
notifyCode = notifyCode / &H10000
'''NOTE: ps is your global/local PaletteSet object
If notifyCode = CBN_DROPDOWN Then
ps.KeepFocus = True
ElseIf notifyCode = CBN_CLOSEUP Then
ps.KeepFocus = False
Else
'nothing for now
End If
'Watch out for the WM_MOUSEACTIVATE message and activate the control.
ElseIf m.Msg = WM_MOUSEACTIVATE Then
m.Result = New IntPtr(MA_ACTIVATE)
Return
End If
'make sure to continue with the normal flow of the message
MyBase.WndProc(m)
End Sub

Protected Overloads Overrides Sub OnLoad(ByVal e As EventArgs)
Dim hwndParent As IntPtr = GetParent(Me.Handle)
SetWindowLong(hwndParent, GWL_EXSTYLE, GetWindowLong(hwndParent, _
GWL_EXSTYLE) Or WS_EX_CONTROLPARENT)
MyBase.OnLoad(e)
End Sub

#End Region


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

Norman - You should know that you can just as easily
set the KeepFocus property of the PaletteSet to true,
to avoid the problem. AutoCAD is stealing focus from
the control, because it is seeing the dropdown control
of the combobox as a popup, and it is sending out the
WM_ACADKEEPFOCUS message to the PaletteSet, which
reponds that it doesn't want to keep the focus (when
the KeepFocus property is false).

Just set KeepFocus to True, and that should solve one of
the problems. I'm not familiar with the other problems
Mike's code solves, but he's taking the 'VB6' approach to
things, which is unnecessary in .NET.

To change the window style, you just override the
Control.CreateParams property, like this:

protected override CreateParams CreateParams
{
get
{
return base.CreateParams |= (int) WS_EX_CONTROLPARENT;
}
}

--
http://www.caddzone.com

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

"Norman Yuan" wrote in message news:4931424@discussion.autodesk.com...
Thank yo very much for the code. I'll give it a try later.

"Mike Tuersley" wrote in message
news:4931205@discussion.autodesk.com...
Autodesk is already aware of the issue and being this late in their year, I
wouldn't expect to see it till Acad2007 is released. Throw the code below
on your usercontrol [that represents the tool palette] and you shouldn't
have any more issues.

Regarding the code, there may be more here than is necessary and it is
hacky, but it works and I haven't had time to go through and optimize it.
Beware of word wrap!

Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_CONTROLPARENT As Integer = 65536
Private Const CBN_DROPDOWN As Integer = &H7
Private Const CBN_CLOSEUP As Integer = &H8
Private Const WM_COMMAND As Integer = &H111
Private Const WM_MOUSEACTIVATE As Integer = &H21
Private Const MA_ACTIVATE As Integer = &H1
Private Const WinformReflectionBase As Integer = &H2000

_
Private Shared Function SetWindowLong(ByVal hWnd As IntPtr, _
ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
End Function

_
Private Shared Function GetWindowLong(ByVal hWnd As IntPtr, _
ByVal nIndex As Integer) As Integer
End Function

_
Private Shared Function GetParent(ByVal hWnd As IntPtr) As IntPtr
End Function

#Region "UserControl Extras"

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
'check to see if control is activated
If m.Msg = 133 Then
'set the focus and populate the control is needed
Me.Focus()
ElseIf m.Msg = WinformReflectionBase + WM_COMMAND Then
Dim notifyCode As Integer = m.WParam.ToInt32()
notifyCode = notifyCode / &H10000
'''NOTE: ps is your global/local PaletteSet object
If notifyCode = CBN_DROPDOWN Then
ps.KeepFocus = True
ElseIf notifyCode = CBN_CLOSEUP Then
ps.KeepFocus = False
Else
'nothing for now
End If
'Watch out for the WM_MOUSEACTIVATE message and activate the control.
ElseIf m.Msg = WM_MOUSEACTIVATE Then
m.Result = New IntPtr(MA_ACTIVATE)
Return
End If
'make sure to continue with the normal flow of the message
MyBase.WndProc(m)
End Sub

Protected Overloads Overrides Sub OnLoad(ByVal e As EventArgs)
Dim hwndParent As IntPtr = GetParent(Me.Handle)
SetWindowLong(hwndParent, GWL_EXSTYLE, GetWindowLong(hwndParent, _
GWL_EXSTYLE) Or WS_EX_CONTROLPARENT)
MyBase.OnLoad(e)
End Sub

#End Region


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

Hi Tony,

> What's wrong with just setting the PaletteSet's KeepFocus
> property to true ?

Time??? As I said, I haven't had time to determine what's baggage/garbage
vs. what actually fixes it. I've had lots of oddities occur with my palette
project and the code I posted is a composite of various answers to combobox
issues in 2006 and VS2003.

I'll try the KeepFocus and see if it works - Thanks!

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

Hi Mike - With time, I'm sure you'll also realize that
any Palette with controls on it that accept keyboard
input (e.g., text boxes, editable combos, etc.), requires
the PaletteSet's KeepFocus property to be true.

If it is not, the user will be forced to keep the mouse
cursor inside of the Pallet control when they enter text
into its controls with the keyboard which of course, is
something you would not wish on your worst enemy 🙂

The other issue, is that when you implement fixes like
the ones you show, they should be in a base class that
can be inherited from, so that any class derived from it
will also inherit the functionality, without having to copy
and paste all of that um... code into each control you
build for hosting on a Palette.

--
http://www.caddzone.com

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

"Mike Tuersley" wrote in message news:4931844@discussion.autodesk.com...
Hi Tony,

> What's wrong with just setting the PaletteSet's KeepFocus
> property to true ?

Time??? As I said, I haven't had time to determine what's baggage/garbage
vs. what actually fixes it. I've had lots of oddities occur with my palette
project and the code I posted is a composite of various answers to combobox
issues in 2006 and VS2003.

I'll try the KeepFocus and see if it works - Thanks!

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

Thank you very much, Tony!

I did not notice there is "KeepFocus" property. (I do not like the "Object
Browser: in VS, it is buggy. I miss the way in VB/VBA to browse object).

Basically, set "KeepFocus" to "true" solve the problem when tool palette is
docked. However, when the tool palette is floating and the focus is not on
the floating window, you still need two clicks to pull down combobox's list
(the first click gets the list poping up and disappearing quickly). I can
live with that and hope this will be fixed in future Acad release, so that I
can avoid to roll out a derived combo box and make thing unnecessarily
complicated.

Thanks again.

"Tony Tanzillo" wrote in message
news:4931792@discussion.autodesk.com...
Norman - You should know that you can just as easily
set the KeepFocus property of the PaletteSet to true,
to avoid the problem. AutoCAD is stealing focus from
the control, because it is seeing the dropdown control
of the combobox as a popup, and it is sending out the
WM_ACADKEEPFOCUS message to the PaletteSet, which
reponds that it doesn't want to keep the focus (when
the KeepFocus property is false).

Just set KeepFocus to True, and that should solve one of
the problems. I'm not familiar with the other problems
Mike's code solves, but he's taking the 'VB6' approach to
things, which is unnecessary in .NET.

To change the window style, you just override the
Control.CreateParams property, like this:

protected override CreateParams CreateParams
{
get
{
return base.CreateParams |= (int) WS_EX_CONTROLPARENT;
}
}

--
http://www.caddzone.com

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

"Norman Yuan" wrote in message
news:4931424@discussion.autodesk.com...
Thank yo very much for the code. I'll give it a try later.

"Mike Tuersley" wrote in message
news:4931205@discussion.autodesk.com...
Autodesk is already aware of the issue and being this late in their year, I
wouldn't expect to see it till Acad2007 is released. Throw the code below
on your usercontrol [that represents the tool palette] and you shouldn't
have any more issues.

Regarding the code, there may be more here than is necessary and it is
hacky, but it works and I haven't had time to go through and optimize it.
Beware of word wrap!

Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_CONTROLPARENT As Integer = 65536
Private Const CBN_DROPDOWN As Integer = &H7
Private Const CBN_CLOSEUP As Integer = &H8
Private Const WM_COMMAND As Integer = &H111
Private Const WM_MOUSEACTIVATE As Integer = &H21
Private Const MA_ACTIVATE As Integer = &H1
Private Const WinformReflectionBase As Integer = &H2000

_
Private Shared Function SetWindowLong(ByVal hWnd As IntPtr, _
ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
End Function

_
Private Shared Function GetWindowLong(ByVal hWnd As IntPtr, _
ByVal nIndex As Integer) As Integer
End Function

_
Private Shared Function GetParent(ByVal hWnd As IntPtr) As IntPtr
End Function

#Region "UserControl Extras"

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
'check to see if control is activated
If m.Msg = 133 Then
'set the focus and populate the control is needed
Me.Focus()
ElseIf m.Msg = WinformReflectionBase + WM_COMMAND Then
Dim notifyCode As Integer = m.WParam.ToInt32()
notifyCode = notifyCode / &H10000
'''NOTE: ps is your global/local PaletteSet object
If notifyCode = CBN_DROPDOWN Then
ps.KeepFocus = True
ElseIf notifyCode = CBN_CLOSEUP Then
ps.KeepFocus = False
Else
'nothing for now
End If
'Watch out for the WM_MOUSEACTIVATE message and activate the control.
ElseIf m.Msg = WM_MOUSEACTIVATE Then
m.Result = New IntPtr(MA_ACTIVATE)
Return
End If
'make sure to continue with the normal flow of the message
MyBase.WndProc(m)
End Sub

Protected Overloads Overrides Sub OnLoad(ByVal e As EventArgs)
Dim hwndParent As IntPtr = GetParent(Me.Handle)
SetWindowLong(hwndParent, GWL_EXSTYLE, GetWindowLong(hwndParent, _
GWL_EXSTYLE) Or WS_EX_CONTROLPARENT)
MyBase.OnLoad(e)
End Sub

#End Region


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

Good points to note, Tony, thanks!

I wasn't concerned with keybard input because there is none - everything
works off combos, up/dn numerics, next/prev buttons, etc. This is all per
customer request which has been the cause of some inconsistancies but the
biggest is the difference in communication [for lack of a better term] with
the tool palette when it is in a docked vs floating state.

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...

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