Archive for the ‘Delphi.Net’ Category

.Net Security and Shared Drives

Wednesday, June 18th, 2008

.Net has the ability to restrict the permissions granted to executables based on where the executable is located.  Executables on a your local hard drive have different permissions than those on a shared drive or downloaded from the Internet.  I recently wound up banging my head against this for several hours after I had to re-install the .Net Framework.  That seems to have reset my local intranet (shared drive) permissions to something less than Full Trust.  To fix it I had to do this:

(more…)

Timers in .Net

Tuesday, June 17th, 2008

The scrolling marquee component in the Essentials suite made use of multimedia timers (timeSetEvent) to control the speed at which the text scrolled across the label. While a multimedia time has a finer resolution and is more accurate than a standard Windows timer, the multimedia timer caused problems in the form of sporadic uninitialized pointer errors. Since I was unable to track down the exact cause of the problem and since I didn’t need the additional accuracy provided by the multimedia timer, I switched to one of the standard timers provided by the .Net framework. Namely, System.Threading.Timer.

(more…)

TRect, TPoint and TSize Moved

Monday, June 16th, 2008

The TRect, TPoint and TSize classes and their supporting functions like Rect and Point have been moved to the Types unit!

AllocateHWnd and DeallocateHWnd Moved

Monday, June 16th, 2008

The AllocateHWnd and DeallocateHWnd functions have been moved to the WinUtils unit!

Variant Records Unsafe in .Net

Monday, June 16th, 2008

It turns out that variant records, that is records with overlapping fields, are considered unsafe by the .Net CLR. A pity, since I use these things all the time to crack message buffers and the like. Fortunately, what .Net takes away, new features of the Delphi language give back. Because it is now possible to have methods and properties attached to records it is fairly easy to simulate variant records.

(more…)

Namespaces in Delphi.Net

Monday, June 16th, 2008

I initially found the use of namespaces in Delphi.Net to somewhat confusing. I think the reason for this was the project Default Namepsace property. Although using the default namespace provides a nice short hand way of assigning all units in your project to the same namespace, it makes the naming of the units and source files a bit confusing, at least to me.

(more…)

Using String Resources in Delphi.Net

Friday, June 13th, 2008

The first thing that became apparent was that a lot of unsafe code was being used to access string resources. Turbopower also used a proprietary string resource compiler to create the .RES files from text files.

A little research revealed much better ways of doing this in .Net. By using the ResGen tool and the ResourceManager component supplied with the .Net 2.0 SDK it was possible to eliminate the unsafe code and drastically reduce the size and complexity of the string resource handling code as well.

(more…)

Migrating VCL Components to VCL.Net

Friday, June 13th, 2008

Today I am starting a project to port the Turbopower Essentials component suite to VCL.Net.  Turbopower open sourced these components when they got out of the Delphi component business some years ago.  The components have been languishing on the shelf at SourceForge ever since.

My reasons for doing this are twofold:

  1. There seems to be a dearth of third party components for VCL.Net
  2. I need to get up to speed with VCL.Net and .Net.  Porting these components will allow me to  train myself up on both technologies without messing with our production code.

I intend to write blogs entries about my progress, outlining the things that I have learned along the way.  The process of blogging about the experience will help me to remember what I have learned.  If I happen to help someone else along the way so much the better.

So, stay tuned!  You might learn something and you might get to see me fall flat on my face.

Hard Linking Delphi.Net Packages into Your Application

Wednesday, June 11th, 2008

I spent quite a while looking for this option because it is done in quite a different way from Delphi 5.  In Delphi 5 there was a single link option that either caused your application to use dynamic run time packages or statically linked run time packages.  That was it, all or nothing.  In Delphi.Net you can pick which packages to use statically while leaving everything else dynamic.

(more…)

Adding a Tool Box Icon to a VCL.Net component

Wednesday, June 11th, 2008

Unlike Delphi 5 where you had to add the icon for your components into a resource (.DCR) file, for VCL.Net you need to include a reference to the bitmap file containing the icon in your source code.  You use the $R compiler directive for this.

(more…)