更新窗体中的 UI 对象

编程入门 行业动态 更新时间:2024-10-26 00:22:36
本文介绍了更新窗体中的 UI 对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

Pre 我使用 MFC、ON_UPDATE_COMMAND_UI 和 CCmdUI 类来更新我的 Windows UI 的状态.来自较旧的 MFC/Win32 参考:

Pre I was using MFC, ON_UPDATE_COMMAND_UI, and the CCmdUI class to update the state of my windows UI. From the older MFC/Win32 reference:

通常,菜单项和工具栏按钮有多个状态.为了例如,菜单项变灰(变暗)如果它在当前上下文.菜单项也可以被选中或不选中.一个工具栏按钮也可以禁用,如果不可用,或者可以检查.

Typically, menu items and toolbar buttons have more than one state. For example, a menu item is grayed (dimmed) if it is unavailable in the present context. Menu items can also be checked or unchecked. A toolbar button can also be disabled if unavailable, or it can be checked.

谁更新这些项目的状态随着计划条件的变化?从逻辑上讲,如果一个菜单项生成一个由,例如,处理的命令文档,它是有意义的文档更新菜单项.这文件可能包含更新的信息基于.

Who updates the state of these items as program conditions change? Logically, if a menu item generates a command that is handled by, say, a document, it makes sense to have the document update the menu item. The document probably contains the information on which the update is based.

如果一个命令有多个用户界面对象(可能是一个菜单item 和工具栏按钮),两者都是路由到相同的处理函数.这封装了您的用户界面更新所有等价物的代码单个用户界面对象地点.

If a command has multiple user-interface objects (perhaps a menu item and a toolbar button), both are routed to the same handler function. This encapsulates your user-interface update code for all of the equivalent user-interface objects in a single place.

该框架提供了一个方便的自动更新界面用户界面对象.你可以选择以其他方式进行更新,但提供的界面是高效且易于使用.

The framework provides a convenient interface for automatically updating user-interface objects. You can choose to do the updating in some other way, but the interface provided is efficient and easy to use.

Windows 窗体的指南是什么?我在主窗体中使用 Application.Idle 处理程序,但我不确定这是最好的方法.大约在我将所有 UI 更新放入 Idle 事件处理程序时,我的应用程序开始出现一些性能问题,而且我还没有跟踪此问题的指标.不确定是否相关.

What is the guidance for Windows Forms? I am using an Application.Idle handler in the main form but am not sure this is the best way to do this. About the time I put all my UI updates in the Idle event handler my app started to show some performance problems, and I don't have the metrics to track this down yet. Not sure if it's related.

推荐答案

AFAIK,在标准的 .NET System.Windows.Forms 世界中,此功能不是开箱即用的.这个问题可以从几个方面来回答.以下链接是有用的资源:

AFAIK, in the standard .NET System.Windows.Forms world, this functionality is not available out the box. This problem can be answered in a few ways. The links below are useful resources:

•OnUpdate 等效项

•Windows 表单的动作列表

•在 C# 中更新 Windows 窗体的命令 UI

这篇关于更新窗体中的 UI 对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-25 10:54:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1115324.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:窗体   对象   UI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!