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

ttaskdialog-sample
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.

liveiniprocessflow
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

Preserving Set Type Values in INI Files (/Databases)

delphi-set2integer
A quick look at the todo list revealed: today is the day to add the following new functionality to my Delphi application: allow the user to change the visibility of some user interface elements on a one-could-say very complex form. There are several controls on the form some users could find to be “too advanced” and they basically will never need em. Naturally, users would prefer such elements to be made invisible to make their final user interface experience less complex (messy) – so that they can better focus on those elements that are important to them.

The first idea is simple: let’s provide an enumeration listing those controls that can be hidden by the user. Let’s group those in a set type variable and expose as a property. Add (inside the configuration screen) a list of checkboxes allowing the user to specify what elements he/she wants to see and what should be hidden. All set, let’s do some coding…

In this application I’m saving all application / user specific configuration settings in an INI file. The TIniFile exposes various WriteSomeValueType procedures. There’s no WriteSet. Oh, so the question to solve before we do any coding: “how to preserve (save/load) set type property value in an INI (or in a database)
Continue reading

FireMonkey / Mobile (Android, iOS) QR Code Generation Using Delphi XE 5 / DelphiZXingQRCode

fmx-TDelphiZXingQRCode
The DelphiZXingQRCode unit, ported from ZXing by Debenu, allows to easily add QR Code generation to your Delphi VCL applications.

While the DelphiZXingQRCode was designed to support VCL applications (and be used in newer as well as in older Delphi versions), it can also easily be “upgraded” for Fire Monkey applications – be it desktop or mobile (Android, iOS).
Continue reading

Generating QR Codes Using Delphi – DelphiZXingQRCode – Open Source Unit by Debenu

TDelphiZXingQRCode
A QR code (Quick Response Code) is a specific 2D barcode that gained popularity during the last years when mobile phones with cameras allowed mobile phone users to quickly scan the image and get more info on a product, business, event, offer, URL address, …

If you need to include the generation of QR barcode images in your Delphi application, you might want to take a look at Debenu’s open source “DelphiZXingQRCode” – a Delphi port of the QR Code functionality in ZXing, an open source barcode image processing library.
Continue reading

Graphical Hints – Image in Virtual Treeview Node Hint (Extending TVirtualTreeHintWindow)

delphi-vtw-pdf-hint-graphics-previewIn a Delphi application, the THintWindow class implements the small pop-up window that appears over a control at run time, when the control has its ShowHint property set to True (and has a value assigned to the Hint property).
The implementation of the THintWindow (at least what gets displayed by it, not how) is rather simple: it will display whatever string value is assigned for the Hint property of a control. If you want more control over what gets displayed by the hint window, and how, and when the hint window will popup – you can create your own version by extending the THintWindow class.
To use your own hint you would assign your own class to the global HintWindowClass variable at application start-up time, so that the new hint window type is used for hints. You can even fine tune the display of the hint window just before it pops-up using the OnHint and OnShowHint events of the TApplicationEvents.

That’s all nice and clear. But, what if the control you are using is Virtual Treeview which has its own version of the hint window implemented in TVirtualTreeHintWindow? What if you want to extend this by including some graphics along with the text that the hint window displays? Further, what if you need to have different hint values for every node displayed by the tree?
Of course, you are not working on a new application – all logic is already there, lots of methods and events already implemented.

The answers: here’s how to simply extend both the TVirtualTreeHintWindow and the TVirtualStringTree to add some node specific graphics to the hint window displaying node specific hints.
Continue reading

Full Text TXT Search In Delphi (+FireDac +SQLite). Sample Working Project.

delphi-sqlite-firedac-fts
Finally, the sample project for my full text search implementation in Delphi is ready. The idea involves providing a user of my application the ability to do full text (Google like) searches on a set of documents by searching inside document content. For the task, I’ve selected SQLite for the database and FireDac for the database connectivity and operations.
Continue reading

SQLite: Referential Integrity With Full Text Search Virtual Tables (used in a Delphi application)

sqlite-fts-ref-integrity
As a second step in my goal to implement full text search functionality in my Delphi application I had to create a sample SQLite database supporting FTS queries.
Full text search models in databases allow to do what Google does with web documents – quickly search for documents containing some word (token).
Continue reading