Click to See Complete Forum and Search --> : Active control creation


sys_logics
March 30th, 2001, 12:00 AM
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...

Clearcode
March 30th, 2001, 02:12 AM
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