E
eBob.com
I know nothing about graphics, but I am trying to fill a panel with a path
gradient brush. From looking at and playing with an example I found it
appears that I have to establish a Graphics object using Graphics.FromHwnd
for my form. Then the coordinates I specify have to be relative to the
form. But since it is the panel I want to paint on I am wondering if there
is some way to get a graphics object which corresponds to a Control such
that I could then specify coordinates relative to the Control (panel in my
case).
Of course I could use Control.Location to translate the Control coordinates
to Form coordinates. But what if the Control is contained within another
Control, which might itself be contained within another Control etc.?
Handling the general case seems to get messy. (I know that there are other
Graphics.Fromxxxxxxxx methods but none sound like they take a Control as an
argument.)
Also, I use my PathGradientBrush (pgbr) like this:
myGraphics.FillRectangle(pgbr, 100, 100, 1040, 1040).
But in my experiments those last four integer arguments which define the
rectangle don't seem to do anything. I can give them any values and I
always get the same result. The only coordinates which seem to matter are
those specified in defining the path to the PathGradientBrush constructor.
What am I missing? Surely those arguments defining the rectangle must be
there for some puropse.
I'd appreciate any help anyone can offer. Thanks, Bob
gradient brush. From looking at and playing with an example I found it
appears that I have to establish a Graphics object using Graphics.FromHwnd
for my form. Then the coordinates I specify have to be relative to the
form. But since it is the panel I want to paint on I am wondering if there
is some way to get a graphics object which corresponds to a Control such
that I could then specify coordinates relative to the Control (panel in my
case).
Of course I could use Control.Location to translate the Control coordinates
to Form coordinates. But what if the Control is contained within another
Control, which might itself be contained within another Control etc.?
Handling the general case seems to get messy. (I know that there are other
Graphics.Fromxxxxxxxx methods but none sound like they take a Control as an
argument.)
Also, I use my PathGradientBrush (pgbr) like this:
myGraphics.FillRectangle(pgbr, 100, 100, 1040, 1040).
But in my experiments those last four integer arguments which define the
rectangle don't seem to do anything. I can give them any values and I
always get the same result. The only coordinates which seem to matter are
those specified in defining the path to the PathGradientBrush constructor.
What am I missing? Surely those arguments defining the rectangle must be
there for some puropse.
I'd appreciate any help anyone can offer. Thanks, Bob