tags:

views:

489

answers:

3

Im working on a program which moves a panel within a form. I use a scrollbar to change the panels .Top property. However, this property will only reach -32768. In this case, i need it to go much higher (or lower o0). Is there anyway i can change it to a 32bit int so it can go upto −2147483648?


edit, maybe if i clarify what i am trying to do, you lot wont think it will be bad for useability.

Yesterday i asked this question: http://stackoverflow.com/questions/946840/c-vscrollbar-hscrollbar

But because i couldnt find an answer and no1 else answered me, i had to think of a different way to scroll a richtextbox. So my solution was to resize the textbox height to equal (textbox font height * total lines). That would mean that no scrollbars on the textbox would be shown. Now i use the scrollbar to move the textboxes top position to create a pseudo scroll effect. It works perfectly when the textbox has about 2000 lines at 13pixels as font height. But after that it ends up being higher then a 16bit int. Thats why i need to change it to a 32bit int.

+2  A: 

The Windows scrollbars themselves are tied to 16bit values. The WinForm scrollbars just reflect that limit. You can't change it without writing your own scrollbar control from scratch.

But you don't need to do that. There is no physical reason to have that many values in a scrollbar because you can't scroll it more finely than pixels are there in the screen, and your monitor is not more that 30000 pixels tall (or wide).

The normal pattern is to divide your domain value by an appropriate number. Usually a constant will do, but you can use your maximum as well. Then you use that value as the actual scrollbar indexes.

For example, let's say you have values that range from 0 to 1200355. You can the scrollbar's maximum value to 10000, and then you can retrieve the currently selected value as myScrollbar.Value*(10000/1200355) (or some such -- I don't have the exact syntax at hand).

Yes, that means that you lose some precision -- you won't be able to select a value on the scrollbar that differ by just 3 units. If you really need that kind of precision, then the scrollbar control is not the right tool.

Euro Micelli
I think judging by your answer, you didnt quite get what i ment. My scrollbar is just a normal scrollbar with a maximum of 1000. its the panel that needs to have a top of greater then 30000
Ozzy
A: 

Ultimately if you have a panel that needs to go higher than the limit of a scroll bar, you can multiply your scrollbar value by a specific multiplier.

 panel1.top = scrollbar1.value * 3;

The multiplier can be any value that is suitable for your needs. That being said, a screen of over 30000 pixels is quite large.

Additionally you can make your scroll bar value proportionate to your maximum range of values needed.

areaHeight = 60000;
scrolldelta = areaHeight / scrollbar1.MaxValue;

panel1.Top = scrolldelta * scrollbar1.value;
Darien Ford
A: 

Ozzy even am looking out to solve a similar issue.i need to scroll my panel and wanted to change it to 32 bit int.

did u get any solution for your problem that u r facing if so do help me out too....

thanks ss

sss
You should post your similar issue as a separate question, with details. You can link back to this question as a reference if you need to.
Bill the Lizard