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??
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.
Greetings.
When you say "trigger this", which are you trying to do? Open in a new
window or reuse the current window?
- Brian
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
> 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.
> 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
> 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..
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
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...
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...
> I think that this works and will always open a new explorer window.
I'll give it a whirl and let you know :)
If you just want it in a new window, use the '-new' switch:
shellexecute(handle, 'open', 'http://somewebsite.com -new', Nil, Nil, 0)
Andrew
"eshipman" <mr_delphi_developer@yahoo!!!.com> wrote in message
news:MPG.1c4c68b5c...@forums.borland.com...
Well, I know that IE has that switch. Can't find anything on Mozilla or
Firefox.
> 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 :)
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
> 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.
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
> procedure OpenURLInNewWindow( const url: String );
I'll try that too :)