Adding a Window Property (Windows Embedded CE 6.0)
1/6/2010
To assign a window property and a string identifier associated with that property to a window, call the SetProp function.
The following code example shows how to load an icon and a cursor and then allocate memory for a buffer. The example then uses the SetProp function to assign the resulting icon, cursor, and memory handles as window properties for the window identified by the application-defined hwndSubclass variable. The application uses the strings PROP_ICON, PROP_CURSOR, and PROP_BUFFER to identify the window properties.
#define BUFFER 4096
HINSTANCE hinst; // Handle to current instance
HWND hwndSubclass; // Handle to a subclassed window
HANDLE hIcon, hCursor;
TCHAR *lpMem;
TCHAR tchPath[] = TEXT("\\samples\\winprop.c");
// Load resources.
hIcon = LoadIcon(hinst, MAKEINTRESOURCE(400));
hCursor = LoadCursor(hinst, MAKEINTRESOURCE(220));
// Allocate and fill a memory buffer.
lpMem = (TCHAR*) LocalAlloc(LMEM_ZEROINT, BUFFER);
if (lpMem)
{
lstrcpy(lpMem, tchPath);
// Set the window properties for hwndSubclass.
SetProp(hwndSubclass, TEXT("PROP_ICON"), hIcon);
SetProp(hwndSubclass, TEXT("PROP_CURSOR"), hCursor);
SetProp(hwndSubclass, TEXT("PROP_BUFFER"), lpMem);
}
else
{
// Appropriate error handling code
}