* * *

Author Topic: Is it possible to remove Script and FontStyle comboboxes from tFontDialog?  (Read 1325 times)

CM630

  • Hero Member
  • *****
  • Posts: 817
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/

Is it possible to remove Script and FontStyle selection from tFontDialog in Windows (7)?
I added fdNoStyleSel to the options of tFontDialog, but the style combobox is still shown.
What is worse, it selects nothing by default and an error message is generated when OK is clicked.
« Last Edit: October 13, 2017, 08:46:42 am by CM630 »
Лазар 1,8,0;W7 64bit or XP 32bit;FPC3,0,4;rev 56594

CM630

  • Hero Member
  • *****
  • Posts: 817
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Anybody out there?
Лазар 1,8,0;W7 64bit or XP 32bit;FPC3,0,4;rev 56594

Thaddy

  • Hero Member
  • *****
  • Posts: 6338
You can't demote any published properties. That is:unless you write a proxy for it.
I am enjoining wine, not whine....

GetMem

  • Hero Member
  • *****
  • Posts: 3082
Actually is quite trivial on windows. Drop a TTimer to your form, set Interval property to 100, Enabled property to false, then:
Code: Pascal  [Select]
  1. uses windows;
  2.  
  3. procedure TForm1.Button1Click(Sender: TObject);
  4. begin
  5.   FontDialog1.Execute;
  6. end;
  7.  
  8. procedure TForm1.FontDialog1Show(Sender: TObject);
  9. begin
  10.   tmWait.Enabled := True;
  11. end;
  12.  
  13. procedure TForm1.tmWaitTimer(Sender: TObject);
  14. var
  15.   wHandle: THandle;
  16. begin
  17.   tmWait.Enabled := False;
  18.   wHandle := GetActiveWindow;
  19.   EnableWindow(GetDlgItem(wHandle, $0471), False);
  20.   EnableWindow(GetDlgItem(wHandle, $0474), False);
  21. end;

Thaddy

  • Hero Member
  • *****
  • Posts: 6338
@GetMem: are you seriously suggesting to use a timer to hide properties from the object inspector? I mean, really?  :D
I am enjoining wine, not whine....

GetMem

  • Hero Member
  • *****
  • Posts: 3082
@GetMem: are you seriously suggesting to use a timer to hide properties from the object inspector? I mean, really?  :D
No. I just gave him a quick solution to disable those unwanted section from the FontDialog on runtime(see attachment). The timer is only need because FontDialog.Handle is always 0. This is a bug, in delphi there is a valid window handle after you launch the dialog.

CM630

  • Hero Member
  • *****
  • Posts: 817
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Thanks,
It seems I will have to make my own selection dialog.
But meanwhile, I could use @GetMem's solution. As he mentioned that it is a bug, I assume it will be fixed one day. And I guess it won't work on anything but Windows.
Лазар 1,8,0;W7 64bit or XP 32bit;FPC3,0,4;rev 56594

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus