Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleUse the SetProp, GetProp, and RemoveProp API functions to associate a value with a window handle (hWnd)
DescriptionThis example shows how to use the SetProp, GetProp, and RemoveProp API functions to associate a value with a window handle (hWnd) in Visual Basic 6.
KeywordsSetProp, GetProp, RemoveProp, hWnd
CategoriesAPI
 
The SetProp API function associates a Long value with a named property for a window handle (hWnd).

When you enter a property name and a value and click the Set Property button, the following code associates the value with the name for the form's window handle.

 
Private Sub cmdSetProperty_Click()
    SetProp Me.hWnd, txtName.Text, CLng(txtValue.Text)
    txtValue.Text = ""
End Sub
 
When you enter a property name and click the Get Property button, the following code gets and displays the property's value associated with the form.
 
Private Sub cmdGetProperty_Click()
Dim property_value As Long

    property_value = GetProp(Me.hWnd, txtName.Text)
    txtValue.Text = property_value
End Sub
 
When you enter a property name and click Remove Property, the program uses the following code to remove the property. If you later click the Get Property button, GetProp returns 0 for the non-existent property.
 
Private Sub cmdRemoveProperty_Click()
    RemoveProp Me.hWnd, txtName.Text
    MsgBox "Done"
End Sub
 
 
Copyright © 1997-2006 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated