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

drawing problem w/ clearing

I just started my first project where i draw lines and strings on the
screen. I sucessfully drew what i needed on the screen, then realized that
when it updated it just drew over the same area w/o clearing the first
instance of text and lines. How can i clear it? Below is my code,
basically it is a thermometer and my program is drawing a red line the
height of the temp and drawing the temp on the red bubble.
Dim g As Graphics

Dim b As New Bitmap(pictherm.Image)

Dim y As Integer

Dim tempint As Integer

'120 degrees => y = 20

'-20 degrees -> y = 230

If tempcheck() = True Then

'tempcheck() will check if temp value is a real integer or string = "N/A"

tempint = CInt(currentWeather.currentconditions.tmp)

If settings.units = "s" Then

'degrees F

y = CInt(Math.Round((-1.5) * CInt(currentWeather.currentconditions.tmp) +
200))

End If

If settings.units = "m" Then

'degrees C

y = CInt(Math.Round((-2.69) * CInt(currentWeather.currentconditions.tmp) +
151.92))

End If

Dim f As New Font("Arial", 16, FontStyle.Bold)

g = Graphics.FromImage(b)

Dim textposx As Integer = 30

If tempint >= 100 Then

textposx = 24

End If

If tempint < 0 Then

textposx = 26

End If

If tempint >= 0 And tempint < 100 Then

textposx = 30

End If

g.DrawLine(New Pen(Color.Red, 28), 46, y, 46, 242)

g.DrawString(currentWeather.currentconditions.tmp, f, New
SolidBrush(Color.White), textposx, 250)

pictherm.Image = b

g.Dispose()

End If
Dec 10 '05 #1
1 1309
asdf wrote:
I just started my first project where i draw lines and strings on the
screen. I sucessfully drew what i needed on the screen, then realized that
when it updated it just drew over the same area w/o clearing the first
instance of text and lines. How can i clear it? Below is my code,
basically it is a thermometer and my program is drawing a red line the
height of the temp and drawing the temp on the red bubble.
Dim g As Graphics

Dim b As New Bitmap(pictherm.Image)

Dim y As Integer

Dim tempint As Integer

'120 degrees => y = 20

'-20 degrees -> y = 230

If tempcheck() = True Then

'tempcheck() will check if temp value is a real integer or string = "N/A"

tempint = CInt(currentWeather.currentconditions.tmp)

If settings.units = "s" Then

'degrees F

y = CInt(Math.Round((-1.5) * CInt(currentWeather.currentconditions.tmp) +
200))

End If

If settings.units = "m" Then

'degrees C

y = CInt(Math.Round((-2.69) * CInt(currentWeather.currentconditions.tmp) +
151.92))

End If

Dim f As New Font("Arial", 16, FontStyle.Bold)

g = Graphics.FromImage(b)

Dim textposx As Integer = 30

If tempint >= 100 Then

textposx = 24

End If

If tempint < 0 Then

textposx = 26

End If

If tempint >= 0 And tempint < 100 Then

textposx = 30

End If

g.DrawLine(New Pen(Color.Red, 28), 46, y, 46, 242)

g.DrawString(currentWeather.currentconditions.tmp, f, New
SolidBrush(Color.White), textposx, 250)

pictherm.Image = b

g.Dispose()

End If


Need to understand when you do this... please show more code
Dec 11 '05 #2

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

Similar topics

18
by: Niels | last post by:
Hi group, I have some problems with clearing floated divs. My usual method works fine in Konqueror, but not in Firefox. Here's an example: <html><body> <div id='left' style='float:left;...
0
by: Gary | last post by:
I have a problem with the datagrid not clearing when the datasource changes, a few fields remain on the screen and even when new data would fill those grid squares the old data remains. I wind...
8
by: john | last post by:
Hi I am a C++ newbie, I am looking to draw single lines and simple boxes in a C++ console window. Is there a draw command with x and y coordinates that can be used with my Dev C++ compiler. For...
4
by: Roubles | last post by:
Hi All, Quick question; what is the difference between initializing and clearing a structure like this: mystruct_t a = {0}; and initializing and clearing it like this:
1
by: raghavendra | last post by:
Hi, i am facing problem clearing screen in console application. As, in C++ we have clrscr(); Is? their any similar type of function is avaliable.. Raghavendra...
9
by: Werner Hempel | last post by:
Hello, I'm trying to do a simple three column layout, with two divs (#left and #right) floating left and right, and the #content-div with margins in between, and all three in a wrapper-div. The...
65
by: Steven Watanabe | last post by:
I know that the standard idioms for clearing a list are: (1) mylist = (2) del mylist I guess I'm not in the "slicing frame of mind", as someone put it, but can someone explain what the...
65
by: Leslie Kis-Adam | last post by:
Hi everyone! Does anyone know, if it is possible to clear the screen in ANSI C? If it is,then how? Any help would be appreciated. Laszlo Kis-Adam <dfighter_AT-NOSPAM_freemail.hu
6
by: abdunnabisk | last post by:
I am developing a program in c# where I have to show device connected each other in a dashboard.I am drawing in OnPaint event.when the user move the devices the background is flickering.because each...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.