Re: window messages

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Tom Esh (tjeshGibberish_at_earthlink.net)
Date: 02/23/04


Date: Mon, 23 Feb 2004 00:15:32 -0500

If this is a continuation of your previous thread (Updating
Listboxes), then you're sending the wrong notification code.
CBN_EDITCHANGE only applies to combos with an edit control, not those
with just a dropdown. It should be CBN_SELCHANGE.
Also when sending SELECTSTRING, make sure your string in lParam is
passed ByVal. Your "SendMessageText" declare may do that, however if
so it will not work with WM_COMMAND, since lParam is not a string in
that case.

Ex:
Public Const WM_COMMAND = &H111
Public Const CBN_SELCHANGE = 1
Public Const CB_SELECTSTRING = &H14D
Public Declare Function SendMessage Lib "user32" _
        Alias "SendMessageA" _
        (ByVal hWnd As Long, ByVal wMsg As Long, _
        ByVal wParam As Long, lParam As Any) As Long
Public Declare Function GetDlgCtrlID Lib "user32" _
        (ByVal hWnd As Long) As Long

\
Dim wParam As Long

wParam = (CBN_SELCHANGE * &H10000) + GetDlgCtrlID(hChild)
SendMessage hChild,CB_SELECTSTRING, -1&, ByVal TempString
SendMessage Wnd,WM_COMMAND, wParam, ByVal hChild

On Sun, 22 Feb 2004 21:13:06 -0500, "JonWayn" <jongunn@bellsouth.net>
wrote:

>TempString = "Local" & vbNullChaR
>? SendMessageText(hChild,CB_SELECTSTRING,-1,TempString) ' *
>LoWord = GetDlgCtrlID(hChild)
>HiWord = CB_EDITCHANGE
>
>lngDWord = (lngDWord And &HFFFF) Or (HiWord * 2 ^ 16)
>lngDWord = (lngDWord And &HFFFF0000) Or LoWord
>
>? SendMessageText(Wnd,WM_COMMAND,lDWord,hChild) ' **
>
>'================================================================
>Refer to the asterisks above:
>
>* Works fine - changes the edit control portion of the combobox to 'Local
>Disk (C:)' in my experiments, from a subfolder of C:
>
>
>** Does nothing whatsoever
>
>CB_FINDSTRING and CB_SELECTSTRING work fine for this combobox. However, with
>the FileName combobox, CB_GETCOUNT returns the right number of items, but
>neither CB_SELECTSTRING nor CB_FINDSTRING works.
>

-Tom
MVP - Visual Basic
(please post replies to the newsgroup)



Relevant Pages

  • Re: Status Bar Question
    ... Public Const WS_CHILD = &H40000000 ... Public Declare Function InvalidateRect Lib "user32" (ByVal hWnd As Long, ...
    (microsoft.public.vb.general.discussion)
  • Re: Printing image control
    ... Public Declare Function StartDoc Lib "gdi32" Alias _ ... Public Const LF_FACESIZE = 32 ...
    (comp.lang.basic.visual.misc)
  • Re: Printer Scale Settings
    ... Public Declare Function StartDoc Lib "gdi32" Alias _ ... Public Const LF_FACESIZE = 32 ...
    (microsoft.public.vb.general.discussion)
  • Re: VB5 Printing
    ... Public Declare Function StartDoc Lib "gdi32" Alias _ ... Public Const LF_FACESIZE = 32 ...
    (microsoft.public.vb.general.discussion)
  • Re: Printer Scale Settings
    ... Public Declare Function StartDoc Lib "gdi32" Alias _ ... Public Const LF_FACESIZE = 32 ...
    (microsoft.public.vb.general.discussion)