实施集中热键处理/处理
我正在开发一个项目,需要在整个应用程序中实现可自定义的热键。有许多不同的表单和用户控件需要实现不同的热键子集。我想在中央 MessageFilter 类中实现所有处理和处理。
我想要一个具有所有热键方法的基类,然后只需重写每个表单/控件中所需的子集,但我不知道如何让所有表单和用户控件共享一个基类。这将允许我执行类似的操作来处理热键:
public bool PreFilterMessage(ref Message m)
{
HotKeyAction 操作 = GetActionForKey(keydata);
BaseClass 实例 = GetBaseClassFromFocusedFormOrControl();
开关(动作)
{
case HotKeyAction.Action1:instance.Action1() 中断;
}
} 我是否
以错误的方式思考这个问题?
I'm working on a project where I need to implement customizable hotkeys across the application. There are a number of different forms and user controls that need to implement different subsets of hotkeys. I would like to implement all of the handling and processing in a central MessageFilter class.
I want to have a base class that has methods for all hotkeys, and then just override the subset of needed ones in each form/control, but I can't figure out how to have all of the forms and usercontrols share a base class. This would allow me to do something like this to process the hotkeys:
public bool PreFilterMessage(ref Message m)
{
HotKeyAction action = GetActionForKey(keydata);
BaseClass instance = GetBaseClassFromFocusedFormOrControl();
switch (action)
{
case HotKeyAction.Action1: instance.Action1() break;
}
}
Am I thinking about this the wrong way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可以这么说,您可以将表单创建为“基类”。也就是说,您可以创建一个名为 ShanesForm 的表单,其中不包含任何内容。将方法调用放置在此表单中,然后将该表单设置为所有其他表单的基类。
You can create forms as a "base class" so to speak. That is, you could create a Form called ShanesForm with nothing on it. Place your method calls in this form, and then set that form as the base class to all your other forms.