views:

33

answers:

2

Hi,

I'm trying to find a way to compute the scroll unit (num. of pixels the screen moves down when u click once on the down arrow in the scrollbar). The msdn documentation for SB_LINEUP says :

Decrements the scroll box position; scrolls toward the top of the data by one unit. In each case, a unit is defined by the application as appropriate for the data.

Is there anyway for us to find out what the value of 1 scroll unit is, for a given window??

Any help would be appreciated. Thanks.

A: 

Check out SystemInformation.MouseWheelScrollLines Property:

The MouseWheelScrollLines property indicates how many lines to scroll, by default, in a multi-line control that has a scroll bar. The corresponding Platform SDK system-wide parameters are SPI_GETWHEELSCROLLLINES and SPI_SETWHEELSCROLLLINES. For more information about system-wide parameters, see "SystemParametersInfo" in the Platform SDK documentation at http://msdn.microsoft.com.

SwDevMan81
This property would give me the number of units that the scrollbar would move when i rotate the mouse wheel. But what i'm interested in is how many pixels does one unit of scrolling constitute ?? When i do a manual test, it seems around 20 pixels. But how do i get this programatically ?!
kambamsu
A: 

I've found out a way to find it out. For future reference for others:

hdc = GetDC (hwnd); 
    // Extract font dimensions from the text metrics. 
    GetTextMetrics (hdc, &tm); 
    int pixelCnt= tm.tmHeight + tm.tmExternalLeading;

Ref: http://msdn.microsoft.com/en-us/library/bb787531%28VS.85%29.aspx

kambamsu