When a window is destroyed, it must destroy any window properties it set. The following example uses the EnumPropsEx function and the application-defined callback function DelPropProc to destroy the properties associated with the window identified by the application-defined hwndSubclass variable. The callback function, which uses the RemoveProp function, is also shown.
case WM_DESTROY:
EnumPropsEx(hwndSubclass, DelPropProc, NULL);
PostQuitMessage(0);
break;
// DelPropProc is an application-defined callback function
// that deletes a window property.
BOOL CALLBACK DelPropProc(
HWND hwndSubclass, // handle of window with property
LPCSTR lpszString, // property string or atom
HANDLE hData) // data handle
{
RemoveProp(hwndSubclass, lpszString);
return TRUE;
}