VS2012, VB, Windows Form
I have a preferences form where I want to edit the appearance of a button on the main form - Back/ForeColor and Text. I've decided to do this by putting a copy of the main button on the preferences form and allowing click to set BackColor, right-click to set ForeColor and double-click to set Text. I'm doing it this way a) because it feels neat and b) as an exercise in learning to modify the Button class.
Setting BackColor with Click is working (it opens a ColorDialog) and, by devious means, I have got the same code to set ForeColor from a right-click. The devious means were disabling the Button, putting it into a Panel of the same size, and using the MouseClick event of the Panel to detect MouseButtons.Left/Right.
Unfortunately, disabling the button turns the Text black, although the right-click picks up the correct ForeColor. I've managed to re-draw the text in the right colour but I still want it to interpret & as a button would and the basic re-drawing method just interprets this as text (in other words it shows "&START"). So, close but no cigar.
In the end I thought that rather than all this faffing about with panels and re-draws, I'd just find out how to activate the right- and double-click in Button. So within my form I have created a class XButton, which inherits Button and now appears
on the form. So far so good, now I need to modify XButton. I have been giving myself a headache for several days so I think I need a break and ask around. Hope someone can help with these very simple :) questions:
1) Button does not list DoubleClick among its methods but BaseButton does. Presumably Button disables certain functionality. How do I re-enable it?
2) Same for MouseClick to respond to MouseButtons.Right
3) I was fiddling with this earlier trying MouseClick and DoubleClick as event names (can't remember exactly what I was doing) and the debugger told me they conflicted with definitions in Button and I needed to use Shadows. But DoubleClick isn't supposed to be a part of Button so what's going on there?
If I can get this to work I intend setting it up in a way that makes it available to anything I write in future, including from the Toolbox. That's for later but I mention it now in case it affects how I approach this.
Muchas gracias for any pointers, colegas
Duncan