Solved

Easy way to replace TLabel with TStatic?  Can TLabel be skinned?

Posted on 2006-11-21
7
408 Views
Last Modified: 2010-04-05
Hello...

I have had some programs developed in Delphi, that I would now like to skin using SkinCrafter.

According to my programmers, they used TLabel ( a standard Delphi control) for all the text... and are now saying that SkinCrafter only supports TStatic, which is a standard Windows control.

So they will need to spend about a day per program, manually changing TLabel to TStatic.

My question is:  

1.  Is there a way to globally replace TLabel with TStatic?  
2.  Or is there a way for TLabel to be skinned?

Thanks.

- Dave
0
Comment
Question by:optdave55
  • 4
  • 2
7 Comments
 
LVL 28

Expert Comment

by:TName
ID: 17990827
The main difference between TLabel and TStaticText (I think that's the component you are referring to) is that TStaticText is a "windowed" component, whereas TLabel is not. This means that TStaticText has a window handle and via this handle it can be addressed even from outside the application.
They are very different components, even if they look the same ;)
In theory one could replace all occurences of "TLabel" with "TStaticText" in all dfm and pas files, but as TLabel has a few properties and events that TStaticText doesn't, this could prove to be problematic. It depends on the this: have events for any TLabel been implemented, that TStaticLabel doesn't have? Have properties of TLabel that TStaticText doesn't have, been changed from the default (and thus are mentioned in the dfm file(s)). I'd be very careful and test it (on a copy of the application...) Of course, manually replacing dozens or even  hundreds of labels can be a tedious  task...
0
 
LVL 26

Accepted Solution

by:
EddieShipman earned 500 total points
ID: 17990838
You can use the Replace Components... function from GExperts to automate this for all files in a form
or project.
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 17990846
The only events that TLable has that TStatic doesn't is the OnMouseEnter and OnMouseLeave (in Delphi 7) and
it isn't difficult to add those if you need them.
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 28

Expert Comment

by:TName
ID: 17990960
Hm, I see I've written TStaticLabel in the second paragraph, instead of TStaticText...
I don't know how SkinCrafter works (maybe someone else does?), but I would guess that it uses the handles to access the individual components.
One more thing, even in an ideal situation, where you could replace all instances of TLabel with TStaticText by simply replacing their class name in all files, you could end up with declarations like
Label23:TStaticText;
The compiler wouldn't care, but maintenance programmers in the future probably would ;)
Manually changing the components would be safer I think, but maybe someone has already done this once at a larger scale and can tell you more about it...
0
 
LVL 28

Expert Comment

by:TName
ID: 17990975
Ok, maybe I'm being too hesitant... ;)
0
 
LVL 28

Expert Comment

by:TName
ID: 17991072
>You can use the Replace Components...

"Replace Components" suggested by  EddieShipman  really sounds like the ideal solution, I wasn't aware of it.
http://www.gexperts.org/tour/  (click on Replace Components in the left panel)

Another useful GExperts function...
0
 
LVL 4

Expert Comment

by:tobjectpascal
ID: 17991904
Right mouse click on the form, select "view as text"

object Form1: TForm1
  Left = 192
  Top = 107
  Width = 544
  Height = 375
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 102
    Top = 66
    Width = 32
    Height = 13
    Caption = 'Label1'
  end
  object Label2: TLabel
    Left = 132
    Top = 116
    Width = 32
    Height = 13
    Caption = 'Label2'
  end
  object Label3: TLabel
    Left = 204
    Top = 146
    Width = 32
    Height = 13
    Caption = 'Label3'
  end
  object Label4: TLabel
    Left = 216
    Top = 100
    Width = 32
    Height = 13
    Caption = 'Label4'
  end
  object Label5: TLabel
    Left = 240
    Top = 64
    Width = 32
    Height = 13
    Caption = 'Label5'
  end
  object Label6: TLabel
    Left = 324
    Top = 98
    Width = 32
    Height = 13
    Caption = 'Label6'
  end
  object Label7: TLabel
    Left = 330
    Top = 192
    Width = 32
    Height = 13
    Caption = 'Label7'
  end
  object Label8: TLabel
    Left = 264
    Top = 270
    Width = 32
    Height = 13
    Caption = 'Label8'
  end
  object Label9: TLabel
    Left = 140
    Top = 268
    Width = 32
    Height = 13
    Caption = 'Label9'
  end
  object Label10: TLabel
    Left = 60
    Top = 234
    Width = 38
    Height = 13
    Caption = 'Label10'
  end
  object Label11: TLabel
    Left = 108
    Top = 194
    Width = 38
    Height = 13
    Caption = 'Label11'
  end
  object Label12: TLabel
    Left = 160
    Top = 206
    Width = 38
    Height = 13
    Caption = 'Label12'
  end
end


Just Delphi Menu > Search > Replace

TLabel
TStatic

Then right mouse click, select View As Form, Delphi will then say, Property X does not exist, do you wish to correct, press Yes (i've had instances of 50 or 60 components coming up) I've even got to the point where i've held down enter for a few seconds lol...


0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now