Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to hide the font size list in a TFontDialog Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
21-Oct-02
Category
Dialogs
Language
Delphi 2.x
Views
150
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

How can I completely hide the fontsize selection combobox in the font dialog? I 
have manipulated some properties of the fontdialog but the combobox where you pick 
the font size is always visible. Furthermore, I want to keep the preview of the 
font but with a fixed font size.

Answer:

Set the fdLimitSize option in the dialogs Options to true and specifiy the same 
size for the MinFontsize and Maxfontsize property.

Hide the font size list. This requires a bit of spy work to determine the control 
IDs in the dialog. Once this has been done you can attach a handler to the 
fontdialogs Onshow handler:

1   procedure TForm1.FontDialog1Show(Sender: TObject);
2   begin
3     EnableWindow(GetDlgItem(fontdialog1.handle, 1138), false);
4     EnableWindow(GetDlgItem(fontdialog1.handle, 1090), false);
5     ShowWindow(GetDlgItem(fontdialog1.handle, 1138), SW_HIDE);
6     ShowWindow(GetDlgItem(fontdialog1.handle, 1090), SW_HIDE);
7   end;


1138 is the handle of the font size combobox (it is a combobox, despite looking 
like an edit with a list box below it), 1090 the text label above it. Without 
disabling the controls the accelerator for the size box will close the dialog for 
some reason.

For the future: the spy works done here was performed this way:
8   
9   procedure TForm1.Button1Click(Sender: TObject);
10  begin
11    fontdialog1.execute;
12  end;
13  
14  function EnumProc(wnd: HWND; lines: TStrings): BOOL; stdcall;
15  var
16    buf, caption: array[0..255] of char;
17  begin
18    result := True;
19    GetClassname(wnd, buf, 256);
20    GetWindowText(wnd, caption, 256);
21    lines.add(format('ID: %d, class: %s, caption: %s', [GetDlgCtrlID(wnd), buf,
22      caption]));
23  end;
24  
25  procedure TForm1.FontDialog1Show(Sender: TObject);
26  begin
27    memo1.clear;
28    EnumChildWindows(fontdialog1.handle, @EnumProc, integer(memo1.lines));
29  end;
30  
31  {Output in memo:
32  
33  ID: 1088, class: Static, caption: Schrift&art:
34  ID: 1136, class: ComboBox, caption: MS Sans Serif
35  ID: 1000, class: ComboLBox, caption:
36  ID: 1001, class: Edit, caption: MS Sans Serif
37  ID: 1089, class: Static, caption: &Schriftschnitt:
38  ID: 1137, class: ComboBox, caption: Standard
39  ID: 1000, class: ComboLBox, caption:
40  ID: 1001, class: Edit, caption: Standard
41  ID: 1090, class: Static, caption: &Grad:
42  ID: 1138, class: ComboBox, caption: 8
43  ID: 1000, class: ComboLBox, caption:
44  ID: 1001, class: Edit, caption: 8
45  ID: 1, class: Button, caption: OK
46  ID: 2, class: Button, caption: Abbrechen
47  ID: 1026, class: Button, caption: Ü&bernehmen
48  ID: 1038, class: Button, caption: &Hilfe
49  ID: 1072, class: Button, caption: Darstellung
50  ID: 1040, class: Button, caption: &Durchgestrichen
51  ID: 1041, class: Button, caption: &Unterstrichen
52  ID: 1091, class: Static, caption: &Farbe:
53  ID: 1139, class: ComboBox, caption: Schwarz
54  ID: 1073, class: Button, caption: Muster
55  ID: 1092, class: Static, caption: AaBbYyZz
56  ID: 1093, class: Static, caption:
57  ID: 1094, class: Static, caption: S&chrift:
58  ID: 1140, class: ComboBox, caption: Western
59  }


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC