Mega Code Archive

 
Categories / Delphi / Examples
 

Internetexplorerwindow

ShellExecute never creates a new browser window, it simply grabs the first one it finds. If you do this: ShellExecute(Handle, 'OPEN', pchar(strBrowser), pchar(strURL), nil, SW_SHOW); it will open up a new window. But the trick is knowing the default browser. Here's how that can be done: // ShellFindExecutable is from Petr Vones (Team JEDI), this fixes a problem with FindExecutable: function ShellFindExecutable(const FileName, DefaultDir: string): string; var Res: HINST; Buffer: array[0..MAX_PATH] of Char; P: PChar; begin FillChar(Buffer, SizeOf(Buffer), #0); if DefaultDir = '' then P := nil else P := PChar(DefaultDir); Res := FindExecutable(PChar(FileName), P, Buffer); if Res > 32 then begin P := Buffer; while PWord(P)^ <> 0 do begin if P^ = #0 then // FindExecutable replaces #32 with #0 P^ := #32; Inc(P); end; Result := Buffer; end else Result := ''; end; procedure TForm1.Button1Click(Sender: TObject); var strBrowser, strURL: String; begin strURL := 'http://www.torry.ru'; strBrowser := ShellFindExecutable('*.htm', ''); // If no default browser is returned (for whatever reason) try and run it normally.. If Length(strBrowser) = 0 then begin strBrowser := strURL; strURL := ''; end; ShellExecute(Handle, 'OPEN', pchar(strBrowser), pchar(strURL), nil, SW_SHOW); end; Ed At 10:27 AM 03/01/01, you wrote: >Look up ShellExecute. > >Example for launching the Yahoo site in the default browser... > > ShellExecute(0, 'open', 'http://www.yahoo.com', '', '', SW_SHOW); > >With Regards, > >Phillip H. Blanton > > >-----Original Message----- >From: Jesper Stenlund [mailto:jest02@handelsbanken.se] >Sent: Wednesday, February 28, 2001 9:22 AM >To: delphi@elists.org >Subject: Create new Internet Explorer Window > > >Is there a way to create a new Internet Explorer from inside a Delphi >application? >I've been looking for some Windows API but I havent found any. > >I have a label which contains a web-address and when the user clicks it I >want to start a new Internet Explorer window and load the site. That is. If >the user clicks the button 3 times, then I want a >new window for each click. > >How do I do this?? > >//Jesper Stenlund >jest02@handelsbanken.se