我想要完全摆脱“工作离线”消息框。

为了提供一些上下文,此消息框出现在运行本地 box应用程序的机器上。对网络的访问显然是不稳定的,因此暂时的缺乏不应该被阻止:它只会延迟一些背景通知。网页只需要显示本地资源。这些urls看起来像http://localhost:4444/*myApp*/...
这台机器运行在XP上,浏览器是IE8。
我尝试了以下解决办法,但没有成功:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\WebCheck\LoadSens和LoadLCE设置为auto,然后将no设置为yes最后一次尝试几乎奏效。“脱机工作”永远不会被选中,但有时(实际上是随机的)邪恶消息框会出现。问题是,尽管它从来没有保持阻塞(工作模式切换到在线,使页面正常工作),它扰乱了最终用户。
注意:我们不能挑战架构(本地web应用程序),尽管它看起来可能有点奇怪。
发布于 2013-06-07 13:20:04
既然其他人帮不了我,我终于找到了解决办法。有点脏但还在工作。诀窍是模拟点击“重试”按钮。我是通过使用user32.dll函数来做到这一点的。以下是几个步骤:
FindWindow函数查找父窗口的句柄。FindWindowEx的按钮。SendMessage发送单击下面是所需函数的声明
// For Windows Mobile, replace user32.dll with coredll.dll
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className, string windowTitle);
const uint WM_CLOSE = 0x10;
const uint BM_CLICK = 0x00F5;下面是使用它们的方法
private bool ClickButton(String window, String button)
{
IntPtr errorPopUp;
IntPtr buttonHandle;
bool found = false;
try
{
errorPopUp = FindWindow(null, window.Trim());
found = errorPopUp.ToInt32() != 0;
if (found)
{
found = false;
buttonHandle = FindWindowEx(errorPopUp, IntPtr.Zero, null, button.Trim());
found = buttonHandle.ToInt32() != 0;
if (found)
{
SendMessage(buttonHandle, BM_CLICK, IntPtr.Zero, IntPtr.Zero);
Trace.WriteLine("Clicked \"" + button + "\" on window named \"" + window + "\"");
}
else
{
Debug.WriteLine("Found Window \"" + window + "\" but not its button \"" + button + "\"");
}
}
}
catch (Exception ex)
{
Trace.TraceError(ex.ToString());
}
return found;
}window是窗口的标题(=“工作离线”),button是按钮的标题(=“&重试”)。
Note:不要忘记副标题字母前面的符号("&")。
https://stackoverflow.com/questions/16415122
复制相似问题