Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Opening URLs

27 views
Skip to first unread message

Liz

unread,
Jan 9, 2005, 8:40:24 AM1/9/05
to
Hi,

As we all know you can do shellexecute(handle, 'open',
'http://somewebsite.com', Nil, Nil, 0)

one thing Im curious about is some apps manage to say open in new
window, or reuse current. How can you send that ? Surely it varies with
the browser? If not, how can I trigger this??

Avatar Zondertau

unread,
Jan 9, 2005, 9:11:54 AM1/9/05
to

For Internet Explorer this is a per-user setting stored. It can be
found at the advanced settings under "browing" and is stored in the
registry in this key:

HKEY_CURRENT_USER\Software\Microsoft\Internet
Explorer\Main\AllowWindowReuse

I guess such a setting also exists for other browsers.

Brian Cook

unread,
Jan 9, 2005, 1:57:01 PM1/9/05
to
> Hi,

Greetings.

When you say "trigger this", which are you trying to do? Open in a new
window or reuse the current window?

- Brian

Douglas J. Horton

unread,
Jan 9, 2005, 1:49:21 PM1/9/05
to
"Avatar Zondertau" <avatarz...@hotmail.com> wrote in message
news:41e13baa$1...@newsgroups.borland.com...

>> one thing Im curious about is some apps manage to say open in new
>> window, or reuse current. How can you send that ? Surely it varies
>> with the browser? If not, how can I trigger this??
>
> For Internet Explorer this is a per-user setting stored.

I use IE6 and have the Allow Windows Reuse option set to true. Sometimes,
however, when I am clicking on a link within an e-mail (Outlook Express) I
have a new browser window open instead of using the old browser window.
Sometimes it won't happen, sometimes it will. There does not appear to be
any rhyme or reason why it happens, it just does.

--Doug


Liz

unread,
Jan 9, 2005, 2:38:27 PM1/9/05
to
Ben Hochstrasser wrote:

> I want it in a new tab... ;-)

That too, I just wondered how they could be calling it a new window is
better than overwriting something else without care.

Ben Hochstrasser

unread,
Jan 9, 2005, 2:31:21 PM1/9/05
to
Liz wrote:

> I often dont want it to auto load over something I was reading.. I want
> to put it in a new window..

I want it in a new tab... ;-)

--
Ben

Liz

unread,
Jan 9, 2005, 2:29:54 PM1/9/05
to
Brian Cook wrote:

> When you say "trigger this", which are you trying to do? Open in a
> new window or reuse the current window?

Both

ive seen apps that allow you the choice.

I often dont want it to auto load over something I was reading.. I want

to put it in a new window..

Rob Kennedy

unread,
Jan 9, 2005, 3:53:03 PM1/9/05
to
Liz wrote:
> Brian Cook wrote:
>> When you say "trigger this", which are you trying to do? Open in a
>> new window or reuse the current window?
>
> Both
>
> ive seen apps that allow you the choice.

When they do that, they aren't using ShellExecute anymore. Instead they
are probably invoking Internet Explorer directly, using its command-line
parameters to control the display of the new URL.

If a program uses ShellExecute, then what happens to the URL is entirely
under the control of the browser. If you've set Internet Explorer to
re-use old windows, then that's what will happen (and the other
application won't know the results, either). If you've set Firefox to
open URLs in background tabs but bring itse window to the foreground,
then that's what will happen.

The program might also use DDE. Each browser usually has its owner DDE
window name, but they all support the same conversations and commands,
so you could walk through the list of window names until you find one
that's running, and then issue the DDE command to navigate to a new URL.
(If there is no window present, then just fall back to ShellExecute.)

--
Rob

Andrew Jameson

unread,
Jan 9, 2005, 7:00:36 PM1/9/05
to
Hi Liz,

I think that this works and will always open a new explorer window.

Andrew

function GetExtAssociation(const Ext : string): string;
var
FileClass : string;
begin
Result := '';
with TRegistry.Create(KEY_EXECUTE) do begin
try
RootKey := HKEY_CLASSES_ROOT;
FileClass := '';
if OpenKeyReadOnly(Ext) then begin
FileClass := ReadString('');
CloseKey;
end; {if}
if (FileClass <> '') then begin
if OpenKeyReadOnly(FileClass + '\shell\open\ddeexec\Application')
then begin
Result := ReadString('');
CloseKey;
end; {if}
end; {if}
finally
Free;
end; {try}
end; {with}
end; {GetExtAssociation}

const
cWebPage = 'http://somewebsite.com';

ShellExecute(Application.Handle, 'Open', PChar(GetExtAssociation('.htm')),
PChar(cWebPage), nil, SW_NORMAL);


"Liz" <liz_want...@xcalibur.nospam.co.uk> wrote in message
news:41e1...@newsgroups.borland.com...

vmars

unread,
Jan 9, 2005, 8:11:10 PM1/9/05
to

From:

http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/webbrowser/reference/ifaces/dwebbrowserevents/dwebbrowserevents.asp

Remarks

In Microsoft Internet Explorer, the DWebBrowserEvents2::NewWindow2 event is
not fired when the user selects Window from the New command on the File
menu. This event precedes the creation of a new window from within the
WebBrowser. For example, DWebBrowserEvents2::NewWindow2 fires in response to
a navigation targeted to a new window, or from script using the
IHTMLWindow2::open method.

The DWebBrowserEvents2::NewWindow2 event is fired when a window is about to
be created, such as during the following actions:

The user clicks a link while pressing the SHIFT key.
The user right-clicks a link and selects Open In New Window.
The user selects New Window from the File menu.
There is a targeted navigation to a frame name that does not yet exist.

Your browser application can also trigger this event by calling the
IWebBrowser2::Navigate or IWebBrowser2::Navigate2 method with the
navOpenInNewWindow flag. The WebBrowser control has an opportunity to handle
the new window creation itself. If it does not, a top-level Internet
Explorer window is created as a separate (nonhosted) process.

--
...Vern
NOworrys = KidSafe Internet Filter (Freeware)
www.ParentPresent.org
"Brian Cook" <bcook@rowdydogsoftware[REMOVE].com> wrote in message
news:MPG.1c4b3a76c...@newsgroups.borland.com...

Liz

unread,
Jan 10, 2005, 3:49:00 AM1/10/05
to
Andrew Jameson wrote:

> I think that this works and will always open a new explorer window.

I'll give it a whirl and let you know :)

eshipman

unread,
Jan 10, 2005, 11:26:39 AM1/10/05
to
In article <41e1...@newsgroups.borland.com>,
liz_want...@xcalibur.nospam.co.uk says...

If you just want it in a new window, use the '-new' switch:

shellexecute(handle, 'open', 'http://somewebsite.com -new', Nil, Nil, 0)

Andrew Jameson

unread,
Jan 10, 2005, 11:30:47 AM1/10/05
to
Thanks Eddie ... that's easier than my method ! ... but how many browsers
support the 'new' switch ?

Andrew

"eshipman" <mr_delphi_developer@yahoo!!!.com> wrote in message
news:MPG.1c4c68b5c...@forums.borland.com...

eshipman

unread,
Jan 10, 2005, 12:01:55 PM1/10/05
to
> >
> > If you just want it in a new window, use the '-new' switch:
> >
> > shellexecute(handle, 'open', 'http://somewebsite.com -new', Nil, Nil, 0)
>
> Thanks Eddie ... that's easier than my method ! ... but how many browsers
> support the 'new' switch ?
>

Well, I know that IE has that switch. Can't find anything on Mozilla or
Firefox.

Liz

unread,
Jan 10, 2005, 12:14:20 PM1/10/05
to
Andrew Jameson wrote:

> Thanks Eddie ... that's easier than my method ! ... but how many
> browsers support the 'new' switch ?

firefox doesnt, but I suppose importantly it doesnt barf on it either :)

Rob Kennedy

unread,
Jan 10, 2005, 12:46:52 PM1/10/05
to

I think your best bet is to use DDE. The DDE conversation you want is
"WWW_OpenURL". Create a TDDEClientConv and call its SetLink function
with that string and the names of successive applications until the
function returns True. See the following link for an example.

http://www.elists.org/pipermail/delphi/2004-October/026023.html

WWW_OpenURL takes as one of its arguments the ID of a window. If you
have a specific window in mind, use its 1-based index. To re-use the
most recently active browser window, specify -1 (0xffffffff). To create
a new window, specify 0.

http://www.graphcomp.com/info/specs/nets/ddeapi.html#WWW_OpenURL

Internet Explorer, the Mozilla browsers, and Opera all support DDE.

(If all the calls to SetLink fail, then just fall back on plain old
ShellExecute. Since there is no browser running to respond to the
previous DDE requests, you'll obviously get a new window via ShellExecute.)

--
Rob

Liz

unread,
Jan 10, 2005, 1:36:03 PM1/10/05
to
Rob Kennedy wrote:

> I think your best bet is to use DDE. The DDE conversation you want is
> "WWW_OpenURL". Create a TDDEClientConv and call its SetLink function
> with that string and the names of successive applications until the
> function returns True. See the following link for an example.
>

Thanks for that rob, I shall take a look at some point.

John Leavey

unread,
Jan 11, 2005, 4:45:38 AM1/11/05
to
Liz wrote:


procedure OpenURLInNewWindow( const URL: String );
var
S: string;
begin
with TRegistry.Create( KEY_READ ) do
try
rootkey := HKEY_CLASSES_ROOT;
OpenKey( '\htmlfile\shell\open\command', False );
try
S := ReadString('');
except
S := '';
end;
CloseKey;
finally
Free;
end;

if S > '' then
begin
// remove quotes and commandline parameters
S := Copy( S, Pos( '"', S ) + 1, MaxInt );
S := Copy( S, 1, Pos('"', S) - 1 );
ShellExecute( 0, 'open', PChar( S ), PChar( URL ),
nil, sw_shownormal );
end;
end;

John Leavey

Liz

unread,
Jan 11, 2005, 5:08:33 AM1/11/05
to
John Leavey wrote:

> procedure OpenURLInNewWindow( const url: String );


I'll try that too :)

0 new messages