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...