Suppose you have Form1 with PrintDialog1 (TPrintDialog) component and would like to change (localize) its "Print" button title from default '&Print' to something else...
The code below will give you the ID's of all the controls on a PrintDialog (or any other standard Dialog you want):
ps. make sure you have Button1 (TButton), Memo1 (TMemo) and PrintDialog1 (TPrintDialog) on a Form1 (TForm) ...
~~~~~~~~~~~~~~~~~~~~~~~~~
//handles Button1 OnClick
procedure TForm1.Button1Click(Sender: TObject) ;
begin
with PrintDialog1 do Execute;
end;
//handles PrintDialog1 OnShow
procedure TForm1.PrintDialog1Show(Sender: TObject) ;
begin
Memo1.clear;
EnumChildWindows(PrintDialog1.Handle,
@EnumProc,
Integer(Memo1.Lines)) ;
end;
//the callback function
function EnumProc(AHandle: HWND;
Lines: TStrings): boolean; stdcall;
var
buf, Caption: Array [0..255] of char;
begin
result := true;
GetClassname(AHandle, buf, 256) ;
GetWindowText(AHandle, Caption, 256) ;
Lines.add(Format('ID: %d, class: %s, caption: %s',
[GetDlgCtrlID(AHandle), buf, Caption])) ;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~
Related:
more about callbacks
about common dialogs
How to change a button title on an Open dialog
Delphi tips navigator:
» How to get the current line and column from a Memo
« Positioning the caret in a line in a Memo or RichEdit

