The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

Archive for the ‘Delphi 3’ Category

Delphi: using IInterface to restore cursor at end of mehod (prelude to a memento that executes any code at end of method).

Posted by jpluimers on 2014/08/06

A long while ago, I wrote about a (then overdue post) on .NET/C#: Using IDisposable to restore temporary settrings example: TemporaryCursor class.

I had been using a similar technique in Delphi since before I found out about the [WayBack] TRecall class and thought: I think my TTemporaryCursor is smarter, as it is based on interfaces.

TRecall (and the [WayBack] Vcl.Graphics descendants [WayBack] TBrushRecall, [WayBack] TFontRecall, and [WayBack] TPenRecall) store [WayBack] TPersistent properties using the Assign method. They were introduced in Delphi 6.

Too bad there are only [WayBackvery few people using TRecall as lots of TPersistent things warrant sasaving and restoring.

My [WayBack] TTemporaryCursor (now [WayBack] at bitbucket) class only stores an integer, so it cannot derive from TRecall. Besides it is based on IInterface which got introduced in Delphi 6, but was present as IUnknown since Delphi 3 (see [WayBack] Interface It! A quick guide to the ins and outs of interfaces in Delphi. By Jimmy Tharpe).

This means that TRecall could have been based on IInterface, so I wonder why it was not.

Note I’m not the first to publish about such a class (Malcolm Grooves wrote [WayBack] TCursorSnapshot, SwissDelphiCenter has [WayBack] TMyCursor, Nick Hodges published about [WayBack] TAutoCursor), it’s just that it has been in my tool box for so long, and written memento classes that you will see 2 articles on it this week.

In the mean time (this works with Delphi 2009 and up), I also wrote a small class that does similar things for any  [WayBackanonymous method. More on that tomorrow.

Back to TRecall: it is an example of [WayBack] the memento pattern in Delphi. The [WayBack] memento pattern allows you to restore state.

SourceMaking.com a.k.a. [WayBack] Design Patterns and Refactoring is a great site about [WayBack] Design Patterns, [WayBack] UML, [WayBack] AntiPatterns and [WayBack] Refactoring.

Most pattern example code is available in all of the C#, C++, Delphi, Java and PHP languages.

Great stuff!

One of the constructs for restoring state is a [WayBack] try … finally … end construct: it allows you to always execute something in the finally block, for instance restoring the state to right before the try block. Read the rest of this entry »

Posted in Conference Topics, Conferences, Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 3, Delphi 4, Delphi 5, Delphi 6, Delphi 7, Delphi x64, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Design Patterns, Development, Diagram, Event, Software Development, UML | 14 Comments »

The StackOverflow Pascal/DelphiSyntax Highlighter

Posted by jpluimers on 2014/07/22

Found out where the StackOverflow Pascal has its origins: What happened to comments in syntax highlighter? – Meta Stack Overflow.

Like any syntax highlighter, it is not perfect (only a Delphi compiler driven highlighter would have a chance to be perfect), but it does a pretty good job and gets better over time.

–jeroen

Posted in Borland Pascal, Delphi, Delphi 1, Delphi 2, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 3, Delphi 4, Delphi 5, Delphi 6, Delphi 7, Delphi x64, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Development, FreePascal, Pascal, Software Development, Turbo Pascal | Leave a Comment »

Delphi: Variant versus OleVariant (via: RAD Studio API Documentation)

Posted by jpluimers on 2014/07/16

I used to forget about the difference between Variant and OleVariant, and used them like this:

Use OleVariants for OLE, and Variants for non OLE.

There is no need to manually clear them.

Luckily I was right, as the differences are documented in the Delphi on-line help at OLE-compatible Variant type (the oldest I could find was the Delphi 2010 OleVariant documentation): Read the rest of this entry »

Posted in Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 3, Delphi 4, Delphi 5, Delphi 6, Delphi 7, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Development, Software Development | Leave a Comment »

Delphi `with` post and discussion revisited (via: wiert.me and LinkedIn)

Posted by jpluimers on 2014/06/11

A bit more than a year ago, I wrote about Delphi: you should avoid the with statement as it makes your code less future proof. That caused some nice comments on the blog, and some more on LinkedIn where Paul Foster mentioned it in a thread ‘Jeroen Pluimers makes a case against “with” statements.‘ Both interesting reads, especially the reasons that people use or avoid with, or keep its use in balance. There is one set of comments I want to emphasize: refactoring multiple with statements into a one function and a call per former with. Read the rest of this entry »

Posted in Borland Pascal, Delphi, Delphi 1, Delphi 2, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 3, Delphi 4, Delphi 5, Delphi 6, Delphi 7, Delphi 8, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Development, Pascal, Software Development, Turbo Pascal, With statement | 19 Comments »

Delphi multithreading and DLL exports: watch your exceptions (via: Stack Overflow)

Posted by jpluimers on 2014/06/03

Talking about Danny Thorpe: he also posted a nice hint on threading methods for ancient Delphi versions that equally applies to DLL exports in any Delphi version, even any programming environment.

Recently, I had to do some surgery in such a Pre-Delphi 6 application, and I was really happy to remember this answer: it instantly solved some process crashes, and the added logging allowed for investigating the actual cause.

Note that this tip isn’t just a good advice for old Delphi versions.

Even in younger Delphi versions, you have to watch methods that can be called from outside a regular Delphi context, for instance exported methods.

Heck, it applies to virtually any development environment: exceptions usually are very specific to that environment and should never cross a process boundary.

Summary

Take the approach below

  • for Execute methods in your own thread classes in Delphi 5 or earlier
  • for any method that can be called externally (like DLL exports) Read the rest of this entry »

Posted in Delphi, Delphi 1, Delphi 2, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 3, Delphi 4, Delphi 5, Delphi 6, Delphi 7, Delphi 8, Delphi x64, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Development, Software Development | Leave a Comment »

Delphi: Design-Time Component Name Limited to 63 characters (via: Vin Colgin – Google+)

Posted by jpluimers on 2014/05/05

I learned something new today (thanks Vin Colgin) the Delphi Design-Time Component Name is Limited to 63 characters.

Uwe Raabe found out that this an Object Inspector thing due to this constant in DesignIntf.pas:

const
  MaxIdentLength = 63;

It has been probably there since Delphi 1 and has been documented on-line since at least Delphi 2007.

I remember having had long (like 100+ character) identifiers in source code, but not in the Object Inspector.

Now I know you can’t (:

–jeroen

via: Vin Colgin – Google+ – Delphi: Design-Time Component Name Limited to 63 characters….

Posted in Delphi, Delphi 1, Delphi 2, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 3, Delphi 4, Delphi 5, Delphi 6, Delphi 7, Delphi 8, Delphi x64, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Development, Software Development | 4 Comments »

delphi: idioms for building strings (via: my answer on Stack Overflow)

Posted by jpluimers on 2014/04/16

Once every while, one of your StackOverflow answers gets an edit suggestion that is really valuable.

This case it was Edwin Yip who suggested to emphasize the difference between TStringBuilder and TStringList (adding characters versus lines).

Too bad that freshly 10k user Makoto showed he hates bold emphasis, intentional property casing and post signatures by removing the added value (there is so much emphasis he could remove on other answers to warrant at least a day time job).

I know that not all emphasis is welcomed at StackOverflow, but in this case I think it added real value.

So I edited my own answer to add even more value: showing the idioms I use for building strings, and now it is time to quote it: Read the rest of this entry »

Posted in Delphi, Delphi 1, Delphi 2, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 3, Delphi 4, Delphi 5, Delphi 6, Delphi 7, Delphi 8, Delphi x64, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Development, Software Development | Leave a Comment »

Delphi `TParser` links

Posted by jpluimers on 2014/03/25

I needed to modify some code that had been amended from the Delphi TParser class (which parses DFM files, but can be amended to other sources as well), so here are some links I found during my research:

Oh and it is on the Delphi VCL Hierarchy poster too (:

–jeroen

Posted in Delphi, Delphi 1, Delphi 2, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 3, Delphi 4, Delphi 5, Delphi 6, Delphi 7, Delphi 8, Delphi x64, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Development, Software Development | Tagged: | 2 Comments »

Delphi: make sure you show the `ExceptAddr` and `ClassName` if you display in exception in DEBUG mode.

Posted by jpluimers on 2014/03/21

When handling `Application.OnException` add the `ExceptAddr` to in Delphi the menu `Search` -> `Goto address` has a chance of working, and the `ClassName` so you know what happened.

You might want to always do this, depending on how scared your users get from HEX values in error messages.

This works in about every Delphi version I ever used: Read the rest of this entry »

Posted in Delphi, Delphi 1, Delphi 2, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 3, Delphi 4, Delphi 5, Delphi 6, Delphi 7, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Development, Software Development | 2 Comments »

[FOSDEM 2014] Visualizing Delphi with Moose – YouTube

Posted by jpluimers on 2014/03/20

Jus finished watching this very interesting talk from the last FOSDEM 2014 conference: [FOSDEM 2014] Visualizing Delphi with Moose – YouTube.

It is based on MOOSE (an open-source platform for software and data analysis) and PHARO (a free and open-source Smalltalk environment).

This is how to get started (it is in Dutch, we have great developers and researchers around here).

Be sure to watch the presenter Stefan Eggermont (StackOverflow, Twitter, LinkedIn, GitHub, FOSDEM, website www.legacycode.nl) as this kind of analysis (that is also possible for other languages and tools) can highly speedup your work.

You can download the webm version of the talk from the FOSDEV14 devroom.

–jeroen

Posted in Delphi, Delphi 1, Delphi 2, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 3, Delphi 4, Delphi 5, Delphi 6, Delphi 7, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Development, Software Development | 4 Comments »