2017-07-14 70 views
2

我們有一個用VB6編寫的大系統,系統的一部分使用WebControl向用戶顯示BING地圖。這是使用BING webcontrol的V7。微軟已經不贊成V7控制,所以我正在嘗試遷移到V8,但我遇到了一些問題。從VB6 IDE使用BING Webcontrol V8

Bing WebControl V8需要​​IE11(雖然它可以在IE10上工作),但WebControl默認只使用IE7渲染引擎。你可以告訴它通過寫註冊表項,使用後引擎(如果可用):

HKCU\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION\<exe name> REG_DWORD 11000 

該程序編譯時工作正常,但是從VB6 IDE中運行時不工作,這樣的調試一個PITA。我已經在註冊表中設置了編譯的EXE名稱和VB6.EXE,但它在VB6中不起作用。

關於如何讓WebControl在IDE中運行時使用IE10/11渲染的任何想法?這是在Windows 7 btw。

編輯

這裏是我的代碼: 添加WebBrowser控件到窗體,調用它MSIE。

Option Explicit 

Private mstrHTTP As String 
Public mstrAPI_Key As String 

Private Sub Form_Load() 
    Me.Caption = "Name : '" & App.EXEName & "'" 

    mstrHTTP = "" 
    mstrAPI_Key = "Your BING API key here" 

    msIE.Navigate ("about:blank") 

    Call BuildFunction(mstrHTTP, "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">") 
    Call BuildFunction(mstrHTTP, "<html>") 
    Call BuildFunction(mstrHTTP, " <head>") 
    Call BuildFunction(mstrHTTP, "  <meta http-equiv='X-UA-Compatible' content='IE=Edge' />") 
    Call BuildFunction(mstrHTTP, "  <title>Load map with navigation bar module</title>") 
    Call BuildFunction(mstrHTTP, "  <meta charset='utf-8' />") 
    Call BuildFunction(mstrHTTP, "  ") 
    Call BuildFunction(mstrHTTP, "  <!-- Reference to the Bing Maps SDK -->") 
    Call BuildFunction(mstrHTTP, "  <script type='text/javascript'") 
    Call BuildFunction(mstrHTTP, "    src='http://www.bing.com/api/maps/mapcontrol?callback=GetMap'") 
    Call BuildFunction(mstrHTTP, "    async defer></script>") 
    Call BuildFunction(mstrHTTP, "  ") 
    Call BuildFunction(mstrHTTP, "  <script type='text/javascript'>") 
    Call BuildFunction(mstrHTTP, "  function GetMap()") 
    Call BuildFunction(mstrHTTP, "  {") 
    Call BuildFunction(mstrHTTP, "   var map = new Microsoft.Maps.Map('#myMap', {") 
    Call BuildFunction(mstrHTTP, "    credentials: '" & mstrAPI_Key & "'") 
    Call BuildFunction(mstrHTTP, "    ,enableInertia: false") 
    Call BuildFunction(mstrHTTP, "    ,showMapTypeSelector: false") 
    Call BuildFunction(mstrHTTP, "    ,showZoomButtons: false") 
    Call BuildFunction(mstrHTTP, "    ,showLocateMeButton: false") 
    Call BuildFunction(mstrHTTP, "   });") 
    Call BuildFunction(mstrHTTP, "  // Add post map load code here") 
    Call BuildFunction(mstrHTTP, "  }") 
    Call BuildFunction(mstrHTTP, "  </script>") 
    Call BuildFunction(mstrHTTP, " </head>") 
    Call BuildFunction(mstrHTTP, " <body style='margin:0;'>") 
    Call BuildFunction(mstrHTTP, "  <div id='myMap' style='width:100%;height:100%;'></div>") 
    Call BuildFunction(mstrHTTP, " </body>") 
    Call BuildFunction(mstrHTTP, "</html>") 

    msIE.Document.write (mstrHTTP) 

End Sub 

Private Sub BuildFunction(ByRef theString As String, ByRef extraString As String) 
    theString = theString & extraString & vbCrLf 
End Sub 

Private Sub Form_Resize() 
    msIE.Top = 0 
    msIE.Left = 0 
    msIE.Width = Me.ScaleWidth 
    msIE.Height = Me.ScaleHeight 
End Sub 
+0

好吧,出於某種原因,我在週末之後回來了,它工作正常。沒有什麼變化,我能想到,它現在才起作用。 – Slugsie

回答

0

以下添加到您的HTML頁面的標題:

<meta http-equiv="x-ua-compatible" content="IE=Edge"/>

這會告訴Web控制使用安裝在機器上的最新版本的IE。

+0

我已經試過了,在VB6 IDE中運行時沒有區別。 – Slugsie

+0

然後您將不得不按照此處所述編輯註冊表https://weblog.west-wind.com/posts/2011/May/21/Web-Browser-Control-Specifying-the-IE-Version或使用不同的網頁瀏覽器控制,在VB6上可能會有一個版本的Chromium。 – rbrundritt

+0

正如我在原始問題中所述,我已經嘗試了這個註冊表項。它適用於編譯後的EXE,但不適用於在IDE中運行調試。 – Slugsie