function GetGlobalFocus: THandle;
var
GUIThreadInfo: TGUIThreadInfo;
begin
GUIThreadInfo.cbSize := SizeOf(TGUIThreadInfo);
if GetGUIThreadInfo(0, GUIThreadInfo) then
Result := GUIThreadInfo.hwndFocus
else
Result := 0;
end;
procedure TForm1.test;
var
h,hedit: hwnd;
s: pchar;
str : string;
debut,fin:integer;
begin
hedit := GetGlobalFocus;
str := 'test';
SendMessage(hedit, WM_SETTEXT, 0,integer(Str));
end;
function GetRunningInstance: IWebBrowser2;
var
ShWindows: IShellWindows;
i: integer;
begin
ShWindows := CoShellWindows.Create;
for i := 0 to ShWindows.Count - 1 do
begin
Result := ShWindows.Item(i) as IWebBrowser2;
if Result.LocationURL =
'http://sourceforge.net/projects/extgraph' then
Break;
end;
end;
function GetActiveIEBrowser: IWebBrowser2;
var
shellWindows: IShellWindows;
i: Integer;
webBrowser: IWebBrowser2;
begin
Result := nil;
shellWindows:= CoShellWindows.Create;
for i:=0 to shellWindows.Count -1 do
if Supports(shellWindows.Item(i), IWebBrowser2, webBrowser) then begin
// Separates IE from Explorer
if AnsiLowerCase(ExtractFileName(webBrowser.FullName)) = 'iexplore.exe' then begin
Result:= webBrowser;
Break;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
brwsr: IWebBrowser2;
begin
brwsr := GetActiveIEBrowser;
brwsr.Navigate('http://sourceforge.net/projects/extgraph', emptyparam,emptyparam,emptyparam,emptyparam);
end;
Users browsing this forum: No registered users and 1 guest