LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Resolve object pointer any use for this?

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to use Formula to resolve Sky Excel Worksheet Functions 5 May 7th 09 01:07 AM
#REF! Error Resolve? Dan the Man[_2_] Excel Worksheet Functions 2 July 30th 07 03:28 AM
Did you ever resolve this? [email protected] Excel Discussion (Misc queries) 1 April 24th 07 02:34 PM
how to resolve a printer name Bert van den Brink Excel Programming 1 July 30th 06 10:39 AM
Another issue to resolve Pat Excel Programming 11 February 20th 05 09:01 PM


All times are GMT +1. The time now is 08:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"