|
Here is another example of this that I use to be able to paste something into
an edit box in another program below my program. If this is not used, the
program below will not come into focus after your program is minimized or
closed.
Place this in the last window in your program to be displayed before going to
the program's window below it (for pasteing, etc).
//FormActivate
procedure TFormMD5.FormActivate(Sender: TObject);
begin
Th1 := GetCurrentThreadId;
Th2 := GetWindowThreadProcessId(GetForegroundWindow, nil);
AttachThreadInput(Th2, Th1, true);
Application.Restore; //if previous Application.Minimize;
try
SetForegroundWindow(Application.Handle);
finally
AttachThreadInput(Th2, Th1, false);
end;
end;
|