|
-
Dec 20th, 2002, 02:33 PM
#1
Thread Starter
Junior Member
ShellExecute: Opening URLs (not easy)
Hello, I use this code to open URLs in the default browser:
VB Code:
ShellExecute 0, "open", URL, "", "", 1
The problem is that he URL is being opened in the current browser window. Instead it should start a new browser, like if target was "_blank"
So my question: How can I pass the target frame when opening a URL?
Thanks,
NGE
-
Dec 21st, 2002, 09:49 AM
#2
Member
I have no idea with shellexecute, but you can pass the target frame using the webbrowser control
(WebBrowser.Navigate Url as String, [flags],[targetframename],[postdata],[headers])
*follow the white rabbit neo*
.¸¸.·´¯`·.¸.·>dark journey<·.¸¸.·´¯`·.¸.
To accomplish great things, we must dream as well as act.
Anatole France (1844 - 1924)
-
Dec 21st, 2002, 09:55 AM
#3
Thread Starter
Junior Member
Phew, I don't want to blow up my code by using that control..
Is there probably a way to pass DDE commands to a program?
-
Dec 21st, 2002, 01:05 PM
#4
Sleep mode
there are many parameters in this link , maybe one can solve your problem?
http://www.allapi.net/apilist/ShellExecute.shtml
-
Dec 21st, 2002, 01:11 PM
#5
Thread Starter
Junior Member
Well there are things I just don't know and that's why I'm posting here I don't know if there's a special syntax to pass the frame name to the browser. I hoped somebody knew it...
-
Dec 21st, 2002, 09:09 PM
#6
Frenzied Member
-
Dec 21st, 2002, 09:21 PM
#7
Thread Starter
Junior Member
Thanks, the idea was great but it doesn't work, still launches the site in a already opened IE (I also tried to put the URL in "").
-
Dec 22nd, 2002, 06:19 PM
#8
Frenzied Member
VB Code:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Const SW_SHOWNORMAL = 1
Private Sub Form_Load()
Dim lngFile As Long
lngFile = FreeFile
'delete the file if it's alive
If Len(Dir("C:\temp.url")) Then Kill "C:\temp.url"
Open "C:\temp.url" For Append As lngFile
Print #lngFile, "[Default]"
Print #lngFile, "BASEURL=http://vbforums.com/showthread.php?s=&threadid=221262"
Print #lngFile, ""
Print #lngFile, "[InternetShortcut]"
Print #lngFile, "URL=http://vbforums.com/showthread.php?s=&threadid=221262"
Close lngFile
ShellExecute Me.hwnd, vbNullString, "C:\temp.url", vbNullString, "C:\", SW_SHOWNORMAL
Kill "C:\temp.url"
End Sub
-
Dec 23rd, 2002, 01:18 AM
#9
Thread Starter
Junior Member
Thanks, this gives me a new idea how to solve the problem! (for your interest: the code you gave me still opens the site in a existing window - but now I can search for parameters)
-
Dec 23rd, 2002, 01:25 AM
#10
Frenzied Member
On my work computer, this actually solved your problem. Now that I try it at home on XP it doesn't.
Mind letting me know how you solve the problem when you do?
-
Dec 23rd, 2002, 01:38 AM
#11
Thread Starter
Junior Member
Well I already solved one special case of the problem - the one I need actually. The following code opens a new window first and then the URL in it:
VB Code:
Public Sub OpenURL(iURL As String)
'Open URL in new window
ShellExecute 0, "open", "about[b][/b]:[b][/b]blank", "", "", 1
ShellExecute 0, "open", iURL, "", "", 1
End Sub
That's not a target frame but at least _blank
-
Dec 23rd, 2002, 01:45 AM
#12
Frenzied Member
Works. Cool.
-
Dec 23rd, 2002, 10:40 AM
#13
Thread Starter
Junior Member
Not perfectly, as I said before.. Put the code into a button and click it 3 times.. the first window will open in a new explorer, the other 2 calls will open a new window but open the URL in window #1...
-
Dec 23rd, 2002, 11:42 AM
#14
Frenzied Member
-
Dec 23rd, 2002, 11:59 AM
#15
Thread Starter
Junior Member
Yes, that's exactly what I need. But I don't know how to use DDE in VB.. and searching MSDN wasn't that successful...
-
Dec 23rd, 2002, 01:05 PM
#16
Frenzied Member
This works for me. I used late-binding so it won't bloat your application.
VB Code:
Option Explicit
Private Sub Form_Load()
Dim objIE As Object
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate2 "http://www.vbforums.com/showthread.php?s=&postid=1308704#post1308704"
objIE.Visible = True
Set objIE = Nothing
End Sub
-
Dec 23rd, 2002, 03:19 PM
#17
Thread Starter
Junior Member
Very nice, a thousand thanks!
-
Dec 23rd, 2002, 03:41 PM
#18
Frenzied Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|