About Window Properties
A window property is any data assigned to a window. A window property is usually a handle of the window-specific data, but it may be any value. Each window property is identified by a string name. There are several functions that enable applications to use window properties. This overview discusses the following topics:
Advantages of Using Window Properties
Window properties are typically used to associate data with a subclassed window or a window in a multiple-document interface (MDI) application. In either case, it is not convenient to use the extra bytes specified in the CreateWindow function or class structure for the following two reasons:
- An application might not know how many extra bytes are available or how the space is being used. By using window properties, the application can associate data with a window without accessing the extra bytes.
- An application must access the extra bytes by using offsets. However, window properties are accessed by their string identifiers, not by offsets.
Assigning Window Properties
The SetProp function assigns a window property and its string identifier to a window. The GetProp function retrieves the window property identified by the specified string. The RemoveProp function destroys the association between a window and a window property but does not destroy the data itself. To destroy the data itself, use the appropriate function to free the handle that is returned by RemoveProp.
Enumerating Window Properties