Ever wondered why your exe-File got so big after all the time you worked on it? Well, for that reason the map-file actually exists, but it’s not really easy to understand. Lines and lines of non-human-readable lines of debug text…
Wouldn’t it be great if there was a tool to parse it? That was at least what I was thinking. After searching and not finding anything the answer either was “There is not tool” or “You don’t know how to search”. Positively thinking it was the first I started making my own parser for map-files, so here’s the result of my short work to quickly find unnecessary units in my application.

DSMapParser

The tool (called DSMapParser) is quite simple in what it’s doing. You compile your project with a map file and open the map-file in the Map Parser.
The parser than (surprise!) parses the map-file and groups every file by its namespace. The result is a quite nice overview of all the units that bloat your application.

DSMapParser

Installation

  1. Grab the latest release from the github repository: https://github.com/delphi-sucks/DSMapParser/releases
  2. Extract it and use it! That simple!

Source: https://github.com/delphi-sucks/DSMapParser

Using it

Before you can actually use the map-parser you probably need to adjust some settings in your project to generate a map-file:

  1. Go to your project options: Project > Options
  2. Navigate to “Delphi-Compiler > Linking”
  3. Change the setting “Map-File” to “Segments”

Ensure that you have changed the options in your corresponding release-configuration.

After changing these settings your compiler creates beside your .exe-file also a .map-file, which can be used by the Map-Parser.

 

TL;DR

Parse your Map-File with the DSMapParser to find out why your application is so bloated.

Ever wanted to use some fancy Unicode emotes in your Delphi application? Well good luck with that, because the RichEdit controls are using a library that’s so old it even supports Windows 95! An OS that had no support for more than 16 years (support ended December 31, 2001)!

So why isn’t embarcadero also dropping support for that and use a library for at least Windows XP (let’s be serious, enough people are still using it). The reason probably would be because either way embarcadero want’s to still support it (like Windows 3.11) or because Microsoft doesn’t offer really good alternatives.

So let’s look at the possibilities Microsoft gives us here; Looking at the MSDN-Page about the RichEdit-Control (https://msdn.microsoft.com/en-us/library/windows/desktop/bb787873(v=vs.85).aspx) we can see that it’s documented from version 1.0 (Windows 95) up to 4.1 (Windows XP), but aren’t there any other versions? I mean Microsoft can’t seriously not have updated their RichEdit-Control since Windows XP, right? They have! But not for everyone! If you want to use a version higher than 4.1 you would need Microsoft Office.

This is obviously not a solution having Microsoft Office as requirement for your application and embarcadero probably thinks the same way. So what are your solutions? Use the latest version you can use without worrying about too much! In this case it would be version 4.1 which also supports Unicode.

Getting RichEdit 4.1

To enable support for RichEdit 4.1 in your RichEdit-controls you need to load the library and tell your control to use another version:

unit UnicodeRichEdit;

interface

uses
  Vcl.Controls, Vcl.ComCtrls;

type
  TUnicodeRichEdit = class(TRichEdit)
  protected
    procedure CreateParams(var Params: TCreateParams); override;
  end;

implementation

uses
  System.Classes;

procedure TDSUnicodeRichEdit.CreateParams(var Params: TCreateParams);
begin
  inherited;
  // Tell the RichEdit control to use 4.1
  CreateSubClass(Params, 'RICHEDIT50W');
end;

var
  FRichEditUnicodeModule: HMODULE;

initialization
begin
  // Load the library
  FRichEditUnicodeModule := LoadLibrary('MSFTEDIT.DLL');
  if FRichEditUnicodeModule <= HINSTANCE_ERROR then
  begin
    raise Exception.Create('Could not load library "MSFTEDIT.DLL"!');
  end;
end;

finalization
begin
  // Free the library
  if FRichEditUnicodeModule <> 0 then
  begin
    FreeLibrary(FRichEditUnicodeModule);
  end;
end;

end.

Installation

A complete package ready to install is also available at GitHub: https://github.com/delphi-sucks/DSUnicodeRichEdit

  1. Download the latest version from https://github.com/delphi-sucks/DSUnicodeRichEdit/archive/master.zip
  2. Open the project-file “src/DSUnicodeRichEdit.dpk”
  3. Install it (right click on the project in the project overview and “Install”)
  4. Go to Tools > Options > Delphi Options > Library
  5. Add the path to the src folder to the Library-Path (repeat this step for every platform you want to use this component with)

Conclusion

It’s a bit tricky but with a small amount of code you can have Unicode emotes in your RichEdit control and also enjoy the old new features of version 4.1. If you are concerned about reliability then don’t worry; After a long period of use in a production environment I had no single error. You only have to consider that you need to have at least Windows XP otherwise it won’t run.

 

TL;DR

Have RichEdit-controls with Unicode support by using the DSUnicodeRichEdit package.

Wouldn’t it be nice if you could just make your Delphi IDE a bit more nice to look at? Well, when working with Delphi every day you really need something to get your thoughts of the frustration. So here is my recommendation for you!

The Ita-IDE plugin gives you the ability to set a custom background in the editor, so you have always something nice to look at.

Ita-IDE

 

Notes

You need to have at least Delphi XE2 to install it without modifying the source code.

It’s compatible with the newest version (at the time of writing) Delphi 10.2 Tokyo.

Installation

  1. Grab a copy of the source from github.com: https://github.com/lynatan/Ita-IDE-Plugin
  2. Open the project and install it as a plugin
  3. Done!

Configuration

To personalize the background just go to the settings at “Tools > Ita IDE Options”. There you can set your own image (better use one with a transparent background otherwise it will look weird), set the size, position and transparency.

 

TL;DR

Set a custom background with the Ita-IDE plugin.