Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

How to clear image control?

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-27-2008, 06:34 PM
Basic4ppc Veteran
 
Join Date: Dec 2008
Posts: 203
Awards Showcase
Beta Tester 
Total Awards: 1
Default How to clear image control?

Maybe a simple one, but I can't see it:
I have a form with on it a simple image control.
On that image control I draw lines with Graham's chart dll.
When I have seen the chart I close the form and I thought that that would
clear the image, but it doesn't, so when I make a new chart and load the form
again I see the old chart plus the new one.

This is the relevant code section:

LineChart.New1(imgChart.Width, imgChart.Height)
LineChart.Text = strTerm
LineChart.Color = Rgb(255,255,230)
LineChart.MaxScaleValue = dMaxValue
LineChart.MinScaleValue = dMinValue 'no effect with positive values
LineChart.ShowGrid = True
LineChart.AddXAxisText(1, 80, strMinDate)
LineChart.AddXAxisText(160, imgChart.Width - 1, strMaxDate)
LineChart.XAxisIntervalValue = 240 'to avoid any ticks on the X-axis

dXAxisFactor = (lMaxDate - lMinDate) / imgChart.Width

LineChart.NewLine(cRed)

For n = 0 To lRecords - 1
'the + 1 and - 1 x-axis adjustments are to prevent
'these values falling of the image on the device
'-------------------------------------------------
If n = 0 Then
LineChart.AddPoint(1, ArrayListValues1.Item(n))
Else
If n < lRecords - 1 Then
LineChart.AddPoint(Int((ArrayListDateTicks.Item(n) - lMinDate) / dXAxisFactor), _
ArrayListValues1.Item(n))
Else
LineChart.AddPoint(imgChart.Width - 1, ArrayListValues1.Item(n))
End If
End If
Next n

Linechart.LineWidth = 1
LineChart.AddLine

imgChart.Image = LineChart.Draw
frmChart.Show



The arraylists are cleared before adding new values (from a SQLite Reader) and they are not the problem.
Thanks again for any advice.

RBS
Reply With Quote
  #2 (permalink)  
Old 12-27-2008, 06:46 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by RB Smissaert View Post
imgChart.Image = LineChart.Draw
This line assigns a new Bitmap ,with the chart drawn on it, to the Image property of the Image control. I can't see how the old Bitmap could still be visible. Are you doing "LineChart.New1(imgChart.Width, imgChart.Height)" the second time around? This is needed to clear the LineChart or you will get the old data redrawn.
Reply With Quote
  #3 (permalink)  
Old 12-27-2008, 06:51 PM
taximania's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire. UK
Posts: 592
Awards Showcase
Beta Tester 
Total Awards: 1
Default

OT:
When posting code, highlight the code text in the input window and click the # icon above it.
This adds the code tag, and makes your post a bit more readable. eg.

Code:
Sub Globals
    
'Declare the global variables here.

End Sub

Sub App_Start
    Form1.Show
End Sub
Sorry for grumbling, grovel, grovel
__________________
.
.
.
Don't ask, I'm fine, honest. !!
.
.
.
Just a little crazy at times



O2 XDA, GW Evo 2.1 UC WWE Rom, WM6.1
Radio Ver 03.34.90
With Basic4ppc V6.80


http://www.taximania.co.uk
Reply With Quote
  #4 (permalink)  
Old 12-27-2008, 06:58 PM
Basic4ppc Veteran
 
Join Date: Dec 2008
Posts: 203
Awards Showcase
Beta Tester 
Total Awards: 1
Default

> Are you doing "LineChart.New1(imgChart.Width, imgChart.Height)" the second time around?

Yes, that runs every time. Just tested it to make sure.
I must be overlooking something simple here.
I have attached the full code of this Sub as a zipped text file.

RBS
Reply With Quote
  #5 (permalink)  
Old 12-27-2008, 07:04 PM
Basic4ppc Veteran
 
Join Date: Dec 2008
Posts: 203
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
highlight the code text in the input window and click the # icon above it.
Ah, yes; thanks for the tip.
Will do that from now on.

RBS
Reply With Quote
  #6 (permalink)  
Old 12-27-2008, 08:18 PM
taximania's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire. UK
Posts: 592
Awards Showcase
Beta Tester 
Total Awards: 1
Default

I'm sorry if I sounded a bit harsh
__________________
.
.
.
Don't ask, I'm fine, honest. !!
.
.
.
Just a little crazy at times



O2 XDA, GW Evo 2.1 UC WWE Rom, WM6.1
Radio Ver 03.34.90
With Basic4ppc V6.80


http://www.taximania.co.uk
Reply With Quote
  #7 (permalink)  
Old 12-27-2008, 08:21 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by RB Smissaert View Post
I have attached the full code of this Sub as a zipped text file.
You are making things unnecessarily complicated. Just post the sbp file then I can run it directly otherwise I have to prat around recreating all the objects etc. and I have too much to do to waste time redoing what you have already done
Reply With Quote
  #8 (permalink)  
Old 12-27-2008, 08:38 PM
Basic4ppc Veteran
 
Join Date: Dec 2008
Posts: 203
Awards Showcase
Beta Tester 
Total Awards: 1
Default

OK, attached the source file. Bear in mind that you can't run it as you haven't got the SQLite db file. This is a very large file, but if you need it then I can make a small one and post that.

RBS
Reply With Quote
  #9 (permalink)  
Old 12-27-2008, 08:40 PM
Basic4ppc Veteran
 
Join Date: Dec 2008
Posts: 203
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
I'm sorry if I sounded a bit harsh
Not at all; I just hadn't looked at the icons.

RBS
Reply With Quote
  #10 (permalink)  
Old 12-27-2008, 11:42 PM
Basic4ppc Veteran
 
Join Date: Dec 2008
Posts: 203
Awards Showcase
Beta Tester 
Total Awards: 1
Default

All solved.
This was a simple and plain bug in my code and sorry to cause and wasted time anywhere.
I have 4 arraylists and they all need clearing before the next chart is made, but I had forgotten to clear ArrayListDateTicks.
Once that was done all was fine.

RBS
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
clear all textboxes tremara1 Questions (Windows Mobile) 0 10-22-2008 08:39 AM
draw line into image control giannimaione Questions (Windows Mobile) 4 06-03-2008 04:40 PM
Drawing on image control derez Basic4ppc Wishlist 10 01-16-2008 04:51 PM
Control IMAGE Joserra Spanish Forum 5 11-14-2007 05:58 PM
Move an image inside an image control Cableguy Questions (Windows Mobile) 5 05-14-2007 07:40 PM


All times are GMT. The time now is 03:34 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0