How to erase a DrawString on a form?

Stellaferox

Active Member
Licensed User
Hi,
I am trying to erase a DrawString on a form but FErase won't do it. Is there another way except rewriting the string in the backgroundcolour?
 

Stellaferox

Active Member
Licensed User
Erel, you must be desperate for all the stupid questions you get.... I forgot the F in front of the Drawstringcommand. Now it works fine...
tnx
 

Stellaferox

Active Member
Licensed User
Meanwhile, let me propose a problem. In the attached program I want to change the Mean and SD from 100 and 16 to 0 and 1 respectively. I want to show the change on the x-axis as soon as the new value is filled in in the textbox (let's say the 0 in the Mean textbox without ENTER). Now I have to switch textboxes and back to show the change.
Any ideas?
 

Stellaferox

Active Member
Licensed User
hmmmmm.... to quick again... here is the file... the subs are tbMean_GotFocus and tbSD_GotFocus.
thnx in advance....
Marc
 

Attachments

  • $Normal.sbp
    15.9 KB · Views: 265

Cableguy

Expert
Licensed User
Longtime User
Entering the values does not raise any event..that is the problem...The only way I would see this working would be enableing a timer when a textbox got focus and the on timer.tick do a lost focus to the textbox, raising this way the lostfocus event...
 

Stellaferox

Active Member
Licensed User
something like:?

Sub tbSD_GotFocus
Timer1.Interval = 10 'milliseconds
Timer1.Enabled = True
End Sub

Sub Timer1_Tick
Mean = tbMean.Text
SD = tbSd.Text
InitXaxis
Timer1.Enabled = False
End Sub

it doesnt change while waiting...
 

Stellaferox

Active Member
Licensed User
I did it like this, but I do not think this is the most elegant solution...

Sub tbMean_GotFocus
Timer.Interval = 1000 'milliseconds
Timer.Enabled = True
End Sub

Sub tbMean_LostFocus
Timer.Enabled = False
End Sub

Sub tbSD_GotFocus
Timer.Interval = 1000 'milliseconds
Timer.Enabled = True
End Sub

Sub tbSD_LostFocus
Timer.Enabled = False
End Sub

Sub Timer_Tick
Mean = tbMean.Text
SD = tbSd.Text
InitXaxis
End Sub
 

Cableguy

Expert
Licensed User
Longtime User
I was thinking more in the lines of this:

sub textbox1_gotfocus
Timer1.interval=1000
timer1.enabled=true
End Sub

Sub Timer1_Tick
Timer1.Enabled=False
somecontrol.Focus (This will raise the textbox1_lostfocus)
EndSub

Sub Textbox1_lostfocus
This is were you enter the variabl values
End Sub
 

agraham

Expert
Licensed User
Longtime User
Why don't you capture each key press, check for enter and call the lost_focus sub. That way you get an update on leaving the control or on pressing enter.

Sub tbMean_KeyPress (key)
if Asc(Key) = 13 then
tbMean_LostFocus
end if
End Sub


If you want to know what the text box is going to contain after the key press, key isn't added to the textbox until after the event is fired

Sub tbMean_KeyPress (key)
NewText = tbMean.text & key
' do something if necessary
End Sub

By the way. I don't know if you have noticed but your (I think this what it is called as I haven't got the program in front of me) Clear_Area routine is clearing parts of the curve as well.
 
Last edited:

Stellaferox

Active Member
Licensed User
Hi Agraham,
Thnx for your input. i will try that as well...
I know the Erase part of the graph is ersing some points but I dont know how to avoid that. I am calling the Erase function one pixel below the graph so it shouldnt erase parts of the graph. Havent found out how to erase just below the graph otherwise....
Marc
 

Louis

Active Member
Licensed User
Longtime User
Hi there. You know, a while ago on this very forum, Erel added a library called barcode.dll that supports the textbox changed event that will raise each time a text box changes. I cannot remember the URL, but maybe if you write barcode in the search box of the forum you may find it and play around with it and see if that makes things a bit less daunting? Just a thought. Take care then.
 

agraham

Expert
Licensed User
Longtime User
I know the Erase part of the graph is ersing some points but I dont know how to avoid that. I am calling the Erase function one pixel below the graph so it shouldnt erase parts of the graph. Havent found out how to erase just below the graph otherwise
It is because you are doing graphics work using floating point numbers and the rounding to pixel Y values and X co-ordinates is working against you. You are also generating far more data than can be displayed, something like 800 data points rather than 215.

Ideally you need an array, 0 to 214, in your case, holding integer values. I believe that if you declare an array "as int16" you get an array of 16 bit integers (non-array variables are always 64 bit floating point) or you can obtain them by the int(somevariable) function. You can then draw your graphics with both integer X (array index) and Y (array value) and predict exactly what it will look like when you do co-ordinate arithmetic. If you need a more precise value for other puposes you can either have a "shadow" array holding those more precise values or calculate them using a corrected X index like (X-grwidth/2)/(215/8) as the input value to your formula.
 

Stellaferox

Active Member
Licensed User
Agraham, thanx, I have already tried out the exact resolution for my pixels and used the INT function in the earlier stages of development. The reason I sticked with this original is that there used to be a function to invert all the data back to probability. Since it is not included I can go easily back to my original and your suggestion. Thanks for that!
Marc
 
Top