Recent

Author Topic: Can't set title and PreviewText in FontDialog  (Read 1741 times)

jamie

  • Hero Member
  • *****
  • Posts: 5182
Re: Can't set title and PreviewText in FontDialog
« Reply #15 on: February 07, 2023, 12:56:39 am »
Yeah, its the same thing.

The Dialog callback is structured the same way.

Its in the win32WSDialogs.

"FontDialogCallBack" to be exact.

The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 5182
Re: Can't set title and PreviewText in FontDialog
« Reply #16 on: February 07, 2023, 01:29:44 am »
This is the problem here.

at some point in history, someone decided the callback feature causes issues and the callback is only enabled when the ApplyButton is selected in the options.
Code: Pascal  [Select][+][-]
  1.  //setting CF_ENABLEHOOK shows an oldstyle dialog, unless lpTemplateName is set
  2.       //and a template is linked in as a resource,
  3.       //this also requires additional flas set:
  4.       //https://msdn.microsoft.com/en-us/library/windows/desktop/ms646832(v=vs.85).aspx
  5.       if (fdApplyButton in Options) then
  6.       begin
  7.         Flags := Flags or CF_ENABLEHOOK;
  8.         lpfnHook := @FontDialogCallBack;
  9.         lCustData := PtrInt(@ACommonDialog);
  10.       end;                                            
  11.  

 The fix I have can only work if this hook is enabled all the time, not just the applyBUtton.

Tell me what you think, if you enable the applybutton, does it change the view as it claims?
does not here.

--
 In the fontDialogCallBack, this is changed;

Code: Pascal  [Select][+][-]
  1.   case uMsg of
  2.     WM_INITDIALOG:
  3.     begin
  4.       //debugln(['FontDialogCallBack: WM_INITDIALOG']);
  5.       //debugln(['  PChooseFontW(LParam)^.lCustData=',IntToHex(PChooseFontW(LParam)^.lCustData,8)]);
  6.       PtrInt(Dlg) := PChooseFontW(LParam)^.lCustData;
  7.       If (Dlg <> Nil)and (Dlg^.Title <> '') THen SetWindowText(Wnd,Pchar(Dlg^.Title));//jp
  8.     end;
  9.     WM_COMMAND:            
  10.  

The line where my john handcock is!

« Last Edit: February 07, 2023, 01:36:31 am by jamie »
The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 5182
Re: Can't set title and PreviewText in FontDialog
« Reply #17 on: February 07, 2023, 02:21:56 am »
I now see the difference between them, it shortens the dialog and doesn't give you the extra options to select more fonts.

 This is very strange indeed. You would of thought MS would get their act together by now.

The only true wisdom is knowing you know nothing

HexLaden

  • Newbie
  • Posts: 5
Re: Can't set title and PreviewText in FontDialog
« Reply #18 on: February 07, 2023, 11:48:16 am »
Thanks, KodeZwerg for the suggestion and tip. For this project in particular I'll probably follow that way. For a general purpose, system's dialog is the adequate choice. Jamie's patch would be welcome.

jamie

  • Hero Member
  • *****
  • Posts: 5182
Re: Can't set title and PreviewText in FontDialog
« Reply #19 on: February 08, 2023, 03:19:38 am »
it appears it is possible to define the Sample window along with the Caption of the dialog.

But as indicated before, doing so takes on older version of the Dialog box.

In any case, I was able to use FindWindowEx within the initiation of the dialog box to locate the control that houses the sample text and it happens to be a "STATIC" text box.

 I don't know how reliable this would be however.... But you can redefine the text contents at that point.

EDIT:

  I think this is a moot point because although i got the sample window to show the preview text it seems when you click around in the box the static text gets replaced with the original text and what this means you would have to answer to the BN_CLICKS, to keep refreshing it.
  It can be done but really.

  The Caption/Title seems to be ok however. but still, only shows in the old style viewing.
« Last Edit: February 08, 2023, 03:37:04 am by jamie »
The only true wisdom is knowing you know nothing

GetMem

  • Hero Member
  • *****
  • Posts: 4026
Re: Can't set title and PreviewText in FontDialog
« Reply #20 on: February 08, 2023, 06:34:17 am »
@jamie

It's not worth the effort, I came to the same conclusion in post 9. If somebody really wants a custom FondDialog, better build one from scratch. It shouldn't take longer then 20-30 minutes.

KodeZwerg

  • Hero Member
  • *****
  • Posts: 1188
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Can't set title and PreviewText in FontDialog
« Reply #21 on: February 08, 2023, 03:11:48 pm »
I put something together, ready to use but currently not as a drop-in replacement.

Feel free to use it as a starting point and modify however you like.
« Last Edit: Tomorrow at 31:76:97 by KodeZwerg »

 

TinyPortal © 2005-2018