Once upon a delayed JVCL time…

By | September 5, 2009

Once upon a time there was a nice and supportive DrawThemeTextEx function that was responsible for the country borders near the UxTheme.pas city. This function didn’t allow to communicate with citizens from the countries Windows 2000 and XP. A nice and smart guy who had to write a function that must communicate with countries introduced a new function called DrawGlassableText to JvThemes.pas, a neighbor town of UxTheme.pas. That new function had to communicate across the border and because it was near the UxThemes.pas city he thought, because he was smart, that he doesn’t need to check for the target country because the nice and supportive DrawThemeTextEx function returned E_NOTIMPL if it had to communicate with countries other than Vista and Windows 7. So he checked for E_NOTIMPL instead of the target country. All was fine during the reign of Delphi 6 to 2009.

But then an evil new directive that controlled the borders came along with the new and fancy Delphi 2010 administration. This new directive called itself delayed. It took over the nice and supportive DrawThemeTextEx function and turned it into an evil external exception throwing function. The nice and smart guy had long forgotten that he once wrote the DrawGlassableText function and because everyone was communicating with Vista and Windows 7 the now evil external exception throwing function hadn’t played out its evil cards.

But then somebody came along and wanted to communicate with the Windows XP country. But the now evil external exception throwing function DrawThemeTextEx didn’t let him open a channel across the border and threw external exceptions after him until he left. This person then went to the administration of the town JvThemes.pas and told them the story about the evil external exception throwing function. They informed the nice and smart guy who had a look at his DrawGlassableText function and he thought, because he was smart, how could that code had worked anyway. It should have also failed under the reign of Delphi 6 to 2009 but it didn’t.

So what was different after the new fancy Delphi 2010 administration took over the country. He needed some time for his research and he found the reason. The evil delayed directive changed the nice and supportive DrawThemeTextEx function into an evil external exception throwing function. He then changed the DrawGlassableText function to check for the target country. But it was too late. The administration of JvThemes.pas had already sold the broken DrawGlassableText function to other cities.


In other words: The new Delphi 2010 delayed directive that allows a delayed external function binding breaks the JVCL 3.38.

There are 4 possible solutions:

  1. If you have used my binary JVCL installer, then redownload it. I have updated the download to contain the fix for this bug. Only the JVCL installer is new. The JCL isn’t affected by this bug.

    JVCL Binary Installer 3.38.0.1

  2. If you have installed the JVCL 3.38 source installation then you can replace the jvcl\run\JvThemes.pas by the updated JvThemes.pas and start the “jvcl\makemodified.bat” to recompile the JVCL.
  3. If you have installed a daily build then download a new daily build.
  4. If you have installed an SVN revision then update your SVN.

7 thoughts on “Once upon a delayed JVCL time…

  1. M J Marshall

    The “delayed” keyword is of questionable benefit in my opinion – any place you would use it would still require (in any properly-written application/library) some kind of fall-back processing to trap any exceptions, which could be avoided by using the standard LoadLibrary/GetProcAddress method for API calling. Given that delayed only works with D2010+, and that exception handling is a lot more expensive than LoadLibrary/GetProcAddress, we’re back to the question:
    What exactly is delayed good for?

  2. Moritz Beutel

    > What exactly is delayed good for?

    It allows Embarcadero to reduce the amount of boilerplate GetModuleHandle/GetProcAddress code in the VCL.

  3. Mark Edington

    Hey, that story has a really familiar sound to it….

    😉

Comments are closed.