// **
type
Tctrls =
Array of HWND;
// **
function SaveDlgEnumProc(win: HWND; ctrls: Pointer): BOOL;
stdcall;
var
s:
string;
buf:
array [0 .. 255]
of char;
begin
Result := True;
GetClassName(win, buf, 256);
s := buf;
if s = '
TButton'
then // **
begin
SendMessage(win, WM_GETTEXT, 256, Integer(@buf));
s := buf;
if s = '
Speichern'
then
Tctrls(ctrls^)[1] := win;
end
else if s = '
TEdit'
then // **
begin
Tctrls(ctrls^)[0] := win;
end;
end;
procedure TForm3.Button1Click(Sender: TObject);
begin
Test(
handle, '
test')
end;
procedure TForm3.Button3Click(Sender: TObject);
begin
Showmessage(TButton(Sender).Caption);
end;
PROCEDURE TForm3.Test(win: HWND;
const dsn:
string);
var
ctrls: Tctrls;
// **
begin
SetLength(ctrls, 2);
ctrls[0] := 0;
// Edit
ctrls[1] := 0;
// Speichern-Button
EnumChildWindows(win, @SaveDlgEnumProc, NativeInt(@ctrls));
// **
if ctrls[0] <> 0
then
begin
SendMessage(ctrls[0], WM_SETTEXT, 0, Integer(PChar(dsn)));
if ctrls[1] <> 0
then
SendMessage(ctrls[1], BM_Click, 0, 0);
end;
end;