Search code examples
delphidelphi-2007

How to avoid System Exception when Runtime Themes are enabled?


I've just ran over something interesting, enabled runtime themes in Project Options and when a hint is shown on a TDCTree(from old Dream components, similar to TTreeView) and the mouse is moved over another node that should show hint, what I get is:

---------------------------
Debugger Fault Notification
---------------------------
Project DRIVE:\path\to\project\MyApp.exe faulted with message: 'system exception (code 0xc000041d) at 0x73c84cad'. Process Stopped. Use Step or Run to continue.
---------------------------
OK   
---------------------------

I believe that the same issue occurs within IDE, whenever I try to hover over items when adding items at design time.

If I disable runtime themes in Project Options, no exception, but it shows the "old style XP hint".

Application by itself raises an exception with Event Name "APPCRASH".

Seen quite a few issues related to "runtime themes", but haven't seen any way to avoid these issues without disabling them.

Operating system: Windows 7 x64

Delphi: 2007 with December 2007 and February 2008 updates installed

UPDATE 1:

One way to avoid the issue is:

Procedure TDCTreeToolTip.DoHideToolTip;
Begin
  Inherited;
  If FToolTipAdded Then
    if FTreeNode <> NIL then // fix
      DeleteToolTip(ToolTipID,FTreeNode.TreeView.Handle);
  FToolTipAdded:=False;
  FTreeNode:=Nil;
End;

in unit "dcntree.pas".

it seems that FTreeNode "somehow" gets NIL-ed before the call to DoHideToolTip, so the "System Exception is raised... it still doesn't explain why only when "Runtime themes are enabled"

I don't have time now to investigate this further, but the "trigger" is found, need to figure out "whom" is pulling it.


Solution

  • It seems that at least for now, only the following workaround can be used:

    Procedure TDCTreeToolTip.DoHideToolTip;
    Begin
      Inherited;
      If FToolTipAdded Then
        if FTreeNode <> NIL then // fix
          DeleteToolTip(ToolTipID,FTreeNode.TreeView.Handle);
      FToolTipAdded:=False;
      FTreeNode:=Nil;
    End;
    

    in unit "dcntree.pas".