The following code draws a linear gradient on my desktop application, but I'd
like to learn how to do the same thing on a Pocket PC:

/// <summary>
/// If you'd like to have linear gradients for the background of your
MDI application then do the following:
/// 1. Copy the following 3 methods into your parent form.
/// 2. Call 'InitialzieLinearGradients()' from your parent form's
constructor.
/// </summary>
public void InitializeLinearGradients()
{
foreach (Control c in this.Controls)
{
if (c.GetType().Name == "MdiClient")
{
c.Paint += new
System.Windows.Forms.PaintEventHandler(PaintClientBG);
c.SizeChanged += new System.EventHandler(SizeClientBG);
}
}
}

protected void SizeClientBG(Object sender, EventArgs e)
{
sender = sender as MdiClient;
this.Invalidate();
}

protected void PaintClientBG(Object sender, PaintEventArgs e)
{
MdiClient mc = sender as MdiClient;
e.Graphics.Clip = new Region(mc.ClientRectangle);

LinearGradientBrush lgb = new LinearGradientBrush(mc.ClientRectangle,
Color.LightBlue, Color.Navy, 90F, false);
e.Graphics.FillRectangle(lgb, mc.ClientRectangle);
lgb.Dispose();
}



--
Robert W.
Vancouver, BC
www.mwtech.com

Re: How to draw a Linear Gradient background on a Pocket PC? by Alex

Alex
Tue Jul 19 17:48:34 CDT 2005

http://www.alexfeinman.com/download.asp?doc=GradientFill.zip

--
Alex Feinman
---
Visit http://www.opennetcf.org
"Robert W." <RobertW@discussions.microsoft.com> wrote in message
news:3FE1E6DB-8E4A-434C-8C0C-2918712F1B65@microsoft.com...
> The following code draws a linear gradient on my desktop application, but
> I'd
> like to learn how to do the same thing on a Pocket PC:
>
> /// <summary>
> /// If you'd like to have linear gradients for the background of your
> MDI application then do the following:
> /// 1. Copy the following 3 methods into your parent form.
> /// 2. Call 'InitialzieLinearGradients()' from your parent form's
> constructor.
> /// </summary>
> public void InitializeLinearGradients()
> {
> foreach (Control c in this.Controls)
> {
> if (c.GetType().Name == "MdiClient")
> {
> c.Paint += new
> System.Windows.Forms.PaintEventHandler(PaintClientBG);
> c.SizeChanged += new System.EventHandler(SizeClientBG);
> }
> }
> }
>
> protected void SizeClientBG(Object sender, EventArgs e)
> {
> sender = sender as MdiClient;
> this.Invalidate();
> }
>
> protected void PaintClientBG(Object sender, PaintEventArgs e)
> {
> MdiClient mc = sender as MdiClient;
> e.Graphics.Clip = new Region(mc.ClientRectangle);
>
> LinearGradientBrush lgb = new LinearGradientBrush(mc.ClientRectangle,
> Color.LightBlue, Color.Navy, 90F, false);
> e.Graphics.FillRectangle(lgb, mc.ClientRectangle);
> lgb.Dispose();
> }
>
>
>
> --
> Robert W.
> Vancouver, BC
> www.mwtech.com
>


Re: How to draw a Linear Gradient background on a Pocket PC? by RobertW

RobertW
Tue Jul 19 18:10:03 CDT 2005

Alex,

Thanks! Quite a bit of code to do the same thing one can do so easily in a
WinForms app.

No commenting per say but I tried switching around some parameters to get
the gradient to go from the top to the bottom rather than left to right but
wasn't successful. Any suggestions how I could accomplish this?

--
Robert W.
Vancouver, BC
www.mwtech.com



"Alex Feinman [MVP]" wrote:

> http://www.alexfeinman.com/download.asp?doc=GradientFill.zip
>
> --
> Alex Feinman
> ---
> Visit http://www.opennetcf.org
> "Robert W." <RobertW@discussions.microsoft.com> wrote in message
> news:3FE1E6DB-8E4A-434C-8C0C-2918712F1B65@microsoft.com...
> > The following code draws a linear gradient on my desktop application, but
> > I'd
> > like to learn how to do the same thing on a Pocket PC:
> >
> > /// <summary>
> > /// If you'd like to have linear gradients for the background of your
> > MDI application then do the following:
> > /// 1. Copy the following 3 methods into your parent form.
> > /// 2. Call 'InitialzieLinearGradients()' from your parent form's
> > constructor.
> > /// </summary>
> > public void InitializeLinearGradients()
> > {
> > foreach (Control c in this.Controls)
> > {
> > if (c.GetType().Name == "MdiClient")
> > {
> > c.Paint += new
> > System.Windows.Forms.PaintEventHandler(PaintClientBG);
> > c.SizeChanged += new System.EventHandler(SizeClientBG);
> > }
> > }
> > }
> >
> > protected void SizeClientBG(Object sender, EventArgs e)
> > {
> > sender = sender as MdiClient;
> > this.Invalidate();
> > }
> >
> > protected void PaintClientBG(Object sender, PaintEventArgs e)
> > {
> > MdiClient mc = sender as MdiClient;
> > e.Graphics.Clip = new Region(mc.ClientRectangle);
> >
> > LinearGradientBrush lgb = new LinearGradientBrush(mc.ClientRectangle,
> > Color.LightBlue, Color.Navy, 90F, false);
> > e.Graphics.FillRectangle(lgb, mc.ClientRectangle);
> > lgb.Dispose();
> > }
> >
> >
> >
> > --
> > Robert W.
> > Vancouver, BC
> > www.mwtech.com
> >
>
>

Re: How to draw a Linear Gradient background on a Pocket PC? by Alex

Alex
Tue Jul 19 19:51:45 CDT 2005

I've updated the sample

--
Alex Feinman
---
Visit http://www.opennetcf.org
"Robert W." <RobertW@discussions.microsoft.com> wrote in message
news:8725101C-8723-45EC-BCFC-91622E93E81C@microsoft.com...
> Alex,
>
> Thanks! Quite a bit of code to do the same thing one can do so easily in
> a
> WinForms app.
>
> No commenting per say but I tried switching around some parameters to get
> the gradient to go from the top to the bottom rather than left to right
> but
> wasn't successful. Any suggestions how I could accomplish this?
>
> --
> Robert W.
> Vancouver, BC
> www.mwtech.com
>
>
>
> "Alex Feinman [MVP]" wrote:
>
>> http://www.alexfeinman.com/download.asp?doc=GradientFill.zip
>>
>> --
>> Alex Feinman
>> ---
>> Visit http://www.opennetcf.org
>> "Robert W." <RobertW@discussions.microsoft.com> wrote in message
>> news:3FE1E6DB-8E4A-434C-8C0C-2918712F1B65@microsoft.com...
>> > The following code draws a linear gradient on my desktop application,
>> > but
>> > I'd
>> > like to learn how to do the same thing on a Pocket PC:
>> >
>> > /// <summary>
>> > /// If you'd like to have linear gradients for the background of
>> > your
>> > MDI application then do the following:
>> > /// 1. Copy the following 3 methods into your parent form.
>> > /// 2. Call 'InitialzieLinearGradients()' from your parent form's
>> > constructor.
>> > /// </summary>
>> > public void InitializeLinearGradients()
>> > {
>> > foreach (Control c in this.Controls)
>> > {
>> > if (c.GetType().Name == "MdiClient")
>> > {
>> > c.Paint += new
>> > System.Windows.Forms.PaintEventHandler(PaintClientBG);
>> > c.SizeChanged += new System.EventHandler(SizeClientBG);
>> > }
>> > }
>> > }
>> >
>> > protected void SizeClientBG(Object sender, EventArgs e)
>> > {
>> > sender = sender as MdiClient;
>> > this.Invalidate();
>> > }
>> >
>> > protected void PaintClientBG(Object sender, PaintEventArgs e)
>> > {
>> > MdiClient mc = sender as MdiClient;
>> > e.Graphics.Clip = new Region(mc.ClientRectangle);
>> >
>> > LinearGradientBrush lgb = new
>> > LinearGradientBrush(mc.ClientRectangle,
>> > Color.LightBlue, Color.Navy, 90F, false);
>> > e.Graphics.FillRectangle(lgb, mc.ClientRectangle);
>> > lgb.Dispose();
>> > }
>> >
>> >
>> >
>> > --
>> > Robert W.
>> > Vancouver, BC
>> > www.mwtech.com
>> >
>>
>>


Re: How to draw a Linear Gradient background on a Pocket PC? by RobertW

RobertW
Tue Jul 19 23:55:01 CDT 2005

Alex,

Great improvements to the original sample. But I have to share something
with you: Try dropping a control like a button on the form and then rerun it.
On my system - Pocket PC 2003 Emulator and Dell Axim X30 Pocket PC - the
presence of any control seems to deactivate your code.

Is there perhaps some special way one needs to add a control when using such
code?

--
Robert W.
Vancouver, BC
www.mwtech.com



"Alex Feinman [MVP]" wrote:

> I've updated the sample
>
> --
> Alex Feinman
> ---
> Visit http://www.opennetcf.org
> "Robert W." <RobertW@discussions.microsoft.com> wrote in message
> news:8725101C-8723-45EC-BCFC-91622E93E81C@microsoft.com...
> > Alex,
> >
> > Thanks! Quite a bit of code to do the same thing one can do so easily in
> > a
> > WinForms app.
> >
> > No commenting per say but I tried switching around some parameters to get
> > the gradient to go from the top to the bottom rather than left to right
> > but
> > wasn't successful. Any suggestions how I could accomplish this?
> >
> > --
> > Robert W.
> > Vancouver, BC
> > www.mwtech.com
> >
> >
> >
> > "Alex Feinman [MVP]" wrote:
> >
> >> http://www.alexfeinman.com/download.asp?doc=GradientFill.zip
> >>
> >> --
> >> Alex Feinman
> >> ---
> >> Visit http://www.opennetcf.org
> >> "Robert W." <RobertW@discussions.microsoft.com> wrote in message
> >> news:3FE1E6DB-8E4A-434C-8C0C-2918712F1B65@microsoft.com...
> >> > The following code draws a linear gradient on my desktop application,
> >> > but
> >> > I'd
> >> > like to learn how to do the same thing on a Pocket PC:
> >> >
> >> > /// <summary>
> >> > /// If you'd like to have linear gradients for the background of
> >> > your
> >> > MDI application then do the following:
> >> > /// 1. Copy the following 3 methods into your parent form.
> >> > /// 2. Call 'InitialzieLinearGradients()' from your parent form's
> >> > constructor.
> >> > /// </summary>
> >> > public void InitializeLinearGradients()
> >> > {
> >> > foreach (Control c in this.Controls)
> >> > {
> >> > if (c.GetType().Name == "MdiClient")
> >> > {
> >> > c.Paint += new
> >> > System.Windows.Forms.PaintEventHandler(PaintClientBG);
> >> > c.SizeChanged += new System.EventHandler(SizeClientBG);
> >> > }
> >> > }
> >> > }
> >> >
> >> > protected void SizeClientBG(Object sender, EventArgs e)
> >> > {
> >> > sender = sender as MdiClient;
> >> > this.Invalidate();
> >> > }
> >> >
> >> > protected void PaintClientBG(Object sender, PaintEventArgs e)
> >> > {
> >> > MdiClient mc = sender as MdiClient;
> >> > e.Graphics.Clip = new Region(mc.ClientRectangle);
> >> >
> >> > LinearGradientBrush lgb = new
> >> > LinearGradientBrush(mc.ClientRectangle,
> >> > Color.LightBlue, Color.Navy, 90F, false);
> >> > e.Graphics.FillRectangle(lgb, mc.ClientRectangle);
> >> > lgb.Dispose();
> >> > }
> >> >
> >> >
> >> >
> >> > --
> >> > Robert W.
> >> > Vancouver, BC
> >> > www.mwtech.com
> >> >
> >>
> >>
>
>

Re: How to draw a Linear Gradient background on a Pocket PC? by Alex

Alex
Wed Jul 20 00:55:36 CDT 2005

Not on mine. Why don't you try debugging it, see if you get inside pb_Paint
at all?

--
Alex Feinman
---
Visit http://www.opennetcf.org
"Robert W." <RobertW@discussions.microsoft.com> wrote in message
news:32282168-301B-4979-8592-08DBB4CF3050@microsoft.com...
> Alex,
>
> Great improvements to the original sample. But I have to share something
> with you: Try dropping a control like a button on the form and then rerun
> it.
> On my system - Pocket PC 2003 Emulator and Dell Axim X30 Pocket PC - the
> presence of any control seems to deactivate your code.
>
> Is there perhaps some special way one needs to add a control when using
> such
> code?
>
> --
> Robert W.
> Vancouver, BC
> www.mwtech.com
>
>
>
> "Alex Feinman [MVP]" wrote:
>
>> I've updated the sample
>>
>> --
>> Alex Feinman
>> ---
>> Visit http://www.opennetcf.org
>> "Robert W." <RobertW@discussions.microsoft.com> wrote in message
>> news:8725101C-8723-45EC-BCFC-91622E93E81C@microsoft.com...
>> > Alex,
>> >
>> > Thanks! Quite a bit of code to do the same thing one can do so easily
>> > in
>> > a
>> > WinForms app.
>> >
>> > No commenting per say but I tried switching around some parameters to
>> > get
>> > the gradient to go from the top to the bottom rather than left to right
>> > but
>> > wasn't successful. Any suggestions how I could accomplish this?
>> >
>> > --
>> > Robert W.
>> > Vancouver, BC
>> > www.mwtech.com
>> >
>> >
>> >
>> > "Alex Feinman [MVP]" wrote:
>> >
>> >> http://www.alexfeinman.com/download.asp?doc=GradientFill.zip
>> >>
>> >> --
>> >> Alex Feinman
>> >> ---
>> >> Visit http://www.opennetcf.org
>> >> "Robert W." <RobertW@discussions.microsoft.com> wrote in message
>> >> news:3FE1E6DB-8E4A-434C-8C0C-2918712F1B65@microsoft.com...
>> >> > The following code draws a linear gradient on my desktop
>> >> > application,
>> >> > but
>> >> > I'd
>> >> > like to learn how to do the same thing on a Pocket PC:
>> >> >
>> >> > /// <summary>
>> >> > /// If you'd like to have linear gradients for the background of
>> >> > your
>> >> > MDI application then do the following:
>> >> > /// 1. Copy the following 3 methods into your parent form.
>> >> > /// 2. Call 'InitialzieLinearGradients()' from your parent
>> >> > form's
>> >> > constructor.
>> >> > /// </summary>
>> >> > public void InitializeLinearGradients()
>> >> > {
>> >> > foreach (Control c in this.Controls)
>> >> > {
>> >> > if (c.GetType().Name == "MdiClient")
>> >> > {
>> >> > c.Paint += new
>> >> > System.Windows.Forms.PaintEventHandler(PaintClientBG);
>> >> > c.SizeChanged += new System.EventHandler(SizeClientBG);
>> >> > }
>> >> > }
>> >> > }
>> >> >
>> >> > protected void SizeClientBG(Object sender, EventArgs e)
>> >> > {
>> >> > sender = sender as MdiClient;
>> >> > this.Invalidate();
>> >> > }
>> >> >
>> >> > protected void PaintClientBG(Object sender, PaintEventArgs e)
>> >> > {
>> >> > MdiClient mc = sender as MdiClient;
>> >> > e.Graphics.Clip = new Region(mc.ClientRectangle);
>> >> >
>> >> > LinearGradientBrush lgb = new
>> >> > LinearGradientBrush(mc.ClientRectangle,
>> >> > Color.LightBlue, Color.Navy, 90F, false);
>> >> > e.Graphics.FillRectangle(lgb, mc.ClientRectangle);
>> >> > lgb.Dispose();
>> >> > }
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > Robert W.
>> >> > Vancouver, BC
>> >> > www.mwtech.com
>> >> >
>> >>
>> >>
>>
>>


Re: How to draw a Linear Gradient background on a Pocket PC? by RobertW

RobertW
Wed Jul 20 01:08:01 CDT 2005

Alex,

Yes, it is entering that method but it's not painting. I don't think
there's anything special or unusual about my system. And the problem is
showing up on both the Emulator and the Pocket PC itself.

I don't know if you're interested, but I took a screenshot and zipped up
your modified code. It's available here:
http://mwtech.com/downloads/GradientFill2.zip

--
Robert W.
Vancouver, BC
www.mwtech.com



"Alex Feinman [MVP]" wrote:

> Not on mine. Why don't you try debugging it, see if you get inside pb_Paint
> at all?


Re: How to draw a Linear Gradient background on a Pocket PC? by Alex

Alex
Wed Jul 20 13:32:29 CDT 2005

Ok, the problem is caused by the driver refusing to do gradient fill on a
non-contiguous display context. I've modified the code to use off-screen
painting. See http://www.alexfeinman.com/download.asp?doc=GradientFill2.zip


--
Alex Feinman
---
Visit http://www.opennetcf.org
"Robert W." <RobertW@discussions.microsoft.com> wrote in message
news:7EAF3BDB-A6B8-4603-B41E-3021ABB35B32@microsoft.com...
> Alex,
>
> Yes, it is entering that method but it's not painting. I don't think
> there's anything special or unusual about my system. And the problem is
> showing up on both the Emulator and the Pocket PC itself.
>
> I don't know if you're interested, but I took a screenshot and zipped up
> your modified code. It's available here:
> http://mwtech.com/downloads/GradientFill2.zip
>
> --
> Robert W.
> Vancouver, BC
> www.mwtech.com
>
>
>
> "Alex Feinman [MVP]" wrote:
>
>> Not on mine. Why don't you try debugging it, see if you get inside
>> pb_Paint
>> at all?
>


Re: How to draw a Linear Gradient background on a Pocket PC? by RobertW

RobertW
Wed Jul 20 13:45:03 CDT 2005

Alex,

Thanks!!!

Works great on both my Dell Axim X30 and the Pocket PC 2003 Emulator!

--
Robert W.
Vancouver, BC
www.mwtech.com



"Alex Feinman [MVP]" wrote:

> Ok, the problem is caused by the driver refusing to do gradient fill on a
> non-contiguous display context. I've modified the code to use off-screen
> painting. See http://www.alexfeinman.com/download.asp?doc=GradientFill2.zip
>
>
> --
> Alex Feinman
> ---
> Visit http://www.opennetcf.org
> "Robert W." <RobertW@discussions.microsoft.com> wrote in message
> news:7EAF3BDB-A6B8-4603-B41E-3021ABB35B32@microsoft.com...
> > Alex,
> >
> > Yes, it is entering that method but it's not painting. I don't think
> > there's anything special or unusual about my system. And the problem is
> > showing up on both the Emulator and the Pocket PC itself.
> >
> > I don't know if you're interested, but I took a screenshot and zipped up
> > your modified code. It's available here:
> > http://mwtech.com/downloads/GradientFill2.zip
> >
> > --
> > Robert W.
> > Vancouver, BC
> > www.mwtech.com
> >
> >
> >
> > "Alex Feinman [MVP]" wrote:
> >
> >> Not on mine. Why don't you try debugging it, see if you get inside
> >> pb_Paint
> >> at all?
> >
>
>

Re: How to draw a Linear Gradient background on a Pocket PC? by Gizmo

Gizmo
Thu Nov 24 02:32:03 CST 2005

Hi Alex,
i'm tryed to download your code on the link below, but it doesn't work.
How could I get it?

Thanks
Gizmo

"Alex Feinman [MVP]" wrote:

> http://www.alexfeinman.com/download.asp?doc=GradientFill.zip
>
> --
> Alex Feinman
> ---
> Visit http://www.opennetcf.org
> "Robert W." <RobertW@discussions.microsoft.com> wrote in message
> news:3FE1E6DB-8E4A-434C-8C0C-2918712F1B65@microsoft.com...
> > The following code draws a linear gradient on my desktop application, but
> > I'd
> > like to learn how to do the same thing on a Pocket PC:
> >
> > /// <summary>
> > /// If you'd like to have linear gradients for the background of your
> > MDI application then do the following:
> > /// 1. Copy the following 3 methods into your parent form.
> > /// 2. Call 'InitialzieLinearGradients()' from your parent form's
> > constructor.
> > /// </summary>
> > public void InitializeLinearGradients()
> > {
> > foreach (Control c in this.Controls)
> > {
> > if (c.GetType().Name == "MdiClient")
> > {
> > c.Paint += new
> > System.Windows.Forms.PaintEventHandler(PaintClientBG);
> > c.SizeChanged += new System.EventHandler(SizeClientBG);
> > }
> > }
> > }
> >
> > protected void SizeClientBG(Object sender, EventArgs e)
> > {
> > sender = sender as MdiClient;
> > this.Invalidate();
> > }
> >
> > protected void PaintClientBG(Object sender, PaintEventArgs e)
> > {
> > MdiClient mc = sender as MdiClient;
> > e.Graphics.Clip = new Region(mc.ClientRectangle);
> >
> > LinearGradientBrush lgb = new LinearGradientBrush(mc.ClientRectangle,
> > Color.LightBlue, Color.Navy, 90F, false);
> > e.Graphics.FillRectangle(lgb, mc.ClientRectangle);
> > lgb.Dispose();
> > }
> >
> >
> >
> > --
> > Robert W.
> > Vancouver, BC
> > www.mwtech.com
> >
>
>