Mega Code Archive

 
Categories / Delphi / Forms
 

Controling the maximun possible size of a window

Title: Controling the maximun possible size of a window Question: This code controls the maximun possible size of a form. Answer: //--------------------------------------------------------------------------- // Author : Digital Survivor [Esteban Rodrguez Nieto | Jos Plano] // Email : plmad666@gmail.com | jose.plano@gmail.com // Web site : www.ds-studios.com.ar //--------------------------------------------------------------------------- { This unit defines a new Constructor for a window, declaring new properties that controls the size of the window } Unit Maxform; Interface Uses SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls, Forms, Dialogs; Type TMaxForm = Class (TForm) Private Fmh, Fmw, Fml, Fmt : Word; Procedure MyMax (Var M: TWMGETMINMAXINFO); Message WM_GETMINMAXINFO; Published Property MaxHeight : Word Read mh Write mh; Property MaxWidth : Word Read mw Write mw; Property MaxLeft : Word Read ml Write ml; Property MaxTop : Word Read mt Write mt; Constructor create (AOwner : TComponent); Override; End; Implementation Procedure TMaxForm.MyMax (Var M : TWMGETMINMAXINFO); Begin M.MinMaxInfo^.PtMaxSize.X := Fmw; M.MinMaxInfo^.PtMaxSize.Y := Fmh; M.MinMaxInfo^.PtMaxPosition.X := Fml; M.MinMaxInfo^.PtMaxPosition.Y := Fmt; End; constructor TMaxForm.create (Aowner : TComponent); Begin Fmw := Screen.Width; Fmh := Screen.Height; Fmt := 0; Fml := 0; Inherited Create (Aowner); End; End.