Solved

open IE New window

Posted on 2001-08-05
6
640 Views
Last Modified: 2008-02-01
ShellExecute(handle, 'open', PChar(lblUrl.Caption), nil, nil, SW_SHOWNORMAL);

is the code I'me using, but this opens the page in a new IE window if there are none open and in an opened IE window if there was one open.
I want IE to ALWAYS open a NEW window and show this page.
how can I do this?
0
Comment
Question by:pin_plunder
6 Comments
 
LVL 1

Accepted Solution

by:
rootnash earned 25 total points
ID: 6354665
just in case u want a working (but longer) code, try this:

--------------

unit linktoweb;

interface

uses Windows, Dialogs, comobj;

procedure OpenIE(aURL: string);

implementation

function RegisterServiceProcess (dwProcessID, dwType: DWord) : DWord; stdcall; external 'KERNEL32.DLL';

procedure OpenIE(aURL: string);
var
  IE        : Variant;
  WinHanlde : HWnd;
begin
  if( VarIsEmpty(IE) )then
  begin
    IE := CreateOleObject('InternetExplorer.Application');
    IE.Visible := true;
    IE.Navigate(aURL);
  end
  else
  begin
    WinHanlde := FindWIndow('IEFrame', nil);
    if (0 <> WinHanlde) then
    begin
      IE.Navigate(aURL);
      SetForegroundWindow(WinHanlde);
    end
    else
      ShowMessage('Can''t open IE !');
  end;
end;
end.


and call for e.g.

  OpenIE('http://www.yoururl.com');


roots
0
 

Expert Comment

by:BryGuy
ID: 6356431
Heres a procedure I wrote to replace ShellExecute to always open in a new window:

procedure PseudoShellExecuteNewWindow (const Path : string);
var
  StartInfo     : TStartupInfo;
  ProcInfo      : TProcessInformation;
  ExePath       : array [0..MAX_PATH - 1] of char;
  FullExe       : string;
begin
  FillChar (StartInfo, SizeOf(StartInfo), 0);
  FillChar (ProcInfo, SizeOf(ProcInfo), 0);
  StartInfo.cb := SizeOf(StartInfo);

  //
  // Locate the associated executable - if none is found, default to
  // notepad
  //
  if FindExecutable (PChar(Path), nil, ExePath) > 32 then
    FullExe := string(ExePath) + ' "' + Path + '"'
  else
    FullExe := 'notepad ' + Path;

  CreateProcess (nil, PChar(FullExe), nil, nil, FALSE, DETACHED_PROCESS,
    nil, nil, StartInfo, ProcInfo);
end;


If you are tarteting IE only though, I would go ahead and use OLE.

I'd do something like:

procedure OpenInIeWin (const Url : string);
var
  Ie  : Variant;
  UrlVar,
  Flags,
  Frame,
  Post,
  Headers : OleVariant;
begin
  UrlVar := Url;
  Flags := $1;
  Frame := '_BLANK';
  try
    Ie := GetActiveOleObject ('InternetExplorer.Application');
  except
    try
      Ie := CreateOleObject ('InternetExplorer.Application');
    except
      Exit;
    end;
  end;
  Sleep (300); // possiblly fix the "server not available" error.
  Ie.Navigate2 (UrlVar, Flags, Frame, Post, Headers);
end;

Bryan Ashby
0
 
LVL 2

Expert Comment

by:Tasomia
ID: 6357132
uses
  ShellAPI, Registry;

procedure OpenURL(Url : string);
var
  ts :string;
begin
  with TRegistry.Create do try
    rootkey:= HKEY_CLASSES_ROOT;
    OpenKey('\htmlfile\shell\open\command',false);
    try
      ts:= ReadString('');
    except
      ts:= '';
    end;
    CloseKey;
  finally
    Free;
  end;
  if ts = '' then Exit;
  // remove quotes and commandline parameters
  ts:= Copy(ts,Pos('"',ts)+1,Length(ts));
  ts:= Copy(ts,1,Pos('"',ts)-1);
  ShellExecute(0,'open',pchar(ts),pchar(url),nil,sw_show);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  OpenURL('http://www.experts-exchange.com');
end;
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:pin_plunder
ID: 6358025
rootnash the points are already yours, but ...

is there any way to do the same for netscape?

thanks.

0
 
LVL 1

Expert Comment

by:rootnash
ID: 6358231
sorry, i tried tweaking it but it does not work in netscape. :(
0
 

Author Comment

by:pin_plunder
ID: 6359932
thanks a lot for your help
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Intraweb submit form as a POST request 4 229
Delphi 2010 Export to pdf 2 250
Convert Jpg /PNG To GIF 5 102
oracle global variables 4 51
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now