Search code examples
delphidelphi-7

Delphi7 Font dialog outdated on Windows 7


  • Left - dialog of Win7 of modern apps
  • Right - dialog of Win7 of my Delphi7 app

How to make my dlg modern? (How to patch Delphi7)

Font


Solution

  • The offending part for the new dialog to be shown, for Windows 7 and later, is the callback. Here's a quote from "Font Dialog Box":

    If you enable a hook procedure without creating a custom template, the default ChooseFont template for earlier Windows versions will be loaded.

    You can eliminate the hook procedure by modifying a copy of "dialogs.pas" and putting it in your source folder for the current project.

    function TFontDialog.Execute: Boolean;
      ...
    //    Flags := Devices[FDevice] or (CF_INITTOLOGFONTSTRUCT or CF_ENABLEHOOK);
        Flags := Devices[FDevice] or CF_INITTOLOGFONTSTRUCT;
      ...
    //    hWndOwner := Application.Handle;
        hWndOwner := GetActiveWindow;
      ...
    

    The latter modification is for displaying the dialog in a reasonable place. Once the hook procedure is disabled, the VCL will not be able to center the dialog. You will also lose "Apply" button functionality and other events (OnShow/Close).