» Help

How to minimize the controls in a form

   

This more than a trick... it is a curiosity.

All the Delphi controls derived from TWinControl are no more than windows. Keeping this in mind what happens if for example, we minimize a TMemo or a TButton?

Test it and you will see. Put a TMemo and a TButton on your form. Then put this code in the OnClick event handler of the TButton:

procedure TForm1.Button3Click(Sender: TObject);
begin 
  CloseWindow(Memo1.Handle);
end; 

Here is how to minimize a control on your form at given X,Y coordinates:

procedure MinimizaEn(Que:THandle;X,Y:integer);
var 
  Posiciones: TWindowPlacement;
begin 
  Posiciones.length := SizeOf(Posiciones);
  GetWindowPlacement(Que,@Posiciones);
  Posiciones.flags := WPF_SETMINPOSITION;
  Posiciones.ptMinPosition.x := X;
  Posiciones.ptMinPosition.y := Y;
  SetWindowPlacement(Que,@Posiciones);
  CloseWindow(Que);
end;
Author: Unknown
Contributor: geotech
Added: 2010-12-17
Last updated: 2010-12-17

« Return to contents »