Holger's Thoughts on Delphi

Wednesday, November 30, 2005

Delphi - Coding Standard?

At the end of June, during the publication of my first BDNtv presentation I got some feedback regarding my coding style used in the first episode. I was totally surprised that there was an official document that dealt with that topic. So, if you're interested: Object Pascal Style Guide.

I have to admit that I still only use about 50% of that document for my personal development stuff - but that's pretty good, considering that I never was taught any Delphi coding standards before ;-) In school we learned:
if ... then begin
....
end;

A lot of people did not like it and it is very visible. Thus, that was the first thing I changed.

Tuesday, November 29, 2005

DevCon 2005

Well, if you were unable to fly to San Francisco in order to attend the Borland DevCon 2005 at the beginning of this month, Borland Developer Network really offers some attractive (nah, not that kind of attractive ;-)) content.

I just finished watching this and it kept me up until 3:30 am. Thus, I have to say that it was pretty interesting to see all those new features. Major emphasis is being put on the designer and code editor enhancements made for Borland Developer Studio 2006. Delphi and C++ are being presented.

And no, I did not forget that I promised to tell you about my favourite Delphi book... will do later...

Saturday, November 26, 2005

Getting in touch with .NET

After yesterday's confusion, I am going to blog about something safe, I cannot go wrong with - at least technically.


Andreano Lanusse blogged about Xavier's Delphi Book. An excellent choice, but I disagree with him on the fact that it is 'the' book to learn about .NET. In my opinion that book has been written by Mr. .NET himself, Mr. Jeffrey Richter. For me that was the start into .NET development and also to get a feel for C#. If you're looking for a book what Object-oriented programming is, this is not the way to go, of course. It also does not focus on Delphi, but it features all the important namespaces of .NET, i.e. it explains collections, file-access and also goes into detail about reflection. Critics also call the chapter about the .NET Garbage Collection in this book the best ever written. I have to say that I agree with them. There's no way to explain it any easier.


Tomorrow I'll tell you about my fav Delphi book

PopupMenu Part II

Well, nobody is perfect, I guess. Ryan McGinty just brought up a far shorter solution to the problem, which might be sufficient for the most cases.

Simply use
property PopupComponent: TComponent read FPopupComponent write FPopupComponent; of TPopupMenu.

Thanks Ryan!

Friday, November 25, 2005

What component triggered the popup menu?

I hope the headline makes it clear, but I will give additional details first. Let's assume you have one TPopupMenu on your form and two TMemos. Associate both TMemos with the popup menu. When the popup menu pops up, can you tell which one of the two memos was right-clicked?


  • "Yes, it's the Sender-parameter in TPopupMenu.OnPopup." - Wrong.
  • "Of course, it's the Sender-parameter in the OnClick-event of the menu." - Wrong.


I was pretty stunned a couple of days ago as I did not want to implement one popup menu for every component or something scary like that. The solution is easy, if you know it, of course. You just have to look at the right place.

The component that is being right-clicked has a property named "OnContextPopup". So what you could do, use the Tag-property of both TMemos and implement a common OnContextPopup-event for both that sets the Tag of the popup menu accordingly. So you can determine at any time during or after menu popup, which component triggered it.

Easy if you know where to look, but really nasty to find if you look at the menu and its events only.

Happy Thanksgiving everybody!

Wednesday, November 23, 2005

Indy: Can I use Indy Components in ASP.NET applications?

Let me give you the answer by asking you: Why not? As I said in one of my previous posts, Indy assemblies do not differ from any other .NET assembly. ASP.NET can "use" any class of any .NET assembly. However, I think this 'question' arises because of the fact that two things may happen:
  1. Your internet provider may not allow you to deploy custom assemblies in addition to your application DLL

  2. You may not have propery security rights to allow the operation that is included in the assembly to be executed


In the second case you are busted. There is no other way, but to apply for additional access rights. The first case, however, can be solved if you want to use the Indy assemblies. The Delphi compiler can link the Indy "libraries" into your appliciation DLL. Yes, this is really possible due to the fact that Indy is written in Delphi and the Delphi compiler offers that feature. Just right-click on all the Indy assemblies in the Project Manager and check the "Link Unit" menu item and you'll end up with one application assembly.

That's a pretty neat feature of the compiler, isn't it?

About Skype

My friend J.P. warned me. I wouldn't listen. But it is not a good idea to place a "call me" button on your blog, if you forget to tell your client only to let people call you who are on your contact list.

Basically, I changed that now. If you want to call me, you need to be on my contact list first.

And I advise anybody thinking about to put that that nice feature from Skype.com on their blog to think about the same. I had a couple of calls yesterday from people who just thought it to be fun to press the button :-(

Tuesday, November 22, 2005

Time

The internet and Skype make it possible: press one button and you call the person you chose in a list - wherever that person is in the world right now. That is a very nice feature, but can be very very embarrassing if the person you call leave the PC online 24 hours and you call at 3am in the morning.

I had the very same problem tonight. So I found this page, which is more than useful:
http://tinyurl.com/w9p3

Sunday, November 20, 2005

Indy and Winforms (using GExperts)

I had an interesting chat today about a topic that's been an issue for Indy in the last couple of months. Firstly, let me say that the Indy Library does not have any dependencies on the Delphi RTL any longer. The Indy Core Team implemented custom RTL routines, so we no longer depend on the Borland-Namespace.

However, a lot of people still are surprised that you can do Winforms development with Indy. Why shouldn't you? All Indy stuff for .NET are assemblies, no different from any other 3rd party assembly. The only difference is the design-time support. VCL.NET does have design-time support, Winforms does not.

Just in case: Design-time support means that the components appear on the Tool Palette, you can drop them on a form and change properties during design-time. In Winforms we do currently not have that capability.

There are many reasons for this, but the most striking one is that the property editors which we have for VCL would have to be completely rewritten for Winforms, for which we currently do not have the manpower. We looked into it and decided to spend resources on other issues.

However, even if you do not want to write runtime code when using Indy components, I might have a workaround for you!

GExperts, a 'couple' ( of wonderful IDE plugins), helps you in that regard.

Simply

  1. create a VCL form,
  2. drop any Indy component on the form,
  3. set the properties to your liking,
  4. right-click the component and
  5. chose the command "Components to Code".

If you have an older version of GExperts you may find that item in the GExperts menu. Thus, you will end-up with the code to create that exact component in the clipboard. The final step is to paste that code into your Winforms application.

Here you see the popup menu with the GExpert item "Components to Code"


This generates the following source code:


Of course, this does not help you at all when using C#. I am very aware of that. However, as I was talking in the chat today I thought that more people could profit of the result of that chat.

Freeware: TinyClip



Okay, you might have heard about TinyUrl.com. You have a very long URL, you copy it into a form on TinyUrl.com and you get a very short URL as a result.

This might be very handy at first, but it is not, considering that you have to go to the page all the time. Yes, I know there is a toolbar for Firefox, but still. The Firefox-Toolbar does not handle any links you copy into the clipboard, does it?

TinyClip does. It's - still - totally free for download from Hadi Hariri's (AToZed Software) site.

This little tool, which starts when my computer boots, is the reason why all URLs on this blog are TinyURLs. Posted by Picasa

Published Articles

I published a couple of tutorials (aka BDNtv) about ASP.NET on the Borland Developer Network:
All episodes are about 30 minutes long. Enjoy!

Indy Team in Arnhem 2005

Posted by Picasa
Only a few people know that I joined the Indy Development team in April 2005. In the end of May some of the Indy Core Team met in Arnhem (Arnheim) at a Developer Conference.
On the photo you see (left to right) Matthijs ter Woord, me, Chad Z. Hower, Bas Gooijen and Olaf Monien.

Blogging again

It's 3:30 am in the morning and I have to stay up, because I promised to drive a friend of mine to the airport in an hour or so.
Thus, the ideal time to set up blogging again.
This blog will focus on Delphi mainly, but also on the C# personality of Borland Delphi.