473,397 Members | 1,972 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,397 software developers and data experts.

Why does graphics disappear

Hi There,

If I switch from the Form i have drwan my graphics like Rectangle to some
other Window and come back to my graphic window the drawing is disappeared.

How should I go abt it? Can if u can explain me why it happens also it'll be
gr8.

:)

Regards
Rohan
Nov 21 '05 #1
4 9557
"Rohan" <Ro***@discussions.microsoft.com> schrieb:
If I switch from the Form i have drwan my graphics like Rectangle to some
other Window and come back to my graphic window the drawing is
disappeared.


Handle the form's 'Paint' event or override its 'OnPaint' method and draw
the rectangles there ('e.Graphics.Draw*'). The form must be repainted every
time its contents are overlapped by another window.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2
In addition to Herfried's'answer you can also draw your stuff on a bitmap
and set it as the forms backgroundimage.
For example:

Dim myBitmap As New Bitmap(Me.ClientSize.Width, Me.ClientSize.Height)
Dim g As Graphics
g = Graphics.FromImage(myBitmap)
g.FillRectangle(Brushes.Brown, 0, 0, myBitmap.Width, myBitmap.Height)
g.FillEllipse(Brushes.BlueViolet, 0, 0, myBitmap.Width, myBitmap.Height)
g.Dispose()
Me.BackgroundImage = myBitmap

Ofcourse if the size of your form can change you'll have to catch that event
and redraw everything if you want your bitmap to have the same size as your
form.

Drawing on bitmap for example can be handy when you want to create your own
drawing in a picturebox and don't want to redraw everything every time the
paint event fires.

Hth Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.
Nov 21 '05 #3
Private m_BufferBitmap As Bitmap
Private m_BufferGraphics As Graphics

OnLoad **************
m_BufferBitmap = New Bitmap(Me.Size.Width, Me.Size.Height,
Me.CreateGraphics())
m_BufferGraphics = Graphics.FromImage(m_BufferBitmap)

' Clear the new bitmap.
m_BufferGraphics.Clear(Me.BackColor)
*********************

Note: Drawing in the surface should be using m_BufferGraphics object..

On Paint ***************
If Not (m_BufferBitmap Is Nothing) Then e.Graphics.DrawImage(m_BufferBitmap,
0, 0)
**********************

Thanks for the direction Herfried

Regards
Rohan

"Herfried K. Wagner [MVP]" wrote:
"Rohan" <Ro***@discussions.microsoft.com> schrieb:
If I switch from the Form i have drwan my graphics like Rectangle to some
other Window and come back to my graphic window the drawing is
disappeared.


Handle the form's 'Paint' event or override its 'OnPaint' method and draw
the rectangles there ('e.Graphics.Draw*'). The form must be repainted every
time its contents are overlapped by another window.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4
Hi Rohan,

Take a look at this page:
http://www.bobpowell.net/picturebox.htm

I hope it helps a little bit.
Roman

"Rohan" <Ro***@discussions.microsoft.com> сообщил/сообщила в новостях
следующее: news:45**********************************@microsof t.com...
Hi There,

If I switch from the Form i have drwan my graphics like Rectangle to some other Window and come back to my graphic window the drawing is disappeared.
How should I go abt it? Can if u can explain me why it happens also it'll be gr8.

:)

Regards
Rohan

Nov 21 '05 #5

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

Similar topics

0
by: King W.Wang | last post by:
Hi Java gurus, I've copied the following program from the book "Java by Examples". It compiles well with javac. But it does not run as expected. EXPECTED: It is expected that, when you input...
3
by: Supra | last post by:
in vc.net... private void comboBox1_DrawItem(object sender, DrawItemEventArgs e) { Bitmap bmp = new Bitmap(e.Bounds.Width,e.Bounds.Height,e.Graphics); Graphics g = Graphics.FromImage(bmp); ...
3
by: Ace Calhoon | last post by:
Hello, I'm encountering a strange error when printing my forms and reports in Access. Printed documents will intermittently fail to contain graphical elements (i.e. charts will only print labels,...
1
by: James dean | last post by:
Could someone explain how this works. I think the graphics card is used to do blitting and drawing shapes like rectangles. How does it draw using the Graphics card on the PC and why is this feature...
2
by: Christian Soltenborn | last post by:
Hi guys, I have a question to VB .NET: I add a Graphics object to a panel and use a bunch of DrawLine methods etc (it's really nice and convenient). But: As soon as I send my form (which...
8
by: marcus.kwok | last post by:
I am having a weird problem and I have can't figure out why it is happening. I create an OpenFileDialog and set a filename filter. When the dialog first opens, the filter works correctly, and...
0
by: Frank | last post by:
Hi, I use rpy to plot functions and have the following problem. When I execute the following code line by line (start python and then execute line by line) the resulting figure looks as it...
11
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I know I sound like a one-note Johnny on this but I'm still looking for a solution. I need to display characters coming in from a serial port or a socket. I also need to be able to type...
3
by: Peter Webb | last post by:
When I started my current extremely graphics intensive project, I ignored advice in this ng to use the Paint method, and used the alternate CreateGraphics approach. I thought there were some good...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.