• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 361
  • Last Modified:

What unit of measurement is involved here?

vb.net 2003

I am using  x= IE.Document.documentElement.scrollTop

What unit of measurement does x represent and how do I convert that into something that equals pixels?

 if I move the scrollbar down 1 pixel x = 2
 if I move the scrollbar down 2 pixels x = 5
 if I move the scrollbar down 3 pixels x = 7
 if I move the scrollbar down 10 pixels x = 24


  • 2
  • 2
1 Solution
The units are pixels.  You seem to be moving the scrollbar by two or three pixels at a time.
HtmlElement.ScrollTop Property
The distance, in pixels, between the top edge of the element and the top edge of its content.

How can this happen? We can only guess. Possibly Explorer manages scrollbar state using float or double variables, and converts them to integer before setting actual scrollbar position.
Suppose that full  document range is 12.0, and one step is 1.2 - this is calculated by Explorer using some criterions. In this case, when user scrolls page, internal counter changes by the following way:
0  1.2  2.4  3.6  4.8   ...

Actual  scrollbar position in pixels is:

0   1     2     4     5   ...
gosonicAuthor Commented:
ozo - I double checked. Only 1 pixel at a time.

I agree that seems to be the case.  To add to the problem when I change monitors x changes also.
Example on a 17 inch display a 100 pixel movement sets x to 229  on a 19 inch display a 100 pixel movement sets x to 293.  Both set at (1024x768)  Go figure, you would think there would be something useful here with IE.Document.documentElement.scrollTop. but I can't find it, yet.  
Many graphics programs work with images using their actual size in mm, inches etc. In .NET you can see Graphics.DpiX and Graphics.DpiY properties. IE doesn't use it but it uses unmanaged API which does the same. Now suppose you have some image whith known pixel size (for example, 1 pixel = 1 mm), and you want to draw it with it's actual size. This is the place for floating-point calculations and setting scroll range. The same may apply to fonts - let's say you want to draw text with 2 mm height on any monitor with any screen resolution.
gosonicAuthor Commented:
I gave the Graphics.DpiX a try and can't find any relief there either. Thanks for all you insight, I going to go to work on a work around - thanks again.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now