在哪里更新工具栏的按钮状态? [英] Where to update toolbar's buttons state?

查看:98
本文介绍了在哪里更新工具栏的按钮状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.

我正在设计基于scintilla的使用简单文本编辑器的软件.
该软件具有工具栏,其中按钮的状态由外部闪烁体的标志定义.我已经在WinMain的消息循环中实现了这一点,调用了处理程序功能来检查标志并更新工具栏.

我的问题是:
这是处理按钮状态更新的最佳方法吗? (希望不是...)
它会增加程序的开销吗?

谢谢!

Paulo Sherring.

Hi all.

I am designing a software that uses a simple text editor, based on scintilla.
The software has a tool bar, where the buttons'' state are defined by external scintilla''s flags. I''ve achieved this inside the WinMain''s message loop, calling the handler function that checks the flags and updates the tool bar.

My questions are:
Is this the best way to handle the buttons state update? (hoping that is not...)
Does it adds great overhead to the program?

Thanks!

Paulo Sherring.

推荐答案

通常,对于文本编辑器,这是在文本缓冲区的每个状态更新上完成的,包括创建新的,关闭,更改焦点选项卡等,换句话说-任何文档的状态.不它不是. :-)

(我的意思是,您可以用更细粒度的方式来做到这一点,但是您几乎无法赢得任何显着的性能.在涉及单个用户输入的情况下,一毫秒或几毫秒就不算在内.最好将所有更新放在一个呼叫中,例如UpdateControlStates并从该事件的所有最高级别事件处理程序中进行调用,这些事件处理程序可能会更新文档状态.这将确保您的代码保持简单,并且您出错的可能性较小.)

—SA
Normally, in the case of text editor, this is done on every state update of the text buffers, including creation a new one, closing, changing focused tab, etc., In other words — states of any documents. No it is not. :-)

(I mean, you can do it in a more fine-grain manner, but you can hardly win any noticeable performance. Where a single user input is involved, one millisecond or few does not count. Better put all updates in one single call like UpdateControlStates and call in from all the highest-level event handlers of the event which can potentially update a document state. This will ensure your code is kept simple and you have a less chance of a bug.)

—SA


这篇关于在哪里更新工具栏的按钮状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆