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

Visual Basic assignment

I am having problems with persistant graphics, when I
reduce a form to an Icon I loose my picture.I understand
that graphics objects have no memory and you have to
place the code in the paint event of the graphics object
and place ObjectName_Paint(Nothing,Nothing)at the end of
each event.I have sucsessfully done this using a Form as
my graphics object but when I use a picturebox as my
graphics object it always disapears when reduced to an
icon can anyone help me?
Nov 20 '05 #1
2 2695
Hello,

"Kay Warner" <ka*@warner81.fsnet.co.uk> schrieb:
I am having problems with persistant graphics, when I
reduce a form to an Icon I loose my picture.


Create a 'Bitmap' object ('Dim b As Bitmap = New Bitmap(...)'), get a
'Graphics' object ('Dim g As Graphics = Graphics.FromImage(b)') and draw the
image by using 'g.DrawImage(...)' etc. Don't forget do call the 'Graphics'
object's 'Dispose' method after finishing drawing. In the 'Paint' event
handler, you can draw the bitmap to the surface of the form.

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #2
Kay,
Instead of calling your Paint handler directly:
and place ObjectName_Paint(Nothing,Nothing)at the end of
You should invalidate the object, and optionally call Update. Or call
Refresh with does both Invalidate & Update.

' request that the object repaint itself
ObjectName.Invalidate()

' cause the object to repaint itself right now!
ObjectName.Update()
' request that the object repaint itself, and do it right now!
ObjectName.Refresh()

This way if you have more than one Paint event handler attached to the
object, or the object overrides the OnPaint method, the object will be
painted correctly.

Also:
and place ObjectName_Paint(Nothing,Nothing)at the end of
If you are sending Nothing as the PaintEventArgs, how is your Paint event
getting access to the correct Graphics object, I hope you are NOT calling
ObjectName.CreateGraphics in the Paint event, as the correct graphics object
is supplied to you, via the PaintEventArgs.

Also as Herfried stated if you call Control.CreateGraphics or
Graphics.FromImage be certain to call Graphics.Dispose on the object
returned otherwise you will have a Win32 resources leak. The Graphics object
passed in the PaintEventArgs will be taken care of for you.

Hope this helps
Jay

"Kay Warner" <ka*@warner81.fsnet.co.uk> wrote in message
news:00****************************@phx.gbl... I am having problems with persistant graphics, when I
reduce a form to an Icon I loose my picture.I understand
that graphics objects have no memory and you have to
place the code in the paint event of the graphics object
and place ObjectName_Paint(Nothing,Nothing)at the end of
each event.I have sucsessfully done this using a Form as
my graphics object but when I use a picturebox as my
graphics object it always disapears when reduced to an
icon can anyone help me?

Nov 20 '05 #3

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

Similar topics

3
by: pix | last post by:
Hello, I would like to start learning Visual Basic, and I was wondering if there are any recomendations to any ebooks, or actual books for that matter. I have my eye on this book by John Smiley,...
44
by: Truble | last post by:
Visual Studio .NET is not more efficient to write than VB6. I can write a VB6 App at least twice as fast as in .NET. Why did Microsoft ruin the syntax advantage of VB6 in .NET?
2
by: frossberg | last post by:
Hello! I tried to install the Visual Basic.NET Resource Kit (http://msdn.microsoft.com/vbasic/vbrkit/) but obviously something went very wrong and now it sems impossible both to repair and to...
4
by: sqlguy | last post by:
Why do we have to contact MS for a problem that has been with this compiler from at least the beta of VS 20005. I am so sick and tired of the 30 - 40 clicks it takes to dismiss VS when there is a...
97
by: Master Programmer | last post by:
An friend insider told me that VB is to be killled off within 18 months. I guess this makes sence now that C# is here. I believe it and am actualy surprised they ever even included it in VS 2003 in...
1
by: akshaysk | last post by:
HI, I am new to Visual Basic. For my Assignment i am supposed to write a visual basic program using excel. I have tried many scripts, but receive errors. Can anyone tell me of any website that...
7
by: princessa | last post by:
Hi everyone I am in my first year of university and currently in an intro computer science course. I am asking all of you who know Microsoft Visual Basic 6 to let me know if you are able to give...
11
DUNXALEARE
by: DUNXALEARE | last post by:
Hello everyone! I have a new assignment. I just dont know how to create a data report using ms excell. I need to search particular group of data/records using Visual basic 6. in MS Access and...
1
by: gringgos | last post by:
Hi, i am doing an assignment where i have to send data using bluetooth in Visual Basic and i am facing problem regarding to the coding of the command button send. If anyone out there can help me???...
1
by: gringgos | last post by:
Hi, friends, it's me again, it's the same assignment again, where i have to send the recorded voice in VB and send to another PC using bluetooth connection and the other computer can send their voice...
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: 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:
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
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
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.