The usual way to display a modal dialog is to create a form in your VB project and then do something like myForm.Show
vbModal
But suppose I want to display an HTML Modal Dialog. Then I could create an instance of Internet Explorer, give it an
empty document, and then do myResult = IE.document.parentWindow.showModalDialog (myPage, myArgument). This has been
working tremendously well for me and, beside the obvious, is useful for several tricks such as obtaining the
.Document attribute at the expense of a screen flicker (that capitalization is not a mistake), which I've not found
a way to get to from straight VB.
Recently (03 July 22) I have seen a post on microsoft.public.win32.programmer.ui wherein Christian Astor recommends:
ShowHTMLDialog()
(or WebBrowser control : KB 189634)
I see very little discussion of this ShowHTMLDialog on the web and no examples, and I am really mystified by it. Can
someone enlighten me or would anyone have an example of this that they'd care to donate to the web? Especially as it
relates to VB? Here is Microsoft's documentation:
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/mshtml/reference/functions/ShowHTMLDialog.asp
Perhaps I'm missing something really basic here, but I don't find ShowHTMLDialog at AllAPI.net, but on the above page
it shows under MSHTML Reference, and I am using mshtml.tlb.
Should I be able to use this call from VB? If so, how do the declares go?, cause that is what I'm having the most
trouble following.
Looking forward to your responses,
Csaba Gabor from New York
Steven (Szakats Istvan!)
Yes.
> If so, how do the declares go?
Private Declare Function CreateURLMoniker Lib "urlmon.dll" ( _
ByVal MkCtx As Long, _
ByVal URL As Long, _
Moniker As IUnknown) As Long
Private Declare Function apiShowHTMLDialog Lib "mshtml.dll" _
Alias "ShowHTMLDialog" ( _
ByVal hwndParent As Long, _
ByVal pMk As IUnknown, _
Optional pvarArgIn As Variant, _
Optional ByVal pchOptions As Long, _
Optional pvarArgOut As Variant) As Long
And here is a function that wraps the API calls:
Function ShowHTMLDialog( _
ByVal URL As String, _
Optional ByVal Args As Variant, _
Optional ByVal Options As String, _
Optional ByVal Parent As Form) As Variant
Dim oUrlMk As IUnknown
Dim lRes As Long
Dim hWnd As Long
lRes = CreateURLMoniker(0, StrPtr(URL), oUrlMk)
If lRes Then Err.Raise lRes
If Not Parent Is Nothing Then hWnd = Parent.hWnd
lRes = apiShowHTMLDialog(hWnd, oUrlMk, Args, _
StrPtr(Options), ShowHTMLDialog)
If lRes Then Err.Raise lRes
End Function
ShowHTMLDialog "www.yahoo.com", "param", _
"dialogWidth:100px;dialogHeight:100px"
--
Eduardo A. Morcillo [MS MVP - VB]
http://www.mvps.org/emorcillo
Suppose a sequence of events like so: A .VBS file is double clicked, it invokes (CreateObject) an .OCX, which in
turn instantiates IE and does the myResult = IE.document.parentWindow.showModalDialog (myPage, myArgument) line. But
while the HTML modal dialog is up, I want to interact with the OCX. For example, the user hits a button on the
dialog and an OCX variable should get changed. Or simply read, for that matter.
One way to do this would be to have a timer in my OCX and check some variable (mySemaphore) within the modal dialog
on each pass. I just hate using timers for this kind of thing, though. And to read a variable would take two
"timers" (one to get the OCX to stuff it into IE's dialog, the second to tell the dialog it's OK to make use of the
variable. Ugly).
That's what led to my interest when I saw the ShowHTMLDialog. So I'm still interested in the original question, but
I'm also curious about alternate approaches to this motivating issue.
Szia (Ciao),
Csaba
"Csaba2000" <ne...@CsabaGabor.com> wrote in message news:#et8$jFWDH...@tk2msftngp13.phx.gbl...
Since dialogArguments is a variant you can pass a control reference to the
dialog using it. Using the code from the previous post:
ShowHTMLDialog "www.yahoo.com", Me, ....
If you want to pass more parameters add them to a collection and pass the
collection to the dialog.
I had to make one small change. On my system (VB5/Win2K Pro), I need to prefix www.yahoo.com with http:// in order
for the page to show. Without it I got a blank dialog.
Thanks again for your example!
Csaba
"Eduardo A. Morcillo [MS MVP]" <emorcilloATmvps.org> wrote in message news:umzEoIIW...@TK2MSFTNGP11.phx.gbl...
The funny thing is I posted about how to use this same technique in a slightly different context a day or two ago (in
microsoft.public.scripting.vbscript: Returning arrays from a .vbs file; Passing arrays to VBScript caveat). How soon
I forget, eh?
Good call,
Csaba
"Eduardo A. Morcillo [MS MVP]" <emorcilloATmvps.org> wrote in message news:O0AbAXIW...@TK2MSFTNGP11.phx.gbl...