whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

37 Visitors Online


 
...Change the Standard Windows dialogs?
Autor: Igor Siticov
Homepage: http://www.sicomponents.com
[ Print tip ]  

Tip Rating (4):  
     


{
  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;


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners