{
Sometimes 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.
The Example below demonstrates the changing all embedded
text controls in Open dialog.
Das Beispiel zeigt, wie man den Text in einem TOpenDialog
durch eigenen ersetzen kann.
}
uses commdlg;
{...}
procedure TForm1.OpenDialog1Show(Sender: TObject);
{First, we need to determine identifiers of dialog's
controls, they are following:}
const
LB_FILETYPES_ID = 1089; // "File types:" label
LB_FILENAME_ID = 1090; // "File name:" label
LB_DRIVES_ID = 1091; // "Look in:" label
Str1 = 'Four';
Str2 = 'Five';
Str3 = 'One';
Str4 = 'Two';
Str5 = 'Three';
var
hOpenDialog: HWND;
begin
hOpenDialog := GetParent(OpenDialog1.Handle);
SendMessage(hOpenDialog, CDM_SETCONTROLTEXT, idOk, Longint(PChar(Str1)));
SendMessage(hOpenDialog, CDM_SETCONTROLTEXT, idCancel, Longint(PChar(Str2)));
SendMessage(hOpenDialog, CDM_SETCONTROLTEXT, LB_FILETYPES_ID, Longint(PChar(Str3)));
SendMessage(hOpenDialog, CDM_SETCONTROLTEXT, LB_FILENAME_ID, Longint(PChar(Str4)));
SendMessage(hOpenDialog, CDM_SETCONTROLTEXT, LB_DRIVES_ID, Longint(PChar(Str5)));
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
// ...
end;
end;
// for the Print - Dialog:
procedure TForm1.PrintDialog1Show(Sender: TObject);
begin
SetWindowText(GetDlgItem(PrintDialog1.Handle, idOk), '&&OK2');
SetWindowText(GetDlgItem(PrintDialog1.Handle, idCancel), '&Cancel2');
SetWindowText(GetDlgItem(PrintDialog1.Handle, 1025), '&Properties2');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if PrintDialog1.Execute then
begin
// ...
end;
end;