473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

using GetScrollBarInfo win32 API

hi,
i'm trying to get the width of the vertical scroll bar for some third party
component* i'm using. so i called the GetScrollBarInfo API like so:
[DllImport("user32.dll", SetLastError = true, EntryPoint =
"GetScrollBarInfo")]
private static extern int GetScrollBarInfo(IntPtr hWnd,
uint idObject, ref SCROLLBARINFO psbi);
with these structs:
[StructLayout(LayoutKind.Sequential)]

public struct SCROLLBARINFO

{

public int cbSize;

public RECT rcScrollBar;

public int dxyLineButton;

public int xyThumbTop;

public int xyThumbBottom;

public int reserved;

[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]

public int[] rgstate;

}

public struct RECT

{

public int Left;

public int Top;

public int Right;

public int Bottom;

}

the call is:

private const uint OBJID_VSCROLL = 0xFFFFFFFB;

SCROLLBARINFO info = new SCROLLBARINFO();

info.cbSize = Marshal.SizeOf(info);

int res = GetScrollBarInfo(gridCtrl.Handle, OBJID_VSCROLL, ref info);

the problem is that the numbers i get in SCROLLBARINFO.rcScrollBar don't
make sense. i get this:

buttom = -2141498754; left = -2141498499; right = 69528148; top
= -1460105884

how do i get the scroll bar width from these numbers?

*DevXpress's VerticalGridControl, if it's familiar to you.
Jun 3 '07 #1
1 5248
i figured this out by myself, but just for the record (because i really
searched hard and came up with nothing before posing this): for a vertical
scrollbar, the width is the difference between the left and bottom members
of the RECT struct. this measure, however, is in Twips, so you have to
convert it to pixels for it to have a meaning in .net. i devided it by 15,
but it is possible that it depends on your DPI settings in Windows.
reference: http://support.microsoft.com/kb/210590
http://en.wikipedia.org/wiki/Twip

tsahi

"Tsahi Asher" <ts***@nospam.fantasy.bzwrote in message
news:uC**************@TK2MSFTNGP04.phx.gbl...
hi,
i'm trying to get the width of the vertical scroll bar for some third
party
component* i'm using. so i called the GetScrollBarInfo API like so:
[DllImport("user32.dll", SetLastError = true, EntryPoint =
"GetScrollBarInfo")]
private static extern int GetScrollBarInfo(IntPtr hWnd,
uint idObject, ref SCROLLBARINFO psbi);
with these structs:
[StructLayout(LayoutKind.Sequential)]

public struct SCROLLBARINFO

{

public int cbSize;

public RECT rcScrollBar;

public int dxyLineButton;

public int xyThumbTop;

public int xyThumbBottom;

public int reserved;

[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]

public int[] rgstate;

}

public struct RECT

{

public int Left;

public int Top;

public int Right;

public int Bottom;

}

the call is:

private const uint OBJID_VSCROLL = 0xFFFFFFFB;

SCROLLBARINFO info = new SCROLLBARINFO();

info.cbSize = Marshal.SizeOf(info);

int res = GetScrollBarInfo(gridCtrl.Handle, OBJID_VSCROLL, ref info);

the problem is that the numbers i get in SCROLLBARINFO.rcScrollBar don't
make sense. i get this:

buttom = -2141498754; left = -2141498499; right = 69528148; top
= -1460105884

how do i get the scroll bar width from these numbers?

*DevXpress's VerticalGridControl, if it's familiar to you.

Jun 3 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Joonas Paalasmaa | last post by:
Hi, When compiling Sketch's streamfilter C extension the errors below are raised during linking. What could cause the errors? (Python 2.3, MinGw 1.1 with GCC 2.95.3-6, Windows 98) Here are...
0
by: grutta | last post by:
I am writing a windows service that will recieve notification when a USB Device is insterted into the machine. I have used the RegisterDeviceNotification and the RegisterServiceCtrlHandlerEx with...
5
by: Bryan Parkoff | last post by:
Please provide me the information when it is not in the correct newsgroups. I have been using C and C++ language for a long time when it is time for me to learn Win32 API functions that they can...
0
by: Kenneth H. Brannigan | last post by:
Even though I can see that the scroll bars are visible a call to GetScrollBarinfo says they are not visible: private const uint CONST_OBJID_VSCROLL = 0xFFFFFFFB; private const uint...
3
by: bb | last post by:
I have a windows network device driver written in c++ and a user interface im porting to c#, my problem is i dont seem to be getting notified of the event calls from the driver to the c# app im...
9
by: Martin Ortiz | last post by:
I want to use the Win32 API function : SendMessageToDescendants I want to use it in a VB.Net app, but I have a few questions..... 1) Can one use Win32 API functions in VB.Net 2) Is doing so a...
3
by: Siv | last post by:
Hi, A little while ago I wrote a small program that allowed the user to view products from a database. The database holds the details of the products which can be viewed via a form and...
0
by: Bill Nguyen | last post by:
I ran into this error using ClickOne to deploy a .NET 2.0 app. CrystalReports for .NET 2.0 is included in the delployment. The error indicates that an incorrect version of CrystalReports.Engine DLL...
0
by: Tsahi Asher | last post by:
hi, i'm trying to get the width of the vertical scroll bar for some third party component* i'm using. so i called the GetScrollBarInfo API like so: private static extern int...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.