Unit GMSLabel

GMSStickyLabel v2 Feb/19/98 by Glenn Shukster & Jacques Scoatarin GMS COMPUTING INC. Phone (905)771-6458 53 COLVIN CRES. Fax -6819 THORNHILL, ONT. Compuserve: 72734,123 CANADA L4J 2N7 InternetId:Gms@Shaw.wave.ca http://members.tor.shaw.wave.ca/~gms/ Jacques Scoatarin Phone (357)2-492591 52 Athalassis Ave. (flat 202) Nicosia Cyprus InternetId:j.scoatarin@cytanet.com.cy Purpose: TLabel that will attach to any TWinControl Component on the form like TEdit, TDBMemo, TButton etc. There are other components out there that make a label part of the edit or memo etc. but they tie you too much to that other component. Features: 1) All abilities of TLabel still exist 2) Works with Delphi 1,2,3. 3) _AlignTo: The position it will align to the TWinControl (left, right, top, bottom) 4) _AttachTo: The TWincontrol this label will attach to. 5) _Gap: The space between the two components 6) _AlignPos: Further positions the label on the _AlignTo side (TopLeft, Center, BottomRight) 7) _AlignPosGap: The spaces from _AlignPos on the _AlignTo side 8) Right Click: Component editor option realigns all TGMSStickyLabels on the form(owner) to their _AttachTo components 9) Drop Label on any TWinControl and it asks to fill in _AttachTo with that component 10)Move TWinControl: the label will follow the _AttachTo component Known Problems: 1) Changing any property that affects the visual appearance of the TWinControl will call RecreateWnd. For example changing CharCase. Since the object is the same but the window handle is a new one, effectively there is no hook into the control's window procedure. Unfortunately there seems to be no way of re-subclassing. The last message we get in the AttachedTo window subclassed function is WM_DESTROY, thus one might try to at least un-assign FAttachTo. Under normal circumstance you could call a PostMessage upon receiving WM_DESTROY and check if the FAttachTo is still assigned (meaning RecreateWnd was called) however TLabel is not a proper window control and does not have a window handle. Thanks to tmliaw@pc.jaring.my for pointing this problem out, and Jacques Scoatarin for the above explanation Files: GMSLabel.pas : This component GMSLabCE.pas : Component editor for GMSLabel LblEdit.pas : old name for Component editor for GMSLabCE, delete LblEdit.pas file GMSLabel.dcr : In the 16 directory for Delphi 1 GMSLabel.dcr : In the 32 directory for Delphi 2 & 3 Installation: Copy the above pas files and the *.dcr file in the (16 Dir Delphi1) or (32 Dir Delphi 2 & 3) into one of the dirs in your component lib search path. Then install gmslabel.pas & lbledit.pas. Only GMSStickyLabel will appear on your component pallet under GMS. Copyright: This component is free if you keep this comment header. Any damage real or imagined caused by this component is 100% your responsibility not GMS Computing Inc.'s. Thank You This free component is my way of saying thank you to The Delphi Community. People have been more than helpful to me in the forums & newsgroups, especially team B members, Wayne Niddery, and Jacques Scoatarin. As an example of how great a community we have within a day of sending this component out Jacques Scoatarin basically added the lower level api calls to enable features 7 & 8 which make the component much more robust. Enjoy! If you like and use this component e-mail to let me know. P.S. GMS Computing Inc.(which is me) is always looking for new contracts. If you like what you see then contact me. See my web page for more details. VERSION INFO GMSStickyLabel v1.1 July/5/97 by Glenn Shukster & Jacques Scoatarin - Released on public. V 1.2 Aug/14/97 - Thanks to Erik B. Berry & Jean-Christophe Boggio who reported the behavior below - Corrected weird behavior that occured when the panel was aligned bottom and then you assign the TGMSStickylabel - Corrected if TGMSStickyLabel is moved from _AttachedTo component back to the same _AttachedTo component it would not realign itself. Now it does. - Corrected when selecting _AttachedTo you could select a component who did not have the same parent with poor results: Added a property editor that only displays TWinControls that have the same parent. V 1.3 Sep/22/97 - Thanks to Gerald gerald@hydra.hkstar.com for reporting the following bug - Bug in only Delphi3 version. When there is something aligned to top and a new TGMSStickyLabel is dropped on a component it will loop through all the components 3 times with the RectBounds of the TGMSStickyLabel being incorrect until the last loop. In Delphi2 & 1 it only goes thought the loop once with the correct co-ordinates. Solution was that only attach if (Self.BoundsRect.Top > 0) This is a trade off for if you ever try to drop a component at position 0 it will not attach. Drop it just a bit below 0 and it will align no problem. - Thanks to Erik B. Berry for the below improvement Eric suggested to have the component alignment be laRightJustify if the _AlignTo is alLeft. This way when editing the caption it will grow away from the control its attached to, thus not asking to attach to it again. V 1.4 Nov/12/97 - Added options the following options to the property editor alignment (right, left, top, bottom), Set gap, Edit Caption V 1.5 Jan/10/98 - Changed all Assigned(FAttachTo) to the Nil syntax eg. (FAttachTo<>Nil) for Delphi 3 in some cases this caused problems - Fixed _AttachTo so it could be blanked if needed. Before once a TWinControl was assigned this property could not be empty - Added _Offset - Thanks to Mike King from London UK at for suggesting this option V 2 Jan/27/98 - Removed the annoying repeated question to attach to another TWinControl when you are moving the TWinControl with a TGMSStickylabel attached and it overlaps with another TWinControl. - Changed name from _Offset to _AlignPosGap, 1.5 was only distributed to a small few, thus, now was the time to change it, if you had TGMSStickylabels using _Offset it will blank them all to 0. - Changed the name of the Component Editor to GMSLabCE.pas (kept it to 8 char for Delphi1 compatibility) Delete the old one called LblEdit.pas - Added _AlignPos thanks to Erik B. Berry

Classes

TGMSStickyLabel -

Functions

Register -

Types

TAlignPos
TAlignTo

Constants

Variables


Functions


procedure Register;


Types


TAlignPos = (alTopLeft, alCenter, alBottomRight);

TAlignTo = (alLeft, alTop, alBottom,  alRight);
for writing to file for debugging purposes

Constants


Variables