Why oh why does it not work? I've said that so many times, but for the life of me cannot figure this one out.
I thought I'd just go and play a little with Region objects for controls. I basically use 3 images with a defined transparency color and generate Region objects from them. I thought it would be a simple matter of being able to set the Region on my custom control depending on the state of the mouse (MouseEnter, MouseLeave, etc...).
So, if the mouse enters the control, I do a good old
this.Region = mouseOverRegion;
That works. MouseLeave occurs so I do:
this.Region = mouseUpRegion;
That works. Mouse enters again, so the same code earlier is run:
this.Region = mouseOverRegion;
InvalidArgumentException with the call stack being:
System.ArgumentException: Invalid parameter used.
at System.Drawing.Region.GetHrgn(Graphics g)
at System.Windows.Forms.Control.GetHRgn(Region region)
at System.Windows.Forms.Control.set_Region(Region value)
at Schmidt6.SKButton.SKButton_MouseEnter(Object sender, EventArgs e)
What? Anyone have any clues on this? I've tried just about everything in the book (except for the one that works naturally) including disposing the current this.Region, setting it to null, calling this.Region.MakeEmpty() and probably a few other things. Nothing seems to get it to work.
Any help/insights appreciated. So much for just “playing around” since I can't quit now until I get it solved.