7,789
社区成员
发帖
与我相关
我的任务
分享

Chen8013
记得以前写的是“列举属性”,编译成 .exe后不能运行。不知道会不会跟操作系统有关。

Option Explicit
Private objApp As Object
Private objTI As Object
Private Sub EnumVBObjectEvents(ClassName As String)
Dim cci As Object
Dim mi As Object
Dim i As Long
For Each cci In objTI.CoClasses
If (ClassName = cci.Name) Then
For i = 1 To cci.Interfaces(2).Members.Count
Set mi = cci.Interfaces(2).Members(i)
List2.AddItem mi.Name
Set mi = Nothing
Next
End If
Next
End Sub
Private Sub EnumControls()
Dim cci As Object
For Each cci In objTI.CoClasses
If (2 = cci.Interfaces.Count) Then
If (cci.Interfaces(2).Members.Count) Then List1.AddItem cci.Name
End If
Next
Set cci = Nothing
End Sub
Private Sub cmdDispEvents_Click()
List2.Clear
Call EnumVBObjectEvents(List1.Text)
End Sub
Private Sub Form_Load()
List1.Clear
Set objApp = CreateObject("TLI.TLIApplication")
Set objTI = objApp.TypeLibInfoFromRegistry( _
"{FCFB3D2E-A0FA-1068-A738-08002B3371B5}", 6, 0, 9)
Call EnumControls
List1.Selected(0) = True ' 先把第1个选上再说
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set objTI = Nothing
Set objApp = Nothing
End Sub

1187: interface TextBoxEvents : IUnknown {
1188: [helpstring("Occurs when the contents of a control have changed."), helpcontext(0x000dfb4d)]
1189: HRESULT _stdcall Change();
1190: [helpstring("Occurs when a drag-and-drop operation is completed."), helpcontext(0x000dfb50)]
1191: HRESULT _stdcall DragDrop(
1192: [in, out] Control** Source,
1193: [in, out] single* X,
1194: [in, out] single* Y);
1195: [helpstring("Occurs when a drag-and-drop operation is in progress."), helpcontext(0x000dfb51)]
1196: HRESULT _stdcall DragOver(
1197: [in, out] Control** Source,
1198: [in, out] single* X,
1199: [in, out] single* Y,
1200: [in, out] short* State);
1201: [helpstring("Occurs when an object receives the focus."), helpcontext(0x000dfb53)]
1202: HRESULT _stdcall GotFocus();
1203: [helpstring("Occurs when the user presses a key while an object has the focus."), helpcontext(0x000dfb55)]
1204: HRESULT _stdcall KeyDown(
1205: [in, out] short* KeyCode,
1206: [in, out] short* Shift);
1207: [helpstring("Occurs when the user presses and releases an ANSI key."), helpcontext(0x000dfb56)]
1208: HRESULT _stdcall KeyPress([in, out] short* KeyAscii);
1209: [helpstring("Occurs when the user releases a key while an object has the focus."), helpcontext(0x000dfb57)]
1210: HRESULT _stdcall KeyUp(
1211: [in, out] short* KeyCode,
1212: [in, out] short* Shift);
1213: [helpstring("Occurs when a DDE conversation terminates."), helpcontext(0x000dfb58)]
1214: HRESULT _stdcall LinkClose();
1215: [helpstring("Occurs when there is an error during a DDE conversation."), helpcontext(0x000dfb59)]
1216: HRESULT _stdcall LinkError([in, out] short* LinkErr);
1217: [helpstring("Occurs when a DDE conversation is being initiated."), helpcontext(0x000dfb5c)]
1218: HRESULT _stdcall LinkOpen([in, out] short* Cancel);
1219: [helpstring("Occurs when an object loses the focus."), helpcontext(0x000dfb5e)]
1220: HRESULT _stdcall LostFocus();
1221: [helpstring("Occurs when the source has changed the DDE data if the LinkMode property of the destination control is Notify."), helpcontext(0x000dfb5b)]
1222: HRESULT _stdcall LinkNotify();
1223: [helpstring("Occurs when the user presses the mouse button while an object has the focus."), helpcontext(0x000dfb5f)]
1224: HRESULT _stdcall MouseDown(
1225: [in, out] short* Button,
1226: [in, out] short* Shift,
1227: [in, out] single* X,
1228: [in, out] single* Y);
1229: [helpstring("Occurs when the user moves the mouse."), helpcontext(0x000dfb60)]
1230: HRESULT _stdcall MouseMove(
1231: [in, out] short* Button,
1232: [in, out] short* Shift,
1233: [in, out] single* X,
1234: [in, out] single* Y);
1235: [helpstring("Occurs when the user releases the mouse button while an object has the focus."), helpcontext(0x000dfb61)]
1236: HRESULT _stdcall MouseUp(
1237: [in, out] short* Button,
1238: [in, out] short* Shift,
1239: [in, out] single* X,
1240: [in, out] single* Y);
1241: [helpstring("Occurs when the user presses and then releases a mouse button over an object."), helpcontext(0x000dfb4e)]
1242: HRESULT _stdcall Click();
1243: [helpstring("Occurs when the user presses and releases a mouse button and then presses and releases it again over an object."), helpcontext(0x000dfb4f)]
1244: HRESULT _stdcall DblClick();
1245: [helpstring("Occurs when the mouse is moved over the control during an OLE drag/drop operation, if its OLEDropMode property is set to manual."), helpcontext(0x000dfb76)]
1246: HRESULT _stdcall OLEDragOver(
1247: [in, out] DataObject** Data,
1248: [in, out] long* Effect,
1249: [in, out] short* Button,
1250: [in, out] short* Shift,
1251: [in, out] single* X,
1252: [in, out] single* Y,
1253: [in, out] short* State);
1254: [helpstring("Occurs when data is dropped onto the control via an OLE drag/drop operation, and OLEDropMode is set to manual."), helpcontext(0x000dfb77)]
1255: HRESULT _stdcall OLEDragDrop(
1256: [in, out] DataObject** Data,
1257: [in, out] long* Effect,
1258: [in, out] short* Button,
1259: [in, out] short* Shift,
1260: [in, out] single* X,
1261: [in, out] single* Y);
1262: [helpstring("Occurs at the source control of an OLE drag/drop operation when the mouse cursor needs to be changed."), helpcontext(0x000dfb78)]
1263: HRESULT _stdcall OLEGiveFeedback(
1264: [in, out] long* Effect,
1265: [in, out] VARIANT_BOOL* DefaultCursors);
1266: [helpstring("Occurs when an OLE drag/drop operation is initiated either manually or automatically."), helpcontext(0x000dfb79)]
1267: HRESULT _stdcall OLEStartDrag(
1268: [in, out] DataObject** Data,
1269: [in, out] long* AllowedEffects);
1270: [helpstring("Occurs at the OLE drag/drop source control when the drop target requests data that was not provided to the DataObject during the OLEDragStart event."), helpcontext(0x000dfb7a)]
1271: HRESULT _stdcall OLESetData(
1272: [in, out] DataObject** Data,
1273: [in, out] short* DataFormat);
1274: [helpstring("Occurs at the OLE drag/drop source control after a manual or automatic drag/drop has been completed or canceled."), helpcontext(0x000dfb7b)]
1275: HRESULT _stdcall OLECompleteDrag([in, out] long* Effect);
1276: [helpstring("Occurs when a control loses focus to a control that causes validation."), helpcontext(0x000dfb87)]
1277: HRESULT _stdcall Validate([in, out] VARIANT_BOOL* Cancel);
1278: };
