Question

In Delphi XE UxTheme unit there is the following declaration

function DrawThemeTextEx(hTheme: HTHEME; hdc: HDC; iPartId: Integer;  iStateId: Integer;
  pszText: LPCWSTR; cchText: Integer; dwTextFlags: DWORD; pRect: PRect;
  var pOptions: TDTTOpts): HResult; stdcall; 
  external themelib name 'DrawThemeTextEx' delayed;

My Windows XP Professional with SP3 does not have such function in the uxtheme.dll (checked with dllexp.exe from http://www.nirsoft.net/utils/dll_export_viewer.html)

It seems like my application does delayed loading of the procedure and fails runtime with the following error:

Project mtgstudio.exe raised exception class EExternalException 
with message 'External exception C0FB007F'.

The issue was encountered in JVCL as well but resolved there as per http://andy.jgknet.de/blog/2009/09/once-upon-a-delayed-jvcl-time/

I need UxTheme fixed because they are used by the DevExpress components as well.

Is there a way to patch/fix the UxTheme.pas DrawThemeTextEx declaration to be non-delayed?

Was it helpful?

Solution

The fundamental problem is that this API was introduced in Vista and is not available in XP.

The whole point of the delayed keyword is to allow functions like this to be made available easily to developers who want to take advantage of newer API functions. But to do so the developer typically must also provide fallback implementations for older OS versions, which DevExpress appear to have failed to do.

The bug is therefore not in UxTheme.pas, but in the DevExpress component that calls an API that is not implemented on the platform. The fix is to re-work the DevExpress code to avoid calling this API on XP.

I suggest you contact DevExpress who quite probably already have a fix in their latest versions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top