Author: Igor Siticov
How to change text like "File name:", "File Type" and buttons' text in standard
Windows dialogs?
Answer:
Some times we need to replace some text or something other in standard Windows
Open/Save dialogs. Unfortunately, Delphi's dialogs components don't provide the
access to all controls placed on Windows common dialogs. But we can perform this
using Windows API.
Example below demonstrates the changing all embedded text controls in Open dialog.
First, we need to determine identifiers of dialog's controls, they are following:
1 const
2 // LB_FOLDERS_ID = 65535;
3 LB_FILETYPES_ID = 1089; // "File types:" label
4 LB_FILENAME_ID = 1090; // "File name:" label
5 LB_DRIVES_ID = 1091; // "Look in:" label
6
7 Second, we need to send message to dialog window for changing necessary controls,
8 something like following:
9
10 procedure TForm1.OpenDialog1Show(Sender: TObject);
11 const
12 // LB_FOLDERS_ID = 65535;
13 LB_FILETYPES_ID = 1089;
14 LB_FILENAME_ID = 1090;
15 LB_DRIVES_ID = 1091;
16 Str1 = 'Four';
17 Str2 = 'Five';
18 Str3 = 'One';
19 Str4 = 'Two';
20 Str5 = 'Three';
21 begin
22 SendMessage(GetParent(OpenDialog1.Handle), CDM_SETCONTROLTEXT, IDOK,
23 LongInt(Pchar(Str1)));
24 SendMessage(GetParent(OpenDialog1.Handle), CDM_SETCONTROLTEXT, IDCANCEL,
25 LongInt(Pchar(Str2)));
26 SendMessage(GetParent(OpenDialog1.Handle), CDM_SETCONTROLTEXT, LB_FILETYPES_ID,
27 LongInt(Pchar(Str3)));
28 SendMessage(GetParent(OpenDialog1.Handle), CDM_SETCONTROLTEXT, LB_FILENAME_ID,
29 LongInt(Pchar(Str4)));
30 SendMessage(GetParent(OpenDialog1.Handle), CDM_SETCONTROLTEXT, LB_DRIVES_ID,
31 LongInt(Pchar(Str5)));
32 end;
|