Christian
Mon Jul 21 11:34:34 CDT 2008
As Peter mentioned you could just create an owner drawn one button control
http://christian-helle.blogspot.com/2007/09/buttonex-owner-drawn-button-control.html
You could also subclass the button control and do your own painting on
WM_PAINT and WM_ERASEBKGND. Not a simple solution but there a few articles
out there explaining the procedure.
Here's a few MSDN links:
Subclassing Controls with a Managed WndProc
http://msdn.microsoft.com/en-us/library/ms229681.aspx
How to: Subclass a TreeView by Using Native Callbacks
http://msdn.microsoft.com/en-us/library/ms229669.aspx
How to: Subclass a Button by Using Native Callbacks
http://msdn.microsoft.com/en-us/library/ms229661.aspx
--
Regards,
Christian Resma Helle
http://christian-helle.blogspot.com
"Peter Foot" <feedback@nospam-inthehand.com> wrote in message
news:D9D11FBD-753C-4F15-BC16-728C8D4B7986@microsoft.com...
> You can't do this with the standard Button class which is a simple wrapper
> over the native button control. Instead create your own custom control
> where you can draw what you like from scratch and make use of the Click
> event.
> There is an example here:-
>
http://msdn.microsoft.com/en-us/library/aa446518.aspx
>
> Peter
>
> --
> Peter Foot
> Microsoft Device Application Development MVP
> peterfoot.net | appamundi.com | inthehand.com
> APPA Mundi Ltd - Software Solutions for a Mobile World
> In The Hand Ltd - .NET Components for Mobility
>
> "Chris" <Chris@discussions.microsoft.com> wrote in message
> news:EC5D0A6C-7878-490D-A76C-3E1B1F7CD3B0@microsoft.com...
>>I want to extend a standard Button class (VS 2008, Compact Framework
>>3.5) - I
>> need to change background, draw lines etc. Unfortunately it is impossible
>> to
>> override OnPaint method (I mean, I can override it, but this method never
>> fires). I need graphics object which is available in OnPaint method.
>> Anyway -
>> how to create graphics object related to Button? There is no
>> CreateGraphics
>> method in Button class. When I cast Button to Control and call
>> CreateGraphics() (it is available in Cotnrol class) UnSupportedException
>> is
>> thrown.
>> Any ideas how to draw on a button? Or how to get Graphics object related
>> to
>> the button?
>