Prog1020
Prog1020

Reputation: 4781

Delphi7 Font dialog outdated on Windows 7

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

Font

Upvotes: 1

Views: 951

Answers (1)

Sertac Akyuz
Sertac Akyuz

Reputation: 54822

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).

Upvotes: 6

Related Questions