Need to change an old app with TTabbedNotebook to TpageControl

Hello Gurus, I have an app that uses a TTabbedNotebook with a LOT of controls on it, and I would like to get with the 21st century and convert that TTabbedNotebook to a TPageControl, but am not looking forward to removing all my controls and putting them back on the TPageControl. Is there an easier way to do this?

Thanks!
   Shawn
shawn857Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

atul_parmarCommented:
Hi,

1. Derive a class from TPageControl e.g. TMyPageControl.
2. You may be using methods/events/properties of TTabbedNotebook which does not exists in TMyPageControl. You will need to write wrappers of such methods and provide implementation or route it to its equivalent in TMyPageControl.
3. Find and replace all class references of TTabbedNotebook with TMyPageControl in both .PAS and .DFM files

Atul
0
shawn857Author Commented:
Thanks Atul, but I have no idea how to do (1) and (2)

Regards
   Shawn
0
atul_parmarCommented:
First two steps make sense when you are using methods/events/properties of TTabbedNotebook. The thing is - even if those aren't used explicitly, Delphi saves certain property settings in the DFM files.  It is actually writing an adapter for the TMyPageControl.

You choose to skip first two steps; however, in that case Delphi may complain when you open the form saying that property not found; and you can ignore it so that Delphi can correct it.

For instance following is my DFM file

  object nb1: TTabbedNotebook
    Left = 40
    Top = 24
    Width = 300
    Height = 250
    PageIndex = 1
    TabFont.Charset = DEFAULT_CHARSET
    TabFont.Color = clBtnText
    TabFont.Height = -11
    TabFont.Name = 'Tahoma'
    TabFont.Style = []
    TabOrder = 0
    object TTabPage
      Left = 4
      Top = 24
      Caption = 'Default'
    end
    object TTabPage
      Left = 4
      Top = 24
      Caption = 'Test'
      ExplicitLeft = 0
      ExplicitTop = 0
      ExplicitWidth = 0
      ExplicitHeight = 0
    end
  end

Replace TTabbedNotebook with TPageControl and TTabPage with TTabSheet. While opening the form, Delphi complaints that certain properties not found, choose ignore and it will correct the DFM file.  You will also need to provide names to the TabSheet e.g.

  object nb1: TPageControl
    Left = 40
    Top = 24
    Width = 300
    Height = 250
    ActivePage = tsDefault
    TabOrder = 0
    object tsDefault: TTabSheet
      Caption = 'Default'
    end
    object tsTest: TTabSheet
      Caption = 'Test'
      ExplicitLeft = 0
      ExplicitTop = 0
      ExplicitWidth = 0
      ExplicitHeight = 0
    end
  end

Finally fix the references in .PAS file and introduce references for the tab sheets.

Atul
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Sinisa VukSoftware architectCommented:
I suggest to go all manually - good developer practice is to refactore source code more often. This way some stuff can be optimized, fixed, make more user friendly...
Go, take a time to do this...
0
Geert GOracle dbaCommented:
Why make it so difficult ?
Get GExperts at www.gexperts.org
Install it and then from the gexperts menu in the delphi IDE you get this little feature:

replace component feature
it's interactive when errors occur.

I haven't found a tool for converting my ideas directly from my brain to code yet ...
but this gexperts helps :)
0
shawn857Author Commented:
Thanks all for the replies. Geert - I found an opinion on the internet regarding this tool:

http://embarcadero.public.delphi.language.delphi.general.free-usenet.eu/TTabbedNotebook->TPageControl-conversion-tool_T32981083_S1

They say it does not work for TTabbedNotebook --> TPageControl conversion.  :-(

Shawn
0
atul_parmarCommented:
Replacing text in DFM/PAS is pretty easy job unless you want to do it one by one. e.g. CnPack has an option 'Replace in Files..' that will do the job in few seconds. However, there is still some manual work. e.g. naming the TabSheet. The other option is to write a script in some of the scripting language that can manipulates the text well e.g. Ruby.
0
shawn857Author Commented:
Did it, thanks Atul!

Cheers
   Shawn
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.