views:

80

answers:

1

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?

A: 

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.

taylonr