Hi, i am currently devloping a set of fully GDI written controls, just 4 fun and to improve my GDI skills
Anyway, my problem is as simple as that i don't get a trackbar to show the correct value when i scroll it..
Heres a picture of my form:
As you can se, i got a box on each side of the trackbar which is currently showing 1 and 10. To calculate the value i first have to multiply the current location of the trackbutton with 100 and dividy it with the width of the trackline and then dividy it width the maximum value - the minimum value, right?
But i just can't get it to work, i am only 15 years old and math is just not my strongest side.. yet..
W1 and W2 is the size of the boxes + the space between them and the trackline.
i think i just attach the whole project to the topic, in case it's not my math that sucks. Feel free to use the code/controls in your own projects, but i will soon relise the complete project.
Also, sorry for my bad English. Half my project is propertly written in Norwegian, i use to translate the functions after i have compleated the project
Anyway, my problem is as simple as that i don't get a trackbar to show the correct value when i scroll it..
Heres a picture of my form:
As you can se, i got a box on each side of the trackbar which is currently showing 1 and 10. To calculate the value i first have to multiply the current location of the trackbutton with 100 and dividy it with the width of the trackline and then dividy it width the maximum value - the minimum value, right?
But i just can't get it to work, i am only 15 years old and math is just not my strongest side.. yet..
W1 and W2 is the size of the boxes + the space between them and the trackline.
VB.NET:
Dim W As Integer = Width
Dim W1 As Integer = S1.Width + 10
Dim W2 As Integer = S2.Width + 10
Dim Midt As Integer = (W - (W1 + Spacing) - (W2 + Spacing) - SliderW)
Dim val As Integer = (((SliderPos - (W1 + Spacing)) * 100) / Midt) '/ (Maximum + Minimum)
val = (val / (Maximum + Minimum)) + Minimum
If val < Minimum Then val = Minimum Else If val > Maximum Then val = Maximum
Value = val
Invalidate()
i think i just attach the whole project to the topic, in case it's not my math that sucks. Feel free to use the code/controls in your own projects, but i will soon relise the complete project.
Also, sorry for my bad English. Half my project is propertly written in Norwegian, i use to translate the functions after i have compleated the project
Attachments
Last edited by a moderator: