I've been playing with Typelib Information (TBLINF32.DLL) to enumerate the Properties of all the Controls on a Form and determine whether specific ones are Read only.
Basic code is
where pObject is the Control in questionCode:Dim TypeLib As TLI.InterfaceInfo Dim Prop As TLI.MemberInfo Debug.Print pObject.Name Set TypeLib = TLI.InterfaceInfoFromObject(pObject) For Each Prop In TypeLib.Members Debug.Print , Prop.Name & " " & Prop.InvokeKind Next
The output from a ComboBox looks something like this
From what I curently understand, a Prop.InvokeKind of 2 (INVOKE_PROPERTYGET) means it's a Readable property and a Prop.InvokeKind of 4 (INVOKE_PROPERTYPUT) means it's Writeable.Code:Combo1 _DEFAULT 2 _DEFAULT 4 NAME 2 STYLE 2 INDEX 2 BACKCOLOR 2 BACKCOLOR 4 FORECOLOR 2 FORECOLOR 4 LEFT 2 LEFT 4 TOP 2 TOP 4 WIDTH 2 WIDTH 4 HEIGHT 2 HEIGHT 4 ENABLED 2 ENABLED 4 VISIBLE 2 VISIBLE 4 MOUSEPOINTER 2 MOUSEPOINTER 4 TEXT 2 TEXT 4 FONTNAME 2 FONTNAME 4 FONTBOLD 2 FONTBOLD 4 FONTITALIC 2 FONTITALIC 4 FONTSTRIKETHRU 2 FONTSTRIKETHRU 4 FONTUNDERLINE 2 FONTUNDERLINE 4 FONTSIZE 2 FONTSIZE 4 TABINDEX 2 TABINDEX 4 LISTCOUNT 2 LISTINDEX 2 LISTINDEX 4 LIST 2 LIST 4 SORTED 2 SELSTART 2 SELSTART 4 SELLENGTH 2 SELLENGTH 4 SELTEXT 2 SELTEXT 4 PARENT 2 DRAGMODE 2 DRAGMODE 4 DRAGICON 2 DRAGICON 4 DRAGICON 8 TABSTOP 2 TABSTOP 4 TAG 2 TAG 4 HWND 2 ITEMDATA 2 ITEMDATA 4 NEWINDEX 2 HELPCONTEXTID 2 HELPCONTEXTID 4 MOUSEICON 2 MOUSEICON 4 MOUSEICON 8 FONT 2 FONT 8 DATAFIELD 2 DATAFIELD 4 DATACHANGED 2 DATACHANGED 4 WHATSTHISHELPID 2 WHATSTHISHELPID 4 APPEARANCE 2 APPEARANCE 4 CONTAINER 2 CONTAINER 8 INTEGRALHEIGHT 2 RIGHTTOLEFT 2 RIGHTTOLEFT 4 TOOLTIPTEXT 2 TOOLTIPTEXT 4 OLEDRAGMODE 2 OLEDRAGMODE 4 OLEDROPMODE 2 OLEDROPMODE 4 LOCKED 2 LOCKED 4 TOPINDEX 2 TOPINDEX 4 CAUSESVALIDATION 2 CAUSESVALIDATION 4 DATAMEMBER 2 DATAMEMBER 4 DATAFORMAT 2 DATAFORMAT 8 DATASOURCE 2 DATASOURCE 8 CLEAR 1 ADDITEM 1 REMOVEITEM 1 SETFOCUS 1 REFRESH 1 ZORDER 1 DRAG 1 MOVE 1 SHOWWHATSTHIS 1 OLEDRAG 1
The issue is that, for example, the 'Height' property of a ComboBox is read only, yet the results above suggest it's Read/ Write. If you note, the ListIndex Property does not have a Prop.InvokeKind of INVOKE_PROPERTYPUT which is what I would expect.
Am I missing something or is there a 'better' way to achieve the objective? (apart from attempting to assign a value to the Property and using in-line Error Handling to trap errors)
BTW The overall objective is to attempt to build a 'generic' Form Resize Class / Module (yes,I know it's been done a thousand times before, but I've never done it- this is an exercise for me rather than anything 'useful') and in order to do so it's required to be able to identify whether a particular Property exists (e.g.Height) and whether it's writable.




Reply With Quote