Listing Window Properties for a Given Window

In the following example, the EnumPropsEx function lists the string identifiers of the window properties for the window identified by the application-defined hwndSubclass variable. This function relies on the application-defined callback function WinPropProc to display the strings in the window's client area.

EnumPropsEx(hwndSubclass, WinPropProc, NULL);

// WinPropProc is an application-defined callback function

// that lists a window property.

BOOL CALLBACK WinPropProc(

HWND hwndSubclass, // handle of window with property

LPCSTR lpszString, // property string or atom

HANDLE hData) // data handle

{

static int nProp = 1; // property counter

TCHAR tchBuffer[BUFFER]; // expanded-string buffer

int nSize; // size of string in buffer

HDC hdc; // device-context handle

hdc = GetDC(hwndSubclass);

// Display window property string in client area.

nSize = sprintf(tchBuffer, "WinProp %d: %s", nProp++,

lpszString);

TextOut(hdc, 10, nProp * 20, tchBuffer, nSize);

ReleaseDC(hwndSubclass, hdc);

return TRUE;

}