環境:VB6 & Window98 IE5.5
フルスクリーンで表示したIEを独自のポップアップメニューで終了する方法
を、ここの過去ログで発見しました。
http://madia.world.coocan.jp/cgi-bin/VBBBS/wwwlng.cgi?print+200312/03120091.txt
未解決ではあるものの、大変参考になる内容でしたので、その続きを試行錯誤
した結果、動作するようにはなりました。
しかし、以下の問題が解決していません。
1.ダブルクリックで表示したポップアップメニューの終了項目をクリック
しても、時々、終了できない場合があります。
2.終了項目以外にメニュー項目を追加し、そのコマンドを実行する関数を
VBの標準モジュールに置いた場合、スクリプトでその関数をバインド
する方法がわかりません。
解決策についてアドバイスお願いします。
以下に、テストコードを載せます。
' 参照設定
' Microsoft Internet Controls (SHDOCVW.DLL)
' Microsoft HTML Object Library (MSHTML.tlb)
Option Explicit
Private WithEvents IE As InternetExplorer
Private WithEvents IEDoc As HTMLDocument
Private m_oPopup As IHTMLPopup
Private Sub Form_Load()
Set IE = New InternetExplorer
IE.navigate "http://www.google.co.jp/"
IE.Visible = True
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
On Error Resume Next
Set m_oPopup = Nothing
Set IEDoc = Nothing
IE.Quit
Set IE = Nothing
End Sub
Private Sub IE_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Set IEDoc = pDisp.document
End Sub
Private Sub IE_OnQuit()
On Error Resume Next
m_oPopup.Hide
Set m_oPopup = Nothing
Set IEDoc = Nothing
Set IE = Nothing
End Sub
Private Function IEDoc_ondblclick() As Boolean
Dim sHTML As String
sHTML = "<HTML><BODY>" & _
"<DIV onmouseover=""this.style.background='blue';" & _
"this.style.color='white';""" & _
"onmouseout=""this.style.background='white';" & _
"this.style.color='black';"">" & _
"<SPAN onclick=""parent.window.close()"">" & _
"ブラウザを閉じる</SPAN></DIV></BODY></HTML>"
Set m_oPopup = IEDoc.parentWindow.createPopup
With m_oPopup.document.body
.Style.border = "solid black 1px"
.innerHTML = sHTML
End With
With IEDoc.parentWindow.event
m_oPopup.Show .clientX + 3, .clientY + 3, 150, 50, IEDoc.body
End With
End Function
ツイート | ![]() |