How to simulate the VB6 Autodraw in C+.NET ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi Folks,

I have a VB6 project moved to C+.NET. I got some problem with GDI+.
1. VB6 forms have a Autodraw property which allows the Windows to repaint it
automatically. But there is not so property of forms in C+.NET. If any part
of a form is covered by another form and when the second one moves around the
first form, the content (some 3D color mesh, lines and texts for example) of
the covered form disappears. Redrawing the covered form manually when the
form paint event occurs takes a long time. Is there any where to simulate the
VB6 Autodraw in C+.NET?
2. I need some C+.NET code to capture any forms and client array of forms.

Thanks,

Minfu Lu
 
Minfu,

What you need to do is maintain the state of what you want to draw in
your form. Then, override the OnPaint method on your Form class, calling
the base method, and then painting your shapes/whatever state you want to
paint on the form.

Then, when the form is invalidated, it will be painted correctly.

What do you mean by capturing forms?

Hope this helps.
 
Nicholas,

Capturing forms means to copy the entire form image (including title bar) to
the clipboard.
What do u mean "calling the base method" ? The problem is if a small portion
needs to repaint, I really do not know how to redraw it ?

Thanks,

Minfu

Nicholas Paldino said:
Minfu,

What you need to do is maintain the state of what you want to draw in
your form. Then, override the OnPaint method on your Form class, calling
the base method, and then painting your shapes/whatever state you want to
paint on the form.

Then, when the form is invalidated, it will be painted correctly.

What do you mean by capturing forms?

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Minfu Lu said:
Hi Folks,

I have a VB6 project moved to C+.NET. I got some problem with GDI+.
1. VB6 forms have a Autodraw property which allows the Windows to repaint
it
automatically. But there is not so property of forms in C+.NET. If any
part
of a form is covered by another form and when the second one moves around
the
first form, the content (some 3D color mesh, lines and texts for example)
of
the covered form disappears. Redrawing the covered form manually when the
form paint event occurs takes a long time. Is there any where to simulate
the
VB6 Autodraw in C+.NET?
2. I need some C+.NET code to capture any forms and client array of forms.

Thanks,

Minfu Lu
 
Minfu,

When your overriden OnPaint method is called, your first line will be:

protected override OnPaint(PaintEventArgs e)
{
// Call the base implementation.
base.OnPaint(e);

// Perform your painting HERE.
}

In order to know what section to paint, you can access the ClipRectangle
property on the PaintEventArgs instance passed to you as a parameter. This
will let you know what to paint.

As for capturing the form image, you could just get the device context
of the bitmap you are drawing to (getting the Graphics instance, and then
calling GetHDC) and then do the same for the form. Then, you would just
perform a BltBit to copy the image of the form to the bitmap.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Minfu Lu said:
Nicholas,

Capturing forms means to copy the entire form image (including title bar)
to
the clipboard.
What do u mean "calling the base method" ? The problem is if a small
portion
needs to repaint, I really do not know how to redraw it ?

Thanks,

Minfu

Nicholas Paldino said:
Minfu,

What you need to do is maintain the state of what you want to draw in
your form. Then, override the OnPaint method on your Form class, calling
the base method, and then painting your shapes/whatever state you want to
paint on the form.

Then, when the form is invalidated, it will be painted correctly.

What do you mean by capturing forms?

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Minfu Lu said:
Hi Folks,

I have a VB6 project moved to C+.NET. I got some problem with GDI+.
1. VB6 forms have a Autodraw property which allows the Windows to
repaint
it
automatically. But there is not so property of forms in C+.NET. If any
part
of a form is covered by another form and when the second one moves
around
the
first form, the content (some 3D color mesh, lines and texts for
example)
of
the covered form disappears. Redrawing the covered form manually when
the
form paint event occurs takes a long time. Is there any where to
simulate
the
VB6 Autodraw in C+.NET?
2. I need some C+.NET code to capture any forms and client array of
forms.

Thanks,

Minfu Lu
 
Nicholas Paldino said:
Minfu,

When your overriden OnPaint method is called, your first line will be:

protected override OnPaint(PaintEventArgs e)
{
// Call the base implementation.
base.OnPaint(e);

// Perform your painting HERE.
}

<snip>

You need to be careful about where you call the base OnPaint method. This is
the one that fires the Paint event handlers. If people have hooked up Paint
event handlers to decorate your control/form, performing your painting after
base.OnPaint will overwrite their decoration

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
 
Back
Top