I need help trying to construct a Dialog box where the left portion of the dialog will contain function buttons and the right side is a IE website frame...?
I want the buttons on the left to trigger actions on the IE website frame page.
You could think of it like the WebRecorder application where there is a nested website frame with functions in the surrounding dialog areas.
Any Tips or suggestions are appreciated! Thanks!
How to open up IE Window Frame within a Dialog?
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
I nearly said "It can't be done". In that there is no "WebBrowser" control in the object palette of the dialog designer. So you can't just whack a WebBrowser object onto a dialog like you can a button.
However, I dreamt up a way you can do it, kind of. It may not be quite what you are looking for, but it's fun.
There's an API function called SetParent. It allows you to change the parent of a window/object given its handle. So what we can do is start IE, get its handle and then change its parent to a dialog object, thus making IE appear inside the dialog.
Here's a little example script that opens IE up, sticks it inside a tab control with some buttons to demonstrate changing the navigation.
Enjoy.
However, I dreamt up a way you can do it, kind of. It may not be quite what you are looking for, but it's fun.
There's an API function called SetParent. It allows you to change the parent of a window/object given its handle. So what we can do is start IE, get its handle and then change its parent to a dialog object, thus making IE appear inside the dialog.
Here's a little example script that opens IE up, sticks it inside a tab control with some buttons to demonstrate changing the navigation.
Code: Select all
OnEvent>DIALOG_EVENT,Dialog1,10,GoMjtnet
OnEvent>DIALOG_EVENT,Dialog1,20,GoGoogle
OnEvent>DIALOG_EVENT,Dialog1,2,Quit
VBSTART
Dim IE
Sub CreateIE
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible=1
End Sub
Sub Nav(URL)
IE.Navigate(URL)
End Sub
VBEND
Dialog>Dialog1
Caption=Dialog1
Width=735
Height=446
Top=301
Left=236
TabBook=msTabBook1,136,-4,577,405,0
Button=Visit mjtnet.com,8,8,111,25,10
Button=Visit Google.com,8,48,109,25,20
Button=Close,8,375,119,25,2
TabPage=Page1
EndTabBook
EndDialog>Dialog1
VBRun>CreateIE
WaitWindowOpen>Windows Internet Explorer
GetWindowHandle>Windows Internet Explorer,hIEWnd
LibFunc>user32,SetParent,r,hIEWnd,DIALOG1.MSTABBOOK1.HANDLE
Let>WIN_USEHANDLE=1
WindowAction>1,hIEWnd
Let>WIN_USEHANDLE=0
Show>Dialog1
Label>ActionLoop
Wait>0.02
GetDialogAction>Dialog1,r
If>r=2,Quit
Goto>ActionLoop
SRT>GoMjtnet
VBEval>IE.Navigate("http://www.mjtnet.com/"),r
ResetDialogAction>Dialog1
END>GoMjtnet
SRT>GoGoogle
VBEval>IE.Navigate("http://www.google.com/"),r
ResetDialogAction>Dialog1
END>GoGoogle
SRT>Quit
Exit>0
END>Quit
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Hi Marcus,
Thanks for this... some great possibilities here.
I thought I'd post to say I couldn't make it work on my corporate machine as posted (XP SP3 but running IE6) however with the following changes, it worked like a charm:
One problem I can see with using this though (I used the wildcard) is that a user typically has one or more browser windows open all the time. If they fire up this macro, it may "grab" one of the existing IE windows and put that in the dialog instead of keying in on the new one. Perhaps On Event with WINDOW_OPEN could be used to make sure we grab the new one?
Anyway, thanks again for this very interesting technique.
Thanks for this... some great possibilities here.
I thought I'd post to say I couldn't make it work on my corporate machine as posted (XP SP3 but running IE6) however with the following changes, it worked like a charm:
Code: Select all
VBRun>CreateIE
//WaitWindowOpen>Windows Internet Explorer
WaitWindowOpen>Microsoft Internet Explorer*
//GetWindowHandle>Windows Internet Explorer,hIEWnd
GetWindowHandle>Microsoft Internet Explorer*,hIEWnd
Anyway, thanks again for this very interesting technique.
jpuziano
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Thanks Marcus... I'll ponder this method. I know MS is probably not well suited for this type of coding ... but MS is the only scripting language I know!!!mtettmar wrote:I nearly said "It can't be done". In that there is no "WebBrowser" control in the object palette of the dialog designer. So you can't just whack a WebBrowser object onto a dialog like you can a button.
However, I dreamt up a way you can do it, kind of. It may not be quite what you are looking for, but it's fun.
P.s. - if you ever happen to have another dream... try dreaming of how you would code it to open up multiple browser instances, each instance opening in a separate tab along the top of the dialog box. (similar to IE or Firefox tabbed views)