Visit our Sponsor   Visit our Sponsor
delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback



Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi








Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (1)


A way to ensure your elements appear just like you want them toComponent available for this articleFormat this article printer-friendly!Bookmark function is only available for registered users!
THellConstraints
Product:
Delphi 7.x (or higher)
Category:
Component Writing
Skill Level:
Scoring:
Last Update:
12/05/2008
Search Keys:
delphi delphi3000 article borland vcl code-snippet form enhancement constraint component
Times Scored:
2
Visits:
1806
Uploader: Frank de Hell
Company:
Reference: http://www.superliegebeest.nl/delphi.php
Component Download: http://www.superliegebeest.nl/d7/thc.zip
 
Question/Problem/Abstract:
A way to ensure your elements appear just like you want them to! Automatically constrains forms at runtime, at the size used in designtime! You could say this one enables constraints at default, but WITH the ability to change it in designtime any way you like. Normally, setting constraints to any maxwidth etc, will not allow you to change your mind after that, unless you change the maxwidth etc again. This one lets you change it to any size you want in designtime, while keeping the constraints enabled! It is set to Active:= True by default, which, enables the component but can be set to Active:= False which disables it.
Answer:



THellConstraints

Automatically constrains forms at runtime, at the size used in designtime! You could say this one enables constraints at default, but WITH the ability to change it in designtime any way you like. Normally, setting constraints to any maxwidth etc, will not allow you to change your mind after that, unless you change the maxwidth etc again. This one lets you change it to any size you want in designtime, while keeping the constraints enabled! It is set to Active:= True by default, which, enables the component but can be set to Active:= False which disables it.




HellConstraints.pas
{*******************************************************}
{       HellConstraints.pas                             }
{       HellConstraints                                 }
{       12-8-2006 19:25:26                              }
{       Copyright (C) 2006 Fdehell                      }
{       65                                              }
{*******************************************************}
//Open up THellConstraints7.dpk, after you have extracted all the files to your
//Lib directory, click compile and install, that is it!
unit HellConstraints;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,StdCtrls,
  Menus, ExtCtrls;

type
  THellconst = class(TComponent)
  private
    FActive :Boolean;
    FOwner:TComponent;
    procedure SetConstraints(Sender: TObject);
  protected
     procedure Loaded; override;
  public
     constructor Create(AOwner: TComponent); override;
  published
    property Active: boolean read FActive write FActive;
  end;

procedure Register;

implementation
{$R thellconstraints.dcr}

procedure Register;
begin
  RegisterComponents('Fdehell', [THellconst]);
end;

constructor THellconst.Create(AOwner: TComponent);
begin
   inherited Create(AOwner);
   FActive := True;
   if (AOwner is TForm) then
        FOwner := AOwner;
end;

procedure THellconst.Loaded ;
begin
     Inherited Loaded ;
     if not ( csDesigning in ComponentState ) then begin
        if Assigned(FOwner) then
              SetConstraints(FOwner);
   end;
end;



procedure THellconst.SetConstraints(Sender: TObject);
begin
  if FActive then
      with (Sender as TForm).Constraints do begin
      MaxWidth := (Sender as TForm).Width;
      MaxHeight := (Sender as TForm).Height;
      MinWidth := (Sender as TForm).Width;
      MinHeight := (Sender as TForm).Height;
    end;
end;

end.
{*******************************************************}


HellConstraints7.dpk  
{*******************************************************}
{       HellConstraints7.dpk                            }
{       HellConstraints                                 }
{       12-8-2006 19:25:26                              }
{       Copyright (C) 2006 Fdehell                      }
{       65                                              }
{*******************************************************}

package HellConstraints7;

{$R *.res}
{$ALIGN 8}
{$ASSERTIONS ON}
{$BOOLEVAL OFF}
{$DEBUGINFO ON}
{$EXTENDEDSYNTAX ON}
{$IMPORTEDDATA ON}
{$IOCHECKS ON}
{$LOCALSYMBOLS ON}
{$LONGSTRINGS ON}
{$OPENSTRINGS ON}
{$OPTIMIZATION ON}
{$OVERFLOWCHECKS OFF}
{$RANGECHECKS OFF}
{$REFERENCEINFO ON}
{$SAFEDIVIDE OFF}
{$STACKFRAMES OFF}
{$TYPEDADDRESS OFF}
{$VARSTRINGCHECKS ON}
{$WRITEABLECONST OFF}
{$MINENUMSIZE 1}
{$IMAGEBASE $400000}
{$DESCRIPTION 'Automatically constraints the form at runtime, to the size set at designtime'}
{$LIBSUFFIX '7'}
{$IMPLICITBUILD OFF}

requires
  rtl,
  vcl;

contains
  HellConstraints in 'HellConstraints.pas';

end.
{*******************************************************}






Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment
Admins help needed
    Nullified van Bommel (Jul 28 2010 5:14PM)

My previous site has been shut down please use the following link for download:
http://www.delphi7.nl/download.php?file=thc&typefile=components

And the following for sourcecode:
http://www.delphi7.nl/sourcecode/components/hellconstraints.php
Respond














 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
E. Irigoyen
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)