Retrieving a Window Property
9/9/2008
Para recuperar a propriedade janela identificada por um seqüência de caracteres especificado, chamar o GetProp função. Uma janela pode criar alças para os dados contidos em propriedades da janela janela e usar os dados para qualquer finalidade.
O seguinte exemplo de código mostra como usar GetProp Propriedades identificado para obter alças para a janela PROP_ICON, PROP_CURSOR e PROP_BUFFER pelas seqüências de caracteres. O exemplo, em seguida, exibe o conteúdo do reserva memória obtidos recentemente, cursor e ícone na área de cliente da janela.
HWND hwndSubclass; // Handle to a subclassed window
HANDLE hIconProp, hCursProp;
TCHAR *lpFilename;
TCHAR tchBuffer[MAX_PATH];
int nSize;
HDC hdc;
HRESULT hr;
// Get the window properties, then print the data.
hIconProp = (HICON) GetProp(hwndSubclass, TEXT("PROP_ICON"));
ExtTextOut(hdc, 10, 40, 0, NULL, TEXT("PROP_ICON"),
_tcslen(TEXT("PROP_ICON")), NULL);
DrawIcon(hdc, 90, 40, (HICON)hIconProp);
hCursProp = (HCURSOR) GetProp(hwndSubclass, TEXT("PROP_CURSOR"));
ExtTextOut(hdc, 10, 85, 0, NULL, TEXT("PROP_CURSOR"),
_tcslen(TEXT("PROP_CURSOR")), NULL);
DrawIcon(hdc, 110, 85, (HICON)hCursProp);
lpFilename = (TCHAR*) GetProp(hwndSubclass, TEXT("PROP_BUFFER"));
hr = StringCchPrintf(tchBuffer, MAX_PATH, TEXT("Path to file: %s"),
lpFilename);
ExtTextOut(hdc, 10, 10, 0, NULL, tchBuffer, nSize, NULL);