our callback function prototype}
function EnumWinProps(hWnd: HWND; pString: PChar; Data: THandle): BOOL; stdcall;
var
Form1: TForm1;
implementation
{these steps will be executed for each property
entry in the window's property list}
function EnumWinProps(hWnd: HWND; pString: PChar; Data: THandle): BOOL;
begin
{add the string and associated value to the list box}
Form1.ListBox1.Items.Add(Format('%s=%d',[pString,Data]));
{continue enumeration}
Result:=TRUE;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
{add a new property to the window's property list}
SetProp(Form1.Handle,PChar(Edit1.Text),StrToInt(Edit2.Text));
{clear the edit boxes}
Edit1.Text:='';
Edit2.Text:='';
{clear the list box}
Form1.ListBox1.Items.Clear;
{list all of the properties associated with the window}
EnumProps(Form1.Handle, @EnumWinProps);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
{clear the list box}
Form1.ListBox1.Items.Clear;
{list all of the properties associated with the window}
EnumProps(Form1.Handle, @EnumWinProps);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
{remove the selected property from the property list}
{list all of the properties associated with the window}
EnumProps(Form1.Handle, @EnumWinProps);
end;
procedure TForm1.Button4Click(Sender: TObject);
var
Data: THandle; // this stores the property entry data
begin
{get property entry data associated with the given string}
Data:=GetProp(Form1.Handle,PChar(Edit1.Text));
{if there was a property value returned...}
if (Data<>0) then
{...display it...}
Edit2.Text:=IntToStr(Data)
else
{...otherwise display an error message}
Edit2.Text:='No property found.';
end;