Quick Tip: Implement Zoom In Virtual TreeView Using CTRL + / CTRL –

Virtual TreeView Zoom Most Windows applications I use in my daily work (email clients, browsers, text editors) have a handy feature allowing to make the text larger by increasing (or smaller by decreasing) the font size. Increasing the text size in a web browser is something I got accustomed to doing frequently – to make the web page easier to read if the default text size was set too small for my eyes.

Even though all applications have some visual way (track bars mainly) to zoom in/out their display – all also support zooming by using (standard?) keyboard shortcuts. CTRL+Plus to increase the font size, CTRL+Minus to decrease. Am not sure if you know, but Delphi IDE unit editor also has this feature.
Continue reading

Time Out a Message Dialog – Auto Close a Dialog Window After Some Time / Seconds

messagedlgtimed Users do not read dialogs. They. Do. Not. Neither do we developers (admit it). Dialogs are scary things that pop to the user asking to make some kind of selection / decision. Users mostly simply click the little [x] button and hope no further questions would be raised. Regression: do you know what happens in your code if you display a [Yes|No] dialog and the user closes it by clicking on the [x] button?

Among various types of dialogs (and the information inside) you present to the user, be it a warning, error or information, one type actually requires no user input. Such dialogs are those displaying only the OK (or any single) button. It is questionable should you even have a dialog stating something to the user where the only possible user action is to click on the only button (+ the [x]) displayed by the dialog. Anyhow, I’m certain you have (at least I do) lots of those (…,mtInformation, [mbOk], …) scattered around your code.
Continue reading

Speed Up Your Delphi Database Apps Using Remote SQL

remotesql I recently came across a new product in the Delphi world called RemoteSQL. I use and see a lot of Delphi components in my day to day work, but this one caught my eye because it deals with one of my (/everyone’s) pet peeves – speed. RemoteSQL is an additional client-server application tier that significantly speeds up the connection of a client application to its database, when they are not in the same network. According to GoFast, the creators of RemoteSQL, in a typical environment using their system can speeds up your connection by a factor of between 5 and 40, and in extreme cases up to a factor of 80 which, if true, are rather impressive numbers.
Continue reading

64-bit Delphi Applications Using TWebBrowser to Display PDF Documents – Go or No-Go?

I have an application using TWebBrowser component to allow viewing of Adobe PDF documents within the application. This approach is really pretty simple: when a user of the application has Adobe Reader (/Acrobat) installed, by default any PDF documents will get open inside Internet Explorer (and therefore inside TWebBrowser) – neat and simple way to provide easy PDF preview in a Delphi application (until you go 64-bit…).
Continue reading

Displaying Long Non-Breakable Text (File Path) In MessageDlg – Truncation/Ellipsis Issues

Introduced way back in Delphi 2009 the TTaskDialog (defined in Dialogs.pas) implements task dialogs. Task dialogs first appeared in Windows Vista and are used in later Windows versions. In essence, a task dialog is similar to, while much more flexible and parameter-rich than the standard message dialog. You’ve surely seen such fancy dialogs in action: those containing message title and text (content), icons, push buttons, radio buttons, expandable footer area and more.

In Delphi we have several options (including ShowMessage, MessageDlg, Application.MessageBox and some more) when it comes to displaying some modal message to the user. I’m rarely using ShowMessage and Application.MessageBox as both are not as flexible as MessageDlg (actually ShowMessage internally calls MessageDlg).

MessageDlg: Bruce Banner or Hulk ?

Using MessageDlg can result in 2 different displays of the actual message dialog. What will get displayed (and more importantly how) to the user is dependent on several factors including the following: Windows version your application is running on, if the application was built including runtime themes and if Windows uses themes.
Continue reading

Fun: Refactoring a Complex Delphi Boolean Function

tfRefactoring your own code is, what I guess, something that you do frequently – at least I am. Maybe a better description of the process I went through would be rewriting, but let’s stick with refactoring. Either the routines get too complex, or there’s an extra parameter needed or there’s some new special case to be handled, never mind the reason, refactoring of your own code is what we all do and should do.
Continue reading

TToolBar’s TToolButton AutoSize Width Issues (Empty Captions)

tlbr5If you are using the TToolBar control with TToolButtons in your Delphi application (are you not?, in at least one :\) with “Enable runtime themes” enabled for your project, you might have noticed you cannot easily alter the width of an individual button. What’s worst, if you are using button images and for some of the buttons you want the Caption to be displayed and for some not – the empty-caption tool bar buttons will have a too long width.

Is there a way to fix the width of the no-caption buttons so they “match” the width of the bitmap/glyph/image? For a long time I thought there’s no way to fix this, as whatever property I would change, the display, at run time, simply did not look right. Until I’ve found (as you will see: a very) simple solution.
Continue reading

TLiveIni – Custom Delphi INI Implementation

Text and code by Ron Maupin.

I had to build my enhanced INI class that replaces the database. My Modula-2 version used a doubly-linked list (section) of doubly-linked lists (key/value pairs) for the INI. Delphi’s generics made this much easier, and I now use the TDictionary, although it could be done with TStringList. I used the Delphi ability to have an array property (IniFile[Section,Value]) to simplify assignments and set it as the default property of the INI object. I also didn’t want to get lost in the weeds of having different properties or methods for different data types, so I built some record helpers in the application for different data types that simplify assignment (IntVar := IniFile[Section,Value].ToInt or IniFile[Section,Value] := BoolVar.ToStr).
Continue reading