473,396 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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
Nov 17 '05 #1
4 2139
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]
- mv*@spam.guard.caspershouse.com

"Minfu Lu" <Mi*****@discussions.microsoft.com> wrote in message
news:6B**********************************@microsof t.com...
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

Nov 17 '05 #2
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 [.NET/C# MVP]" wrote:
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]
- mv*@spam.guard.caspershouse.com

"Minfu Lu" <Mi*****@discussions.microsoft.com> wrote in message
news:6B**********************************@microsof t.com...
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


Nov 17 '05 #3
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]
- mv*@spam.guard.caspershouse.com

"Minfu Lu" <Mi*****@discussions.microsoft.com> wrote in message
news:CB**********************************@microsof t.com...
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 [.NET/C# MVP]" wrote:
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]
- mv*@spam.guard.caspershouse.com

"Minfu Lu" <Mi*****@discussions.microsoft.com> wrote in message
news:6B**********************************@microsof t.com...
> 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
>
>


Nov 17 '05 #4
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:e4**************@tk2msftngp13.phx.gbl...
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
Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Christian | last post by:
Hello, As the subject says it, is there a way to simulate a special keypress in JS ? In my case, on loading an HTML page, i'd like to set the cursor at the end of the input text of an <input...
1
by: charliewest | last post by:
I am trying use server controls or web controls to simulate the following behavior. I've an image wrapped w/in a link to create a rollover effect as if both elements we're one graphic: <a...
10
by: JustSomeGuy | last post by:
I need to log into a web page automatically. The web page has a password text field and a login button. (A form?) How do I simulate that a user logged in and entered the password and pressed...
2
by: dast | last post by:
I want to simulate an input and post into a web page and than download the web page that is opened after the correct input! The web page exists of an user input form with userid and password, after...
61
by: /* frank */ | last post by:
I have to do a homework: make a CPU simulator using C language. I have a set of asm instructions so I have to write a program that should: - load .asm file - view .asm file - do a step by step...
4
by: johnny | last post by:
On a form I would like to simulate a button click when the Enter is pressed. My form is setup and it works if the delegate for the key pressed on the form calls the delegate for the button pressed....
1
by: diegocarpintero | last post by:
I am writing a c# class which main purpose is to simulate the dialog with a GUI-application. The idea is that this class can simulate some user actions like mouse clicks on buttons. I have...
1
by: =?Utf-8?B?UmljYXJkbyBRdWludGFuaWxsYQ==?= | last post by:
how to simulate a different time zone? ¿is it possible by code to simulate that i am in a different time zone just for to execute a few lines of code? in my case i am in the time zone...
4
by: c0mm3nt | last post by:
Hi Guys. I'm writing a web crawler (web spider) that crawl all links in a website. My application is a Win32 App, written in C# with .Net framework 3.5. Now I'm using HttpWebRequest an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.