CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2001
    Posts
    8

    Active control creation

    I'm developing an activex control for which i need combo box. I could inherit all properties except readonly properties like 'style', 'sorted'. I'm unable to set these properties for combo box in my control as these are readonly at runtime. and I desperetely need these properties. can anybody help me tackle this problem...


  2. #2
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: Active control creation

    You can do this with Windows Messages and Class Bits

    For example, to set and unset the sorted property...

    private Const LBS_SORTED = 100
    private Const GWL_STYLE = (-16)

    '\\ Window specific information
    private Declare Function GetWindowLongApi Lib "user32" Alias "GetWindowLongA" (byval hwnd as Long, byval nIndex as Long) as Long
    private Declare Function SetWindowLongApi Lib "user32" Alias "SetWindowLongA" (byval hwnd as Long, byval nIndex as Long, byval dwNewLong as Long) as Long

    '\\ Now use this in the property....
    public property get Sorted() as Boolean

    Dim lRet as Long

    lRet = GetWindowLongApi(combo.hwnd,GW_STYLE)

    Sorted = (lRet AND LBS_SORT)

    End property

    public property let Sorted(byval NewSort as Boolean)

    lRet = GetWindowLong(combo.hWnd, GW_STYLE)
    If me.Sorted <> NewSort then
    If NewSort then
    lRet = lRet + LBS_SORT
    else
    lRet = lRet - LBS_SORT
    End If
    lRet = SetWindowLong(combo.hwnd,GW_STYLE, lREt)
    End If
    End property




    You will probably have to refresh your control after calling this, as it is not reflected immediately.

    HTH,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured