|
|
Title | Use the SetProp, GetProp, and RemoveProp API functions to associate a value with a window handle (hWnd) |
Description | This 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. |
Keywords | SetProp, GetProp, RemoveProp, hWnd |
Categories | API |
|
|
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
|
|
|
|
|
|