Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Stumbled upon this interesting code and wonder if anybody knows any good use
for this. This example needs a userform with a treeview on it, but you can do the same with any other control. The interesting bit is that it allows you to store controls and forms as simple Long variables in arrays or collections. The example I saw used the SetTimer API, but it looks this is not needed: http://www.mvps.org/vbvision/_sample...nters_Demo.zip Option Explicit Private Declare Sub CopyMemory Lib "kernel32" _ Alias "RtlMoveMemory" (lpDest As Any, _ lpSource As Any, _ ByVal lBytes As Long) Sub test() Dim lObjPtr As Long With UserForm1.TreeView1.Nodes .Clear .Add , , "key1", "top node" .Add "key1", tvwChild, "key2", "child node" End With lObjPtr = ObjPtr(UserForm1.TreeView1.Nodes(2)) 'to demonstrate that we have a fully qualified object reference here '------------------------------------------------------------------- MsgBox ObjectFromObjectPointer(lObjPtr).Parent.Child.Text End Sub Private Function ObjectFromObjectPointer(ByVal lObjectPointer As Long) As Object Dim lpObject As Object 'use the CopyMemory API to copy the 'long pointer into the object variable '------------------------------------- CopyMemory lpObject, lObjectPointer, 4& Set ObjectFromObjectPointer = lpObject CopyMemory lpObject, 0&, 4& End Function RBS |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Is there a way to use Formula to resolve | Excel Worksheet Functions | |||
#REF! Error Resolve? | Excel Worksheet Functions | |||
Did you ever resolve this? | Excel Discussion (Misc queries) | |||
how to resolve a printer name | Excel Programming | |||
Another issue to resolve | Excel Programming |