📄 website.java
字号:
* the Internet Explorer shortcuts. F5 causes refresh). This behaviour is undesired when * rendering HTML in memory as it causes the empty page about:blank page to be reloaded. * The workaround is to block the default F5 handling by IE when the URL is about:blank. */ OleAutomation auto = new OleAutomation(this); int[] rgdispid = auto.getIDsOfNames(new String[] { "LocationURL" }); //$NON-NLS-1$ Variant pVarResult = auto.getProperty(rgdispid[0]); auto.dispose(); int result = COM.S_FALSE; if (pVarResult != null) { if (pVarResult.getType() == OLE.VT_BSTR) { String url = pVarResult.getString(); if (url.equals(Browser.ABOUT_BLANK)) { MSG msg = new MSG(); OS.MoveMemory(msg, lpMsg, MSG.sizeof); if (msg.message == OS.WM_KEYDOWN && msg.wParam == OS.VK_F5) result = COM.S_OK; } } pVarResult.dispose(); } return result;}int TranslateUrl(int dwTranslate, int pchURLIn, int ppchURLOut) { return COM.E_NOTIMPL;}int UpdateUI() { return COM.E_NOTIMPL;}/* IDocHostShowUI */int ShowMessage(int hwnd, int lpstrText, int lpstrCaption, int dwType, int lpstrHelpFile, int dwHelpContext, int plResult) { /* * Feature on IE. Executing certain ActiveX controls such as the Java or Flash plugin from within * a java VM can cause the application to crash. The workaround is to disallow all ActiveX controls. * * Feature on IE. When IE navigates to a website that contains an ActiveX that is prevented from * being executed, IE displays a message "Your current security settings prohibit running ActiveX * controls on this page ...". The workaround is to selectively block this alert as indicated * in the MSDN article "WebBrowser customization". */ /* resource identifier in shdoclc.dll for window caption "Your current security settings prohibit * running ActiveX controls on this page ..." */ int IDS_MESSAGE_BOX_CAPTION = 8033; if (lpstrText != 0) { TCHAR lpLibFileName = new TCHAR (0, "SHDOCLC.DLL", true); //$NON-NLS-1$ int hModule = OS.LoadLibrary(lpLibFileName); if (hModule != 0) { /* * Note. lpstrText is a LPOLESTR, i.e. a null terminated unicode string LPWSTR, i.e. a WCHAR*. * It is not a BSTR. A BSTR is a null terminated unicode string that contains its length * at the beginning. */ int cnt = OS.wcslen(lpstrText); char[] buffer = new char[cnt]; /* * Note. lpstrText is unicode on both unicode and ansi platforms. * The nbr of chars is multiplied by the constant 2 and not by TCHAR.sizeof since * TCHAR.sizeof returns 1 on ansi platforms. */ OS.MoveMemory(buffer, lpstrText, cnt * 2); String text = new String(buffer); /* provide a buffer large enough to hold the string to compare to and a null terminated character */ int length = (OS.IsUnicode ? cnt : OS.WideCharToMultiByte (OS.CP_ACP, 0, buffer, cnt, 0, 0, null, null)) + 1; TCHAR lpBuffer = new TCHAR(0, length); int result = OS.LoadString(hModule, IDS_MESSAGE_BOX_CAPTION, lpBuffer, length); OS.FreeLibrary(hModule); return result > 0 && text.equals(lpBuffer.toString(0, result)) ? COM.S_OK : COM.S_FALSE; } } return COM.S_FALSE;}/* Note. One of the arguments of ShowHelp is a POINT struct and not a pointer to a POINT struct. Because * of the way Callback gets int parameters from a va_list of C arguments 2 integer arguments must be declared, * ptMouse_x and ptMouse_y. Otherwise the Browser crashes when the user presses F1 to invoke * the help. */int ShowHelp(int hwnd, int pszHelpFile, int uCommand, int dwData, int ptMouse_x, int ptMouse_y, int pDispatchObjectHit) { return COM.S_OK;}/* IServiceProvider */int QueryService(int guidService, int riid, int ppvObject) { if (riid == 0 || ppvObject == 0) return COM.E_INVALIDARG; GUID guid = new GUID(); COM.MoveMemory(guid, riid, GUID.sizeof); if (COM.IsEqualGUID(guid, COM.IIDIInternetSecurityManager)) { COM.MoveMemory(ppvObject, new int[] {iInternetSecurityManager.getAddress()}, 4); AddRef(); return COM.S_OK; } COM.MoveMemory(ppvObject, new int[] {0}, 4); return COM.E_NOINTERFACE;}/* IInternetSecurityManager */int SetSecuritySite(int pSite) { return Browser.INET_E_DEFAULT_ACTION;}int GetSecuritySite(int ppSite) { return Browser.INET_E_DEFAULT_ACTION;}int MapUrlToZone(int pwszUrl, int pdwZone, int dwFlags) { int cnt = OS.wcslen(pwszUrl); char[] buffer = new char[cnt]; /* * Note. pwszUrl is unicode on both unicode and ansi platforms. * The nbr of chars is multiplied by the constant 2 and not by TCHAR.sizeof since * TCHAR.sizeof returns 1 on ansi platforms. */ OS.MoveMemory(buffer, pwszUrl, cnt * 2); String url = new String(buffer); /* * Feature in IE 6 sp1. HTML rendered in memory * does not enable local links but the exact same * HTML document loaded through a local file is * permitted to follow local links. The workaround is * to return URLZONE_INTRANET instead of the default * value URLZONE_LOCAL_MACHINE. */ int zone = Browser.URLZONE_INTRANET; /* * Note. Some ActiveX plugins crash when executing * inside the embedded explorer itself running into * a JVM. The current workaround is to detect when * such ActiveX is about to be started and refuse * to execute it. * ActiveX blocked in an object tag: * - Shockwave director plugin (mime: application/x-director) * - Java plugin */ if (url.startsWith(Browser.URL_DIRECTOR) || (url.startsWith(Browser.URL_JAVA) && url.indexOf(Browser.URL_CAB) != -1) || (url.startsWith(Browser.URL_JAVA_15) && url.indexOf(Browser.URL_CAB) != -1)) { zone = Browser.URLZONE_LOCAL_MACHINE; } COM.MoveMemory(pdwZone, new int[] {zone}, 4); return COM.S_OK;}int GetSecurityId(int pwszUrl, int pbSecurityId, int pcbSecurityId, int dwReserved) { return Browser.INET_E_DEFAULT_ACTION;}int ProcessUrlAction(int pwszUrl, int dwAction, int pPolicy, int cbPolicy, int pContext, int cbContext, int dwFlags, int dwReserved) { /* * Feature in IE 6 sp1. HTML rendered in memory * containing an OBJECT tag referring to a local file * brings up a warning dialog asking the user whether * it should proceed or not. The workaround is to * set the policy to URLPOLICY_ALLOW in this case (dwAction * value of 0x1406). * * Feature in IE. Security Patches and user settings * affect the way the embedded web control behaves. The current * approach is to consider the content trusted and allow * all URLs by default. */ int policy = Browser.URLPOLICY_ALLOW; /* * Note. The URLACTION_JAVA flags refer to the applet tag that normally resolve to * the Microsoft VM, not to the java OBJECT tag that resolves to the * Sun plugin. Return URLPOLICY_JAVA_LOW to authorize applets instead of * URLPOLICY_ALLOW that is interpreted as URLPOLICY_JAVA_PROHIBIT in this * context. */ if (dwAction >= Browser.URLACTION_JAVA_MIN && dwAction <= Browser.URLACTION_JAVA_MAX) { policy = Browser.URLPOLICY_JAVA_LOW; } if (dwAction >= Browser.URLACTION_ACTIVEX_MIN && dwAction <= Browser.URLACTION_ACTIVEX_MAX) { int cnt = OS.wcslen(pwszUrl); char[] buffer = new char[cnt]; /* * Note. pwszUrl is unicode on both unicode and ansi platforms. * The nbr of chars is multiplied by the constant 2 and not by TCHAR.sizeof since * TCHAR.sizeof returns 1 on ansi platforms. */ OS.MoveMemory(buffer, pwszUrl, cnt * 2); String url = new String(buffer); /* * Note. Some ActiveX plugins crash when executing * inside the embedded explorer itself running into * a JVM. The current workaround is to detect when * such ActiveX is about to be started and refuse * to execute it. * ActiveX blocked based on URL extension: * - Shockwave director plugin (mime: application/x-director) */ if (url.endsWith(".dcr")) policy = Browser.URLPOLICY_DISALLOW; //$NON-NLS-1$ } if (cbPolicy >= 4) COM.MoveMemory(pPolicy, new int[] {policy}, 4); return COM.S_OK;}int QueryCustomPolicy(int pwszUrl, int guidKey, int ppPolicy, int pcbPolicy, int pContext, int cbContext, int dwReserved) { return Browser.INET_E_DEFAULT_ACTION;}int SetZoneMapping(int dwZone, int lpszPattern, int dwFlags) { return Browser.INET_E_DEFAULT_ACTION;}int GetZoneMappings(int dwZone, int ppenumString, int dwFlags) { return COM.E_NOTIMPL;}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -