Windows API Guide: SECOND_IPADDRESS Macro


Declare Function SetProp Lib "user32.dll" Alias "SetPropA" (ByVal hWnd As Long, ByVal lpString As String, ByVal hData As Long) As Long

Platforms

  • Windows 95: Supported.
  • Windows 98: Supported.
  • Windows NT: Requires Windows NT 3.1 or later.
  • Windows 2000: Supported.
  • Windows CE: Not Supported.

Description & Usage

SetProp sets the value of one of the window properties of a window. If the window property does not already exist, this function will also create it. If the window property already exists, this function merely changes its value. Any window properties which your program creates must eventually be removed via the RemoveProp function.

Return Value

If an error occured, the function returns 0 (use GetLastError to get the error code). If successful, the function returns a non-zero value.

Visual Basic-Specific Issues

None.

Parameters

hWnd
A handle to the window to set a window property of.
lpString
The name of the window property to set.
hData
A handle to the data to set as the window property. This handle can refer to anything you wish.

Example

' This code is licensed according to the terms and conditions listed here. ' Set the "LookupFile" property of window Form1 to a string. ' This example also shows how to remove the property. Dim hStr As Long, pStr As Long  ' handle and pointer to the string Dim thevalue As String  ' the string referenced by the handle Dim retval As Long  ' return value ' Set the value of the string (this could be anything, really). thevalue = "C:\Icons\default.ico" ' Create a memory block... hStr = GlobalAlloc(GMEM_MOVEABLE Or GMEM_ZEROINIT, Len(thevalue)) ' ...and copy the string into it. pStr = GlobalLock(hStr)  ' get a pointer to the block retval = lstrcpy(pStr, text)  ' copy the string retval = GlobalUnlock(hStr)  ' release the pointer ' The handle hStr now refers to a memory block holding the string.  Set ' the "LookupFile" property to this memory block. retval = SetProp(Form1.hWnd, "LookupFile", hStr) ' Note how we cannot yet free the memory block since it is still in use. ' *** INSERT OTHER CODE (such as the GetProp example) HERE *** ' The following code releases the "LookupFile" property and frees ' the memory block to which it points. ' (this code assumes the same Dims as above) hStr = RemoveProp(Form1.hWnd, "LookupFile") ' The property is gone; now free the memory block. retval = GlobalFree(hStr)

See Also

GetProp, RemoveProp

Category

Window Properties

Go back to the alphabetical Function listing.
Go back to the Reference section index.


Last Modified: December 23, 1999
This page is copyright © 1999 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/s/setprop.html



Windows API Guide
Windows API Guide - Reference - Volume 1: Version 3.0 For the MS-DOS and PC-DOS Operating Systems
ISBN: B001V0KQIY
EAN: N/A
Year: 1998
Pages: 610

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net