"Larry Lard" <la*******@goog lemail.comwrote in message
news:4j******** ****@individual .net...
Steve Marshall wrote:
>I'm working on an owner-drawn combo box which has extended
functionalit y. I have to do something to the dropdown list when it
drops down, then undo it when it is closed up again. But I can't see
an event which seems to be a "CloseUp" event - is there such an event?
Surely there must be!
.NET 2.0: DropDownClosed
Earlier: Override the WndProc message and watch for message
CB_SHOWDROPDOWN (this same message is sent on both drop and close, so it
only means 'close' when it's sent while the dropdown is dropped down).
CB_SHOWDROPDOWN is not a notification message. It's used to drop down the
list programatically . To know when the list closes up you should use the
CBN_CLOSEUP notification. Here's the code for that:
Public Class ComboBoxEx
Inherits ComboBox
Private Const WM_USER As Integer = &H400
Private Const WM_COMMAND As Integer = &H111
Private Const OCM__BASE As Integer = WM_USER + &H1C00
Private Const OCM_COMMAND As Integer = OCM__BASE + WM_COMMAND
Private Function HIWORD(ByVal value As Integer) As Short
Return CShort(New System.Drawing. Point(value).Y)
End Function
Protected Overrides Sub WndProc(ByRef m As System.Windows. Forms.Message)
If m.Msg = OCM_COMMAND Then
Dim code As Integer = HIWORD(m.WParam .ToInt32)
If code = CBN_CLOSEUP Then
OnCloseUp(Event Args.Empty)
End If
End If
MyBase.WndProc( m)
End Sub
Protected Overridable Sub OnCloseUp(ByVal e As System.EventArg s)
RaiseEvent CloseUp(Me, e)
End Sub
Public Event CloseUp As EventHandler
End Class
/claes