Mega Code Archive

 
Categories / Delphi / Graphic
 

3D Labels (Lowered and Raised)

Title: 3D Labels (Lowered and Raised). Question: How to create 3D labels? Answer: This procedure is very simple and useful. You still can customize it to accept more parameters. I hope you will enjoy it. procedure Create3DLabel(oForm : TWinControl; const sText : String = 'Delphi'; iTop : Integer = 0; iLeft : Integer = 0; iDepth : Integer = 3; sFontName : String = 'Arail'; iFontSize : Integer = 10; const sLookingType : String = 'Raised'); var oLabel1 : TLabel; oLabel2 : TLabel; begin oLabel1 := TLabel.Create(oForm); oLabel1.Parent := oForm; oLabel1.Transparent := True; oLabel1.Font.Name := sFontName; oLabel1.Font.Size := iFontSize; oLabel1.Caption := sText; oLabel1.Font.Color := clWhite; oLabel2 := TLabel.Create(oForm); oLabel2.Parent := oForm; oLabel2.Transparent := True; oLabel2.Font.Name := sFontName; oLabel2.Font.Size := iFontSize; oLabel2.Caption := sText; oLabel2.Font.Color := clBlack; if sLookingType = 'Lowered' then begin oLabel1.Top := iTop + iDepth; oLabel1.Left := iLeft + iDepth; oLabel2.Top := iTop; oLabel2.Left := iLeft; oLabel2.BringToFront; end; if sLookingType = 'Raised' then begin oLabel1.Top := iTop - iDepth; oLabel1.Left := iLeft - iDepth; oLabel1.BringToFront; oLabel2.Top := iTop; oLabel2.Left := iLeft; end; end; Examples of use: (1) ....................................................................... Create3DLabel(TWinControl(self),'Hello Word',10,10,2,'Times New Roman',72,'Lowered'); ....................................................................... (2) ....................................................................... Create3DLabel(TWinControl(self),'Hello Word',100,100,3,'Times New Roman',72,'Raised'); .......................................................................