views:

445

answers:

4

I have a rather large (freeware) project written with Delphi 2007 which is using both the TntUnicodeControls and the TntLXControls library and I'm planning to move to Delphi 2009.

Unfortunatly I'm using those libraries everywhere in my project:

  • Replacement for VCL controls to provide Unicode capability
  • Win32 API wrappers (mostly for comparing strings)
  • The feature enhancements of TntLXForms, TntLXRegistry, ...
  • Third-party components which use TntControls. (VirtualTrees, SpTBXLib, updates for D2009 are available)

Do you have any experience and/or suggestions in porting such a project to Delphi 2009. Is it advisable to first switch to the (commercial) TMS Unicode controls?

+1  A: 

I think either way it's going to be a lot of work. Probably more so than if you hadn't done all the work to make it unicode compatible before. I personally would forget about the tms Unicode controls, and go back to the vcl. It will save more pain in the future. (nothing against those controls, mind you.)

Also remember, that D2009's string, is not the same thing as D2007's Widestring which you have undoubtedly used in your app. So all instances of Widestring, which you so diligently changed from string (which was AnsiString), need to go back again to string(which is now unicodestring).

Steve
+4  A: 

Install GExperts; there is "Replace component" IDE addin that can help converting TTntXXX to TXXXX controls. Try for once, and if it's ok just check "Replace evrywhere in project".

SpTbx and VirtualTrees can only be recompiled - they both support D2009.

If you used WinAPI wrappers just to call Unicode API-s they should work in D2009 also.

That leaves you with TntLX controls (TntLXForms, TntLXRegistry, ...). Since they are unsupported, may be it is good time to change them anyway.

dmajkic
Can Gexperts do wildcard replaces - eg . TTnt* to T*? I think not, so you need to replace TTntLabel, followed by TTntButton, followed by...
Roddy
You can also simply edit dfm files (replace ": TTnt" to ": T")
samir105
+3  A: 

I can help with some of this, as I'm porting a C++Builder application that uses TNT from 2007 to 2009. The switch to Unicode in D2009 is overdue and welcome. However, it's unfortunate that the transition is probably easier for those who have NOT needed unicode in the past, and probably still don't. If, like me, you needed Unicode and used Troy Wolbrink's great TNT control to provide it, you have a rather more complex job...

The good news is that there's a new version of TNTControls from TMS Software which supports D2009. I haven't looked at this, but expect it is just a 'facade' layer over the native VCL components to ease portability. I'd consider that if your other libraries can be rebuilt to use it.

However, you may be better going back to native VCL controls, and the reason is string types. TNT control have always used WideString to pass Unicode strings back and forth, and you may well have WideString use scattered through your own code. This will work, but it's not ideal as WideString should really just be used for COM interop as it 'wraps' the COM BSTR type. Native unicode strings in D2009 are reference-counted and should be significantly faster.

If you do decide to replace TNT components with native VCL ones, you can use GExperts "Replace Components" command - or, maybe easier, do a search and replace in your .DFM and .PAS files (which you DO have in text form, don't you) to replace TTNT with T.

Roddy
+2  A: 

I recommend the following resources:

Marco Cantu's Delphi 2009 Handbook Chapter 3 (Porting to unicode) http://www.marcocantu.com/dh2009/

Nick Hodges' articles (Delphi in a Unicode World) http://blogs.codegear.com/nickhodges/2008/11/20/39149

samir105