• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 358
  • 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?

Example:
 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

Thanks






0
gosonic
Asked:
gosonic
  • 2
  • 2
1 Solution
 
ozoCommented:
The units are pixels.  You seem to be moving the scrollbar by two or three pixels at a time.
0
 
AlexFMCommented:
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   ...
0
 
gosonicAuthor Commented:
ozo - I double checked. Only 1 pixel at a time.

AlexFM
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.  
0
 
AlexFMCommented:
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.
0
 
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.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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