Compact Framework - 在加载期间禁用鼠标事件

发布于 2024-07-11 23:38:30 字数 794 浏览 7 评论 0原文

早上好,

我设计了许多紧凑的框架应用程序,但我总是无法理解如何防止我们所说的约克郡银行综合症(ybs)。 YBS 以约克郡银行的提款机命名,因为它们的屏幕刷新速度非常慢,我的一位同事以为自己没有按按钮,按了两次按钮,最终提取了 100 英镑,而不是他想要的 20 英镑(“无收据现金”和“100 英镑”按钮被分配给两个不同屏幕上的同一个按钮)。

基本上,我在应用程序启动时使用启动屏幕加载所有表单,并且每个其他表单都有一个名为 Initialise() 的公共事件。 为了显示表单,我使用 Session.Instances.FormName.Initialise() 然后执行 showdialog()。

Initialise() 方法通常会调用某种形式的重置或数据加载,因此 Cursor 也会在该方法中设置。 当用户单击按钮显示表单时,会加载表单,但如果他们同时单击屏幕,则该屏幕点击将传递到当前正在加载(但未显示)的表单时,就会出现问题。

例如,我单击一个按钮来显示表单,然后单击屏幕的左下角。 在我的大多数 CF 应用程序中,右下角的按钮是设置 DialogResult.Cancel 的后退按钮。 因此,一旦加载完成,表单就不会出现,因为单击了后退按钮,即使表单从未显示过。

我已经尝试了很多事情,包括在 Initialise() 开始时使用 this.Enabled = false ,但似乎单击存储在后台,然后在加载完成时将单击事件触发到屏幕上。

所以,我现在想知道是否有一种方法可以在加载过程中禁止任何鼠标输入,而只在 Form.ShowDialog() 之前再次启用它? 或者有人对如何实现这一目标有更好的想法吗?

Morning all,

I design a number of compact framework applications, and something that always eludes me is a way of preventing what we call yorkshire bank syndrome (ybs). YBS is named lovingly after the cash points at Yorkshire Bank due to the fact that their screen refresh is so slow, and one of my colleagues pressed the button twice thinking that he hadn't pressed the button and ended up drawing out £100 instead of the £20 he wanted (the "Cash Without Receipt" and "£100" buttons were assigned to the same button on the two different screens).

Basically, I load all my forms with a splash screen at the start of the application and every other form has a public event called Initialise(). To show a form I used Session.Instances.FormName.Initialise() then do a showdialog().

The Initialise() method normally calls some sort of form reset or data loading, so in turn the Cursor is set in that method as well. The problem arises when the user clicks a button to show a form, the form loads, but if they click the screen in the meantime, that screen click gets passed through to the form that is currently loading (but not shown).

For example, I click a button to show a form and then click the bottom left of the screen. In most of my CF apps, the button in the bottom right is the back button that sets DialogResult.Cancel. So once the load is finished, the form does not appear as the back button has been clicked, even though the form was never shown.

I have tried a number of things, including this.Enabled = false at the start of the Initialise(), but it seems that the click is stored in the background and then the click event fired onto the screen when the load has finished.

So, I'm now wondering if there's a way to disallow any mouse input during my loading and only enable it again just before my Form.ShowDialog()? OR does anyone have any better ideas of how to achieve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

掌心的温暖 2024-07-18 23:38:30

Chris Tacke 创建了 ApplicationEx 作为 OpenNETCF 的一部分。 它允许获取您的应用程序收到的每条 Windows 消息。

这里有一个使用示例。

Chris Tacke created ApplicationEx as part of OpenNETCF. It allows getting every Windows message that your app receives.

There is an example of its use here.

只有影子陪我不离不弃 2024-07-18 23:38:30

我年轻时采用的一个粗略方法是设置一个计时器,在加载后将事件连接到表单上的 ui 元素。 在那种情况下就完成了工作。

这些天我没有遇到太多问题,特别是如果我预加载表格的话。 也许问题在于显示表单时在 UI 线程上执行某种形式的较长数据操作?

如果你想进入“黑客”领域,你总是可以尝试在某个地方启动一个 Application.DoEvents() 来清除缓冲区,效果不佳。

A crude method I deployed in my younger years was to set a timer to hook up the events to ui elements on a form after the load. That did the job in that case.

These days I haven't had so much of a problem, especially if I preload the forms. Perhaps the issue lies with performing some form of longish data operation on the UI thread when showing the form?

If you want to get into "hack" territory you could always try kicking off an Application.DoEvents() somewhere in a poor attempt to clear the buffer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文