| 
 
 
{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;
 
 
 
 // to Enumerate Control - IDs:
 
 function EnumProc(wnd: HWND; Lines: TStrings): BOOL; stdcall;
 var
 buf, Caption: array [0..255] of char;
 begin
 Result := True;
 GetClassname(wnd, buf, 256);
 GetWindowText(wnd, Caption, 256);
 Lines.Add(Format('ID: %d, class: %s, caption: %s',
 [GetDlgCtrlID(wnd), buf, Caption]));
 end;
 
 procedure TForm1.PrintDialog1Show(Sender: TObject);
 begin
 memo1.Clear;
 EnumChildWindows(Printdialog1.Handle, @EnumProc, Integer(memo1.Lines));
 end;
 
 
 
   
   
    | 
         
          | Bewerten Sie diesen Tipp: |  |  |