Re: [Controls] ComboBoxEx

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: ALESSANDRO Baraldi (ik2zok_at_libero.it)
Date: 09/05/04


Date: Sun, 5 Sep 2004 16:39:42 +0200


"MikeD" <nobody@nowhere.edu> ha scritto nel messaggio
news:e4HwWA1kEHA.3968@TK2MSFTNGP11.phx.gbl...
>
> "ALESSANDRO Baraldi" <ik2zok@libero.it> wrote in message
> news:chepvv$63o$1@lacerta.tiscalinet.it...
> > Good Sunday to NG.
> >
> > I built a ComboboxEx with COMCTL32.
> > It's a good way to use this controls....!
>
> Why not use the ImageCombo from the Windows Common Controls OCX? The
> ImageCombo is a wrapper for the ComboBoxEx control.
>
> > But how can use GETITEM
> >
> > Dim cbexi As COMBOBOXEXITEM
> > cbexi.iItem=Index
> > SendMessage(m_hWnd, CBEM_GETITEM, 0, ucbexi)
> >
> > Now i also try to prepare the Buffer for this :
> > pszText As Long '// LPCSTR
> > cchTextMax As Long
> >
> > No good return at all.....!
>
>
> Your code is rather incomplete, so I'm a little unsure how you're
attempting
> to do this. One thing I do see is that your UDT variable is named cbexi
but
> you're passing ucbexi. This is probably just a typo since there are other
> typos in your code (copy and paste your exact code, don't retype it into
> your post). You're also not showing where (or even if) you're specifying
> anything for the mask member of this structure prior to sending the
message.
>
> Post your complete routine, not bits and pieces of it (and remember, copy
> and paste it). Also, be sure to include declarations for API functions,
> structures, and constants....just to make sure those are declared
correctly.
> But as I said first off, you should probably just use the ImageCombo
> control. It'd be a LOT easier. The downside is you've got an OCX to
> distribute (but if you're already using ListViews, TreeViews, or any other
> controls from this OCX, there's no point in not using the ImageCombo).
>
> Mike

Hi Mike.
First Tanks for your replay.

I don't use OCX, there is no reason, it's only my choice...!
I don't use List/Tree or other OCX type, all by Dll Wrapper.
the mistache ucbexi/cbexi is made on Past
part of code like you understand).....!

On SubClass Form Event i itercept 2 Message, the SuBclass system
it's of Klaus H. Probst(VbBox) and similar to VbAccelerator
also Class Wrapper come from VbBox, the difference is that i
use this on VBA[Access_Vers_2002].

Reading MSDN i understand that the most important Notify message
is CBEN_GETDISPINFO, and here i have to tranfert lParam to
NMCOMBOBOXEX structure....!
The problem is that this Notify is not tested....!!!!!!!

Sorry for Long Code... and for bat English to.

Thanks again for your attention.

Alessandro(IT)

Explain:

'///------------------------------START
CODE---------------------------------///

On My Form i add Implemets IMessageTarget class

Private Function IMessageTarget_Message(ByVal id As Long, ByVal hWnd As
Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

   Dim hdr As NMHDR

    Select Case msg
      Case WM_NOTIFY '

            CopyMemory hdr, ByVal lParam, Len(hdr)

            Select Case hdr.hwndFrom
                '// This is my ComboboxEx Handle
                Case m_cbe.hWnd
                    IMessageTarget_Message = OnCBENotify(wParam, lParam)

                Case Else
                    IMessageTarget_Message = Delegate(id)

            End Select

      Case WM_COMMAND
            Select Case lParam
                '// This is my ComboboxEx Handle
                Case m_cbe.hWnd
                    IMessageTarget_Message = OnCBECommand(wParam, lParam)

                Case Else
                    IMessageTarget_Message = Delegate(id)
            End Select
         Case Else
            IMessageTarget_Message = Delegate(id)

    End Select

End Function

Private Function OnCBENotify(wParam As Long, lParam As Long) As Long
   Dim nmCbex As NMCOMBOBOXEX

   CopyMemory nmCbex, ByVal lParam, Len(nmCbex)

   '// This is only to Check message
   '// I don't Know how extract ComboData

   Select Case nmCbex.hdr.Code

      Case CBEN_BEGINEDIT
            Me.lblNotify.Caption = "CBEN_BEGINEDIT "

      Case CBEN_DELETEITEM
            Me.lblNotify.Caption = "CBEN_DELETEITEM"

      Case CBEN_INSERTITEM
            Me.lblNotify.Caption = "CBEN_INSERTITEM"

      Case CBEN_ENDEDIT
            Me.lblNotify.Caption = "CBEN_ENDEDIT"

      Case CBEN_GETDISPINFO
            Me.lblNotify.Caption = "CBEN_GETDISPINFO"

   End Select
   OnCBENotify = 0

End Function

Private Function OnCBECommand(wParam As Long, lParam As Long) As Long
   Dim ucbexi As COMBOBOXEXITEM
   Dim nmCbex As NMCOMBOBOXEX

CopyMemory nmCbex, ByVal lParam, Len(nmCbex)
   Select Case HIWORD(wParam)

      Case CBN_DBLCLK
         Me.lblNotify.Caption = "DBL_CLICK"

      Case CBN_DROPDOWN
         Me.lblCommand.Caption = "DROPDOWN"

      Case CBN_CLOSEUP
         Me.lblCommand.Caption = "CBN_CLOSEUP"

      Case CBN_SETFOCUS, CBN_KILLFOCUS
         Me.lblCommand.Caption = "CBN_SELCHANGE "

      Case CBN_SELCHANGE
            '// This extract only the Selection Index
             Me.lblCommand.Caption = "CBN_SELCHANGE -- " & _
            SendMessage(m_cbe.Hwnd, CB_GETCURSEL, 0, ByVal 0&)

      Case CBN_EDITCHANGE
         Me.lblCommand.Caption = "CBN_EDITCHANGE"

   End Select
OnCBECommand = 0
End Function
'///------------------------------END
CODE---------------------------------///



Relevant Pages

  • Re: [Controls] ComboBoxEx
    ... Why not use the ImageCombo from the Windows Common Controls OCX? ... ImageCombo is a wrapper for the ComboBoxEx control. ...
    (microsoft.public.vb.winapi)
  • Re: The bloated get bloatier
    ... I use my own customized version of the PDW ... My avoidance of controls is partly due to using ... The OCX really just uses a "wizard" to write the API ... If you want to use the Wise installer you could ...
    (microsoft.public.vb.general.discussion)
  • Re: The bloated get bloatier
    ... My avoidance of controls is partly due to using ... The OCX really just uses a "wizard" to write the API ... in the Redist folder with the next service pack. ... if you try to install a new system file it will get replaced. ...
    (microsoft.public.vb.general.discussion)
  • Re: Manifest file for an Ocx
    ... This doesn't appear to work for an OCX at least not in my context. ... So second question remains - how to make a User Control in an activeX ocx ... use xp style controls (triggering this from the OCX and not the app using ... recompile your EXE. ...
    (microsoft.public.vb.general.discussion)
  • Re: Resaving a DLL!
    ... Not sure what you mean by AXD Steve. ... ActiveX DLLs are OK, but an OCX ... It is Forms and Controls that are ...
    (microsoft.public.vb.general.discussion)