Home All Groups Group Topic Archive Search About

PostMessage and Combobox

Author
3 Feb 2006 11:19 AM
EAdolphson
In my ComboBox, I am trying to post the CBN_EDITCHANGE message after the
CBN_SELCHANGE is received, but I am having no luck.  I can trap for the
CBN_SELCHANGE message, but I cannot post the CBN_EDITCHANGE message.  I think
my PostMessage parameters are wrong, but I cannot find what they should be. 
Any help would be greatly appreciated.  Thanks.

Here is my code.  I am using VS 2003 and Visual Basic.

Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
        (ByVal hwnd As Long, _
        ByVal wMsg As Long, _
        ByVal wParam As Long, _
        ByVal lParam As Long) As Long


Protected Overrides Sub WndProc(ByRef m As Message)
        MyBase.WndProc(m)

        Const CBN_SELCHANGE As Int32 = &H1
        Const CBN_EDITCHANGE As Int32 = &H5
        Const CBN_EDITUPDATE As Int32 = &H6
        Const CBN_CLOSEUP As Int32 = &H8
        Const CBN_SELENDOK As Int32 = &H9
        Const WM_COMMAND As Int32 = &H111
        Const WM_USER As Int32 = &H400
        Const OCM__BASE As Int32 = WM_USER + &H1C00
        Const OCM_COMMAND As Int32 = OCM__BASE + WM_COMMAND

        If m.Msg = OCM_COMMAND Then
            Dim CbAction As Int32 = (m.WParam.ToInt32 >> 16)    ' combobox
action
            Select Case CbAction
                Case CBN_SELCHANGE
                    PostMessage(Me.Handle.ToInt32, OCM_COMMAND,
CBN_EDITCHANGE << 16, 0)
                Case CBN_EDITCHANGE
                Case CBN_CLOSEUP
                Case CBN_SELENDOK
            End Select
        End If
End Sub

Author
3 Feb 2006 3:25 PM
Armin Zingler
Show quote Hide quote
"EAdolphson" <EAdolph***@discussions.microsoft.com> schrieb
> In my ComboBox, I am trying to post the CBN_EDITCHANGE message after
> the CBN_SELCHANGE is received, but I am having no luck.  I can trap
> for the CBN_SELCHANGE message, but I cannot post the CBN_EDITCHANGE
> message.  I think my PostMessage parameters are wrong, but I cannot
> find what they should be. Any help would be greatly appreciated.
> Thanks.
>
> Here is my code.  I am using VS 2003 and Visual Basic.
>
> Private Declare Function PostMessage Lib "user32" Alias
> "PostMessageA" _
>        (ByVal hwnd As Long, _
>        ByVal wMsg As Long, _
>        ByVal wParam As Long, _
>        ByVal lParam As Long) As Long



I didn't check the code (if there's a .Net way to do it) but the declaration
is for previous VB versions. Use this one instead:

Private Declare Function PostMessage Lib "user32" Alias
"PostMessageA" _
        (ByVal hwnd As intptr, _
        ByVal wMsg As integer, _
        ByVal wParam As integer, _
        ByVal lParam As integer) As boolean



Armin
Author
3 Feb 2006 5:11 PM
EAdolphson
Searching the 'net, my declaration is correct VB .NET.  All the params need
to be declared as Long not Integer.  I still need help getting the parameter
values.

Show quoteHide quote
"Armin Zingler" wrote:

> "EAdolphson" <EAdolph***@discussions.microsoft.com> schrieb
> > In my ComboBox, I am trying to post the CBN_EDITCHANGE message after
> > the CBN_SELCHANGE is received, but I am having no luck.  I can trap
> > for the CBN_SELCHANGE message, but I cannot post the CBN_EDITCHANGE
> > message.  I think my PostMessage parameters are wrong, but I cannot
> > find what they should be. Any help would be greatly appreciated.
> > Thanks.
> >
> > Here is my code.  I am using VS 2003 and Visual Basic.
> >
> > Private Declare Function PostMessage Lib "user32" Alias
> > "PostMessageA" _
> >        (ByVal hwnd As Long, _
> >        ByVal wMsg As Long, _
> >        ByVal wParam As Long, _
> >        ByVal lParam As Long) As Long
>
>
>
> I didn't check the code (if there's a .Net way to do it) but the declaration
> is for previous VB versions. Use this one instead:
>
>  Private Declare Function PostMessage Lib "user32" Alias
>  "PostMessageA" _
>         (ByVal hwnd As intptr, _
>         ByVal wMsg As integer, _
>         ByVal wParam As integer, _
>         ByVal lParam As integer) As boolean
>
>
>
> Armin
>
>
Author
3 Feb 2006 5:24 PM
Armin Zingler
"EAdolphson" <EAdolph***@discussions.microsoft.com> schrieb
> Searching the 'net, my declaration is correct VB .NET.  All the
> params need to be declared as Long not Integer.

No.

You may also declare wparam and lparam as IntPtr. See
System.Windows.Forms.Message.


Armin