代码之家  ›  专栏  ›  技术社区  ›  Stormenet

Form.FormBorderStyle本机异常访问冲突

  •  2
  • Stormenet  · 技术社区  · 14 年前

    在WindowsCE平台(自定义构建)上,我们的C GUI使用常规表单显示“弹出菜单”。 我们设置了 窗体风格 没有 因为我们不希望窗体控件可见。

    一些客户在一段时间后报告“灰色盒子”。 在这里进行了一些测试之后,我们可以很快地重现这个问题。当我们不断打开两个不同的菜单(表单)时,平台会向我们显示一个本机异常。

    误差
    发生本机异常 在tiger.cehost.exe中。选择退出 然后重新启动此程序,或选择 详细信息。

    细节:

    误差
    例外代码:0xC0000005
    例外地址:0x00000001
    读数:0x0000001

    在wl.setStyle(intptr hwnse,uint32 dwmask,uint32 dwstyle)
    at form._setborderstyle(agl_windowstyle wstyval,agl_windowstyle wstymask)
    at form.set_FormborderStyle(FormborderStyle值)
    在pDropDown.PopupForm.Show()处
    在pDropDown.Show()处
    在pbutton.showHideDropDown()处
    在pbutton.onclick(事件参数e)
    at control.wnproc(wm wm,int32 wparam,int32 lparam)
    at control.内部wnproc(wm wm,int32 wparam,int32 lparam)
    在evl.entermainloop(intptr hwnmain)处
    在应用程序中运行(窗体fm)
    at program.main(string[]参数)

    它似乎总是在 窗体风格 财产。我们已经尝试删除所有的pinvoke,因为可能有些内存被覆盖了,但这没有帮助。

    我们还记录对show方法的每个调用,并且每个调用都在GUI线程中进行,并且表单包含一个有效的句柄。

    2 回复  |  直到 14 年前
        1
  •  1
  •   ctacke    14 年前

    我从来没有见过这种情况,这会让我觉得在CF甚至你的应用程序中,这不太可能是一个问题。

    您的设备是否有足够的内存运行应用程序?内存不足的情况应该抛出一个OOM,但我见过它做过其他不太可预测的事情,所以它总是第一件要检查的事情。

    如果不是内存问题,您确定这不是平台问题吗?记住,由于操作系统的很大一部分是由原始设备制造商开发的,所以不能排除操作系统中的问题。

    我会尝试两件事:

    1. 同一个应用程序在其他硬件(甚至模拟器)上运行正常吗?如果它在其他硬件上工作,那么它严重地将平台作为问题牵连在一起。

    2. 因为在C语言中使用一个小应用程序是相当容易的,所以我建议在C/C++中构建一个应用程序,该应用程序执行相同的功能项,以查看它是否运行或给出相同的问题。

        2
  •  0
  •   Stormenet    14 年前

    这似乎是netcfagl3_5.dll中的一个错误(将通知Microsoft)

    当我们使用pinvokes(setwindowlong)设置formborderstyle时,我们无法重现问题。

    如果有人遇到这种罕见的错误,这是不使用.NET设置FormBorderStyle的代码 窗体风格 财产。

    private const uint WS_OVERLAPPED = 0x00000000;
            private const uint WS_POPUP = 0x80000000;
            private const uint WS_CHILD = 0x40000000;
            private const uint WS_MINIMIZE = 0x20000000;
            private const uint WS_VISIBLE = 0x10000000;
            private const uint WS_DISABLED = 0x08000000;
            private const uint WS_CLIPSIBLINGS = 0x04000000;
            private const uint WS_CLIPCHILDREN = 0x02000000;
            private const uint WS_MAXIMIZE = 0x01000000;
            private const uint WS_CAPTION = 0x00C00000;
            private const uint WS_BORDER = 0x00800000;
            private const uint WS_DLGFRAME = 0x00400000;
            private const uint WS_VSCROLL = 0x00200000;
            private const uint WS_HSCROLL = 0x00100000;
            private const uint WS_SYSMENU = 0x00080000;
            private const uint WS_THICKFRAME = 0x00040000;
            private const uint WS_GROUP = 0x00020000;
            private const uint WS_TABSTOP = 0x00010000;
    
            private const int WS_MINIMIZEBOX = 0x00020000;
            private const int WS_MAXIMIZEBOX = 0x00010000;
    
            private const uint WS_EX_DLGMODALFRAME = 0x00000001;
            private const uint WS_EX_NOPARENTNOTIFY = 0x00000004;
            private const uint WS_EX_TOPMOST = 0x00000008;
            private const uint WS_EX_ACCEPTFILES = 0x00000010;
            private const uint WS_EX_TRANSPARENT = 0x00000020;
            private const uint WS_EX_MDICHILD = 0x00000040;
            private const uint WS_EX_TOOLWINDOW = 0x00000080;
            private const uint WS_EX_WINDOWEDGE = 0x00000100;
            private const uint WS_EX_CLIENTEDGE = 0x00000200;
            private const uint WS_EX_CONTEXTHELP = 0x00000400;
            private const uint WS_EX_STATICEDGE = 0x00020000;
    
            private const int WS_EX_NOANIMATION = 0x04000000;
            public const int GWL_EX_STYLE = -20;
            public const int GWL_STYLE = (-16);
    
    public static void SetNoBorder(Form form) {
                RemoveFormStyle(form, GWL_STYLE, (int)(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU));
                RemoveFormStyle(form, GWL_EX_STYLE, (int)(WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE));
            }
    
    public static void RemoveFormStyle(Form f, int modifier, int style) {
                int currStyle = GetWindowLong(f.Handle, GWL_EX_STYLE);
                currStyle &= ~style;
                SetWindowLong(f.Handle, modifier, currStyle);
            }
    
        [DllImport("Coredll.dll", SetLastError = true)]
        public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
    
        [DllImport("coredll.dll", SetLastError = true)]
        public static extern int GetWindowLong(IntPtr hWnd, int nIndex);