ListBox with horizontal scroll bar

C

Christian Schwarz

Hello,

I understand that the .NET CF controls are wrappers around the native Win32
controls. As the native ListBox under Windows CE seems to support a
horizontal scroll bar it should be possible to extend the .NET ListBox with
an horizontal scroll bar by using Win32 API functions.

Using the following code, I get the handle of my ListBox.

[DllImport("coredll.dll")]
static extern IntPtr GetCapture();

....
myListBox.Capture = true;
IntPtr hWndListBox = GetCapture();
....

The following code enables the horizontal scroll bar by setting the
WS_HSCROLL window style.

[DllImport("coredll.dll")]
static extern uint GetWindowLong(IntPtr hwnd, int index);
[DllImport("coredll.dll")]
static extern void SetWindowLong(IntPtr hwnd, int index, uint value);

....
uint windowLong = GetWindowLong(hWndListBox, -16) | 0x00100000;
SetWindowLong(hWndListBox, -16, windowLong);
....

Now that the horizontal scroll bar is visible one can use SetScrollInfo API
function to set the minimum, maximum and current scroll position. Although
setting the scroll position works, the scrolling of the ListBox content
doesn't work.

What could be the reason? Who is responsible for doing the actual scrolling?
The native Win32 ListBox control? Is there a general problem with my
approach?

Greetings, Christian
 
G

Guest

Just send the LB_SETHORIZONTALEXTENT message after you modified the style:

const int LB_SETHORIZONTALEXTENT = 0x194;

SendMessage(hWndListBox, LB_SETHORIZONTALEXTENT, 250, 0);
 
C

Christian Schwarz

Just send the LB_SETHORIZONTALEXTENT message after you modified the style:
const int LB_SETHORIZONTALEXTENT = 0x194;

SendMessage(hWndListBox, LB_SETHORIZONTALEXTENT, 250, 0);

Many thanks, that solved my problem!

Greetings, Christian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top