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’ Category

Delphi Corner Weblog: New: Velthuis.AutoConsole unit – helps against the “optimised” Embarcadero FastMM fork.

Posted by jpluimers on 2017/05/17

Brilliant:

if it is a console program and it was started any other way (from the Windows Explorer, from the Delphi IDE with or without debugger, from another non-console program), then, before the console window can close, it will display:

Press any key...

Source: Delphi Corner Weblog: New: Velthuis.AutoConsole unit [WayBack]

via:

–jeroen

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, FastMM, Software Development | Leave a Comment »

If you were using Managed / IManaged in Spring4D, be aware they got renamed to Shared / IShared

Posted by jpluimers on 2017/05/17

Sometimes changes are breaking. In this case it’s a Spring4D change: https://bitbucket.org/sglienke/spring4d/commits/a7c9bc92f30f7b5ec71b4905c1f0d97339b3c807

It renames Managed / IManaged to Shared / IShared and introduces compatibility with weak references.

Together they are the Spring4D manifestation of smart pointers about which I wrote a few times before:

–jeroen

Posted in Delphi, Development, Software Development | 1 Comment »

On the design of the Delphi TStream classes – why aren’t they decomposed better?

Posted by jpluimers on 2017/05/16

Ever since I started using Delphi more than 2 decades ago, I wondered about the design of the TStream classes, especially as “stream16.zip” by Duncan Murdoch from the DOS Turbo Pascal era (which I copied in the below gist) showed how to perform composition using streams.

Even though by now there is TStreamReader/TStreamWriter allowing some level of composition, it always bugged me that large parts of the resource handling and component (de)serialisation is in it (centred around ReadComponentRes/WriteComponentRes in stead of fully being in TFiler/TReader/TWriter or even further decomposed), that you cannot interrogate capabilities (like supporting seeking, length, directionality and such) and that a lot of overloads (for instance Read/ReadBuffer/ReadBufferData/Write/WriteBuffer/WriteBufferData) are still based on signed or 32-bit types (though it has improved back in the early days they were even signed 16-bit types).

I’m not the only one who wonders about this: Faster FileStream with TBufferedFileStream • DelphiABall mentioned a new Berlin piece the TStream hierarchy and – being in the field a lot longer – Stefan Glienke rightly asked why the buffering isn’t done with the decorator pattern like JclStreams does, and Asbjørn Heid chimed in with a very dense version of more gripes.

Even TZCompressionStream/TZDecompressionStream (though relatively new) aren’t doing composition really well (by not abstracting the compression/decompression from the write-only/read-only behaviour).

Now that all key players from the early TStream design day and age have left the core Delphi R&D team, maybe one of them can step in and explain why.

–jeroen

via: [WayBack] I was wondering if the TBufferedFileStream (see https://delphiaball.co.uk/2016/04/29/faster-filestream-tbufferedfilestream/) would not have been implemented using the decorator pattern… – Stefan Glienke – Google+ -> https://github.com/project-jedi/jcl/blob/master/jcl/source/common/JclStreams.pas#L207

TJclBufferedStream = class(TJclStreamDecorator)

Read the rest of this entry »

Posted in Delphi, Development, Software Development | 2 Comments »

Applications that scale badely on High-DPI Displays: How to Stop the Madness – via: SQLServerCentral

Posted by jpluimers on 2017/05/10

Many applications still scale badly on High-DPI displays: dialogs way too small, icons you need a microscope for, etc.

SSMS in High-DPI Displays: How to Stop the Madness – SQLServerCentral explains a great trick that works for many applications, for intance:

The trick comes down to enabling the PreferExternalManifest registry setting and then create a manual manifest for the application that forces the application to use “bitmap scaling” by basically telling it does not support “XP style DPI scaling”.

You name manifest file named after the exe and stored it in the same directory as the exe.

After that, you also have to rename the exe to a temporary name and then back in order to refresh the cache.

A quote from the trick:

In Windows Vista, you had two possible ways of scaling applications: with the first one (the default) applications were instructed to scale their objects using the scaling factor imposed by the operating system. The results, depending on the quality of the application and the Windows version, could vary a lot. Some scaled correctly, some other look very similar to what we are seeing in SSMS, with some weird-looking GUIs. In Vista, this option was called “XP style DPI scaling”.

The second option, which you could activate by unchecking the “XP style” checkbox, involved drawing the graphical components of the GUI to an off-screen buffer and then drawing them back to the display, scaling the whole thing up to the screen resolution. This option is called “bitmap scaling” and the result is a perfectly laid out GUI.

In order to enable this option in Windows 10, you need to merge this key to your registry:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide]
"PreferExternalManifest"=dword:00000001

Then, the application has to be decorated with a manifest file that instructs Windows to disable DPI scaling and enable bitmap scaling, by declaring the application as DPI unaware. The manifest file has to be saved in the same folder as the executable (ssms.exe) and its name must be ssms.exe.manifest. In this case, for SSMS 2014, the file path is “C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\Ssms.exe.manifest”.

Paste this text inside the manifest file and save it in UTF8 encoding:


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*">
</assemblyIdentity>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="amd64" publicKeyToken="1fc8b3b9a1e18e3b">
</assemblyIdentity>
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"&gt;
<ms_windowsSettings:dpiAware xmlns:ms_windowsSettings="http://schemas.microsoft.com/SMI/2005/WindowsSettings">false</ms_windowsSettings:dpiAware&gt;
</asmv3:windowsSettings>
</asmv3:application>
</assembly>

This “Vista style” bitmap scaling is very similar to what Apple is doing on his Retina displays, except that Apple uses a different font rendering algorithm that looks better when scaled up. If you use this technique in Windows, ClearType rendering is performed on the off-screen buffer before upscaling, so the final result might look a bit blurry.The amount of blurriness you will see depends on the scale factor you set in the control panel or in the settings app in Windows 10. Needless to say that exact pixel scaling looks better, so prefer 200% over 225% or 250% scale factors, because there is no such thing as “half pixel”.

–jeroen

Source: SSMS in High-DPI Displays: How to Stop the Madness – SQLServerCentral

Posted in Database Development, Delphi, Development, Eclipse IDE, Encoding, Java, Java Platform, Software Development, SQL, SQL Server, SSMS SQL Server Management Studio, UTF-8, UTF8 | 4 Comments »

The Delphi Pipe – twm’s blog

Posted by jpluimers on 2017/05/09

The Delphi Pipe got revived:

The Delphi Pipe is an RSS feed that combines other RSS feeds from various Delphi blogs.

Source: [WayBackThe Delphi Pipe – twm’s blog

Of course there are also [WayBack] DelphiFeeds (which seems unmaintained, but a truckload of people have it in their RSS reader) and [WayBack] BeginEnd.net (slowly but steadily growing).

I wish there was an RSS reader that could filter out duplicate posts so I can just follow all three without reading duplicates.

Related:

–jeroen

Posted in Delphi, Development, Software Development | 3 Comments »

So how does a guy like myself get involved in contributing to GExperts?

Posted by jpluimers on 2017/05/04

Interesting question with some nice hints in the comments there:

[WayBack] So how does a guy like myself get involved in contributing to GExperts?I don’t have a lot a lot of time (or money), but I do have a desire to help. – Joe C. Hecht – Google+

–jeroen

Posted in Delphi, Development, GExperts, Software Development | Leave a Comment »

Windows 10 Creators update and Delphi debugging don’t go well…

Posted by jpluimers on 2017/05/02

Not sure what the cause and effect are, but various people are having issues running Delphi versions on Windows 10 Creators update. Debugging takes an exceptional long time to load the debuggee.

According to Marco Cantu, it is not limited to Delphi:

“It looks like a change in libraries code relocation, and it affects all debuggers — not just ours.”

A roll-back does make them work again but … there is only a very limited time frame to roll back from Windows 10 Creators update (think days, not weeks).

So for now: if you use Delphi do not install the Windows 10 Creators update unless you:

  • can revert back to a full system backup
  • can roll back in time

Examples:

The the last link cannot be archived, not is publicly accessible, I’ve quoted some parts:

The debugger goes haywire for everyone in our organization with Creators and Tokyo/Berlin. Reverting to Windows Anniversary brings back the sanity.

Debugger problems with Tokyo/Berlin and Creators:

  • App takes a long time to load with modules loading and unloading and re-loading many times
  • IDE freezes
  • Memory consumption of bds.exe explodes, sometimes (> 3GB)

I will attached before and after screenshots showing how modules load and unload and re-load with Windows 10 Creators.

I presume these problems have the same root cause(s) than those in https://forums.embarcadero.com/thread.jspa?messageID=884382

Note that Microsoft is still fledging out issues in Windows 10 Creators Upgrade despite pushing it to more and more Windows 10 machines: [WayBackWindows 10 Creators Update rollout: First phase update – Windows Experience BlogWindows Experience Blog

–jeroen

Read the rest of this entry »

Posted in Delphi, Development, Software Development | 12 Comments »

FMX.Dialogs basically blocks mixing VCL with FMX…

Posted by jpluimers on 2017/04/27

Nice find:

Stefan Glienke+4

Look into the initialization block of FMX.Dialogs. The call to ActivateClassGroup(TFmxObject); turns off all the TRegGroups that don’t contain at least one type that inherits from TFmxObject which also happens to be the group that you register your form class to. GetClass then ignores such groups.

I don’t have the slightest idea what the intention behind all that code is but it certainly is one of the reasons why you cannot mix FMX and VCL officially.

In response to:

I have an VCL application. I need to register some form classes at run time. This is done in the form’s unit implementation section :

Initialization

If GetClass(‘TfmConnectiondialog’) = Nil Then
Classes.RegisterClass(TfmConnectiondialog);

Suddenly my class wasn’t registered anymore. GetClass(‘TfmConnectiondialog’) was always nil and Classes.RegisterClass had no effects.

After some long search, I’ve found that I’ve inadvertently added an FMX.Forms in one of my unit. This was the culprit. Replacing FMX.Forms with VCL.Forms solved my problem.

Behaviour is really strange, why Classes.RegisterClass didn’t throw any exception ? Is this a “Bug” or is this “as expected” ?

–jeroen

Source: Hello, I have an VCL application. I need to register some form classes at ru… [WayBack]

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi XE7, Delphi XE8, Development, Software Development | 1 Comment »

When BRCC32 throws `Fatal error Illegal macro definition in command line or defines page.` in a DUnitX project

Posted by jpluimers on 2017/04/19

I had a Fatal error Illegal macro definition in command line or defines page. thrown by BRCC32.exe in one of my Delphi projects.

As cgrc.exe could build the .rc file [source in Russian; WayBack], I reproduced it from the console with an Empty.rc file that has no content. That way I could rule out file content: now it had to be command-line arguments which is a different cause than any of the search results I found before.

My project was based on one of the DUnitX test projects. It ran in Delphi XE8, but the Delphi version doesn’t matter as BRCC32 hasn’t been updated since 1999.

Further below are the failure/success examples; this went wrong:

  1. DUnitX uses the DUNITX-DEBUG define to enable debugging of DUnitX itself in DUnitX.inc which also supports the DUNITXDEBUG define in the same area.
  2. Delphi will translate a .RC file in a project into a BRCC32.exe call adding the project conditional defines and search paths
  3. BRCC32.exe doesn’t like hyphens in conditional defines throwing a non-descriptive error Fatal error Illegal macro definition in command line or defines page.

So either removing DUNITX-DEBUG or changing it into DUNITXDEBUG solves the problem. Hence my pull-request.

Read the rest of this entry »

Posted in Delphi, Development, Resource Files and Scripts (.res/.rc), Software Development, Windows Development | Leave a Comment »

Jan Barendregt is Looking for programmers to maintain existing Excel add-in software

Posted by jpluimers on 2017/04/18

Jan Barendregt is Looking for programmers to maintain existing Excel add-in software.

The reason is no fun (cancer without curative treatment and prognosis till death likely months).

Please follow-up on the forum if you can be of help: [WayBackEmbarcadero Discussion Forums: Looking for programmers to maintain existing Excel add-in software

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »