473,398 Members | 2,343 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,398 software developers and data experts.

When the messagebox disappears, it leaves a white square


I've created a demo program that draws random lines on the form. At the end,
a messagebox pops up with the words"I'm done!". When I click on "OK", the
messagebox disappears, but a white square is left in its place. I can still
see the randomly drawn lines on the form, but some are covered up by the
white square. How do I prevent the white square from showing after the
messagebox closes? Thank you. David
Jul 8 '06 #1
10 1784
if you are using the "Graphics" object to draw lines, this will happen. just
as your lines will go away if you minimize your app. you can either
dynamically create an array to keep track of all the points you draw, or the
way i prefer which is to use a GrpahicsPath object. take a look at the
GraphicsPath and "Start Figure" items. they should be what your looking for,
ive used them and they worked prefectly
--
-iwdu15

Jul 8 '06 #2

I am using the graphics object. Is there an alternative to using the
graphics object for drawing lines? I want to keep it simple because I'm a
newbie to VB.NET. Do I find info on the GraphicsPath object & the Start
Figure in the Help? I've noticed that the same problem happens when I use a
menu. When the menu disappears, there is a blank area. I don't have this
problem with the "same" demo program in VB6. When I click on the messagebox,
it disappears & I can still see the lines.

"iwdu15" wrote:
if you are using the "Graphics" object to draw lines, this will happen. just
as your lines will go away if you minimize your app. you can either
dynamically create an array to keep track of all the points you draw, or the
way i prefer which is to use a GrpahicsPath object. take a look at the
GraphicsPath and "Start Figure" items. they should be what your looking for,
ive used them and they worked prefectly
--
-iwdu15
Jul 9 '06 #3

pcnerd a écrit :
but a white square is left in its place.
It has maybe nothing to do with the program but with ... your graphic
memory. Not enough memory. Check that you free all the objects you use.
Could be!

Michel.

Jul 9 '06 #4
no, its not the graphics memory, if you do not do your drawing in the forms
"OnPaint" method, then when something covers the form, the graphics are lost.
try this, create a sample app and put a button on the form, in the button
click event, draw a couple lines. minimize the form, the bring it back up.
the lines are gone, now if you do the same thing but put the drawing events
in the forms "Paint" event, the lines will stay so in the button click even,
put Me.Invalidate() and in the Paint event, put the drawing code. voila!

so to answer your question, you have to do one of the following: all drawing
in the Paint event, keep track of the points you draw and redraw the lines
when necessary, or use a GraphicsPath object, which you can read about in
help under System.Drawing2D
--
-iwdu15
Jul 9 '06 #5
A faster option is to do your drawing on a bitmap then in the form's
"onpaint" event, copy the bitmap to the form's graphics object using the API
"bitblt".
--
Dennis in Houston
"iwdu15" wrote:
no, its not the graphics memory, if you do not do your drawing in the forms
"OnPaint" method, then when something covers the form, the graphics are lost.
try this, create a sample app and put a button on the form, in the button
click event, draw a couple lines. minimize the form, the bring it back up.
the lines are gone, now if you do the same thing but put the drawing events
in the forms "Paint" event, the lines will stay so in the button click even,
put Me.Invalidate() and in the Paint event, put the drawing code. voila!

so to answer your question, you have to do one of the following: all drawing
in the Paint event, keep track of the points you draw and redraw the lines
when necessary, or use a GraphicsPath object, which you can read about in
help under System.Drawing2D
--
-iwdu15
Jul 9 '06 #6
Using the OnPaint event can give serious performance problems!
As soon as anything has to be (re)painted on your form, you get this
event and your drawcode will execute.

A better way is to use the background image of the form; create a
bitmap, draw on this bitmap, and set this bitmap as background image.
In this way, your drawing will be automaticly updated by the window
repaints.
Dennis wrote:
A faster option is to do your drawing on a bitmap then in the form's
"onpaint" event, copy the bitmap to the form's graphics object using the API
"bitblt".
Jul 9 '06 #7

Now you are totally confusing me! I've gotten different suggestions. I'm
going to put the drawing code in the paint event & put me.invalidate in the
button click event. Something really weird is happening to the random lines
demo. After the 3rd buton click, the lines are drawn & then the form clears
itself!! The next time that I click the button, the lines are drawn again.
Really weird!! Why would it do that?

"Theo Verweij" wrote:
Using the OnPaint event can give serious performance problems!
As soon as anything has to be (re)painted on your form, you get this
event and your drawcode will execute.

A better way is to use the background image of the form; create a
bitmap, draw on this bitmap, and set this bitmap as background image.
In this way, your drawing will be automaticly updated by the window
repaints.
Dennis wrote:
A faster option is to do your drawing on a bitmap then in the form's
"onpaint" event, copy the bitmap to the form's graphics object using the API
"bitblt".
Jul 10 '06 #8
What happens when you put me.refresh after me.invalidate?

pcnerd wrote:
Now you are totally confusing me! I've gotten different suggestions. I'm
going to put the drawing code in the paint event & put me.invalidate in the
button click event. Something really weird is happening to the random lines
demo. After the 3rd buton click, the lines are drawn & then the form clears
itself!! The next time that I click the button, the lines are drawn again.
Really weird!! Why would it do that?

"Theo Verweij" wrote:
>Using the OnPaint event can give serious performance problems!
As soon as anything has to be (re)painted on your form, you get this
event and your drawcode will execute.

A better way is to use the background image of the form; create a
bitmap, draw on this bitmap, and set this bitmap as background image.
In this way, your drawing will be automaticly updated by the window
repaints.
Dennis wrote:
>>A faster option is to do your drawing on a bitmap then in the form's
"onpaint" event, copy the bitmap to the form's graphics object using the API
"bitblt".
Jul 10 '06 #9
Is setting the background of the form to the bitmap quicker than using the
API "Bitblt" to copy the invalidated section to the form's graphic object in
the "onpaint" event?
--
Dennis in Houston
"Theo Verweij" wrote:
Using the OnPaint event can give serious performance problems!
As soon as anything has to be (re)painted on your form, you get this
event and your drawcode will execute.

A better way is to use the background image of the form; create a
bitmap, draw on this bitmap, and set this bitmap as background image.
In this way, your drawing will be automaticly updated by the window
repaints.
Dennis wrote:
A faster option is to do your drawing on a bitmap then in the form's
"onpaint" event, copy the bitmap to the form's graphics object using the API
"bitblt".
Jul 10 '06 #10

I didn't try putting me.refresh after me.invalidate. Can I use me.refresh
without me.invalidate? I moved the drawing code to the Paint event & as soon
as the form loaded , the program started drawing lines & drawing & drawing. I
couldn't even click on the button on the toolbar. I had a feeling that the
program would start drawing the lines after the form loaded. Why does the
form clear itself after drawing lines for the third time? It's really weird!

"Theo Verweij" wrote:
What happens when you put me.refresh after me.invalidate?

pcnerd wrote:
Now you are totally confusing me! I've gotten different suggestions. I'm
going to put the drawing code in the paint event & put me.invalidate in the
button click event. Something really weird is happening to the random lines
demo. After the 3rd buton click, the lines are drawn & then the form clears
itself!! The next time that I click the button, the lines are drawn again.
Really weird!! Why would it do that?

"Theo Verweij" wrote:
Using the OnPaint event can give serious performance problems!
As soon as anything has to be (re)painted on your form, you get this
event and your drawcode will execute.

A better way is to use the background image of the form; create a
bitmap, draw on this bitmap, and set this bitmap as background image.
In this way, your drawing will be automaticly updated by the window
repaints.
Dennis wrote:
A faster option is to do your drawing on a bitmap then in the form's
"onpaint" event, copy the bitmap to the form's graphics object using the API
"bitblt".
Jul 12 '06 #11

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

Similar topics

6
by: Louise | last post by:
Hi I have written an HTML pages which does not have any colour specifying tags as far I know. When I view this in an Microsoft internet explorer browser it appears with a white background and...
0
by: yurps | last post by:
Hello here is my html, if you click the missing image in the first column on the left, the div is shown, when clicked again the div disappears...but the bottom border disappears as well...Is there...
3
by: Tony Johansson | last post by:
Hello! Assume you want to store field object that a chess board consist of. A chess board consist of 64 fields where each field is either white or black. Now to my question how should I...
5
by: adolf garlic | last post by:
Im trying to return xml from sql. The xml is made up of different fragments, some using FOR XML ... syntax. The result is a valid xml doc. There is a working stored proc that returns the xml In...
5
by: John Bowman | last post by:
Hi, I need some dialog handling help, I must be missing something obvious here but I can't figure out the solution to the following problem... Simple Win Forms app that has button on the form....
6
by: Mark | last post by:
Hello all - I'm trying to incorporate a stylesheet into an ASP.Net page but everytime I include the "LINK" code to the .css file in the HEADER location of the HTML code, the background color that...
2
by: Matt Gabbard | last post by:
Greetins all, I have a problem that has me beating my head against the desk.. A simple form with a buttong, creates a sime form via click: --- If lv1.SelectedItems.Count > 0 Then Dim f As...
2
by: spifster | last post by:
Hello all, I am building a collapsable tree using Javascript with DOM in IE. In order to make collapsed cells disappear I have been hiding the text. The cells collapse but still leave borders...
5
tharden3
by: tharden3 | last post by:
How do I remove white space around an icon? I have been using some helpful icon pics from google images to spice up a website that I'm making. In many instances though, the icon is not square, but...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.