473,498 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[VB NET] Syncronize hscrollbar and listview

Hi everybody!
Could anyone know how can I syncronize a
horizontal scrollbar with a listview?
Actually I can only syncronize the horizontal scrollbar with the
listview horizontal scrollbar, but items and subitems don't move.
The code is:

API declaration
' Scrollbar direction
' All these constents can be found in WinUser.h
'
Const SBS_HORZ = 0
Const SBS_VERT = 1

' Windows Messages
' All these constents can be found in WinUser.h
'
Const WM_VSCROLL = &H115
Const WM_HSCROLL = &H114
Const SB_THUMBPOSITION = 4

Public Enum eScrollAction
Jump = 0
Relitive = 1
End Enum

Public Enum eScrollDirection
Vertical = 0
Horizontal = 1
End Enum
' API Function: GetScrollPos
' Returns an integer of the position of the scrollbar
'
Private Declare Function GetScrollPos Lib "user32.dll" ( _
ByVal hWnd As IntPtr, _
ByVal nBar As Integer) As Integer

' API Function: SetScrollPos
' Sets ONLY the scrollbar DOES NOT change the control object
'
Private Declare Function SetScrollPos Lib "user32.dll" ( _
ByVal hWnd As IntPtr, _
ByVal nBar As Integer, _
ByVal nPos As Integer, _
ByVal bRedraw As Boolean) As Integer

' API Function: PostMessageA
' Sends a message to a control (We are going to tell it to synch
' with the scrollbar)
'
Private Declare Function PostMessageA Lib "user32.dll" ( _
ByVal hwnd As IntPtr, _
ByVal wMsg As Integer, _
ByVal wParam As Integer, _
ByVal lParam As Integer) As Boolean
--------------

On the Scroll event of the horizontal scroll bar:

scrollControl(ListView1.Handle, eScrollDirection.Horizontal,
eScrollAction.Jump, HSB.Value * 2)

----------------

Sub & Functrions:

Private Sub scrollControl(ByVal hWnd As IntPtr, ByVal Direction As
eScrollDirection, _
ByVal Action As eScrollAction, ByVal
Amount As Integer)

Dim position As Integer

' What direction are we going
If Direction = eScrollDirection.Horizontal Then

' What action are we taking (Jumping or Relative)
If Action = eScrollAction.Relitive Then
position = GetScrollPos(hWnd, SBS_HORZ) + Amount
Else
position = Amount
End If

' Make it so
If (SetScrollPos(hWnd, SBS_HORZ, position, True) <> -1)
Then
PostMessageA(hWnd, WM_HSCROLL, SB_THUMBPOSITION +
&H10000 * position, Nothing)
Else
MsgBox("Can't set info (Err: " & GetLastWin32Error() &
")")
End If

Else

' What action are we taking (Jumping or Relative)
If Action = eScrollAction.Relitive Then
position = GetScrollPos(hWnd, SBS_VERT) + Amount
Else
position = Amount
End If

' Make it so
If (SetScrollPos(hWnd, SBS_VERT, position, True) <> -1)
Then
PostMessageA(hWnd, WM_VSCROLL, SB_THUMBPOSITION +
&H10000 * position, Nothing)
Else
MsgBox("Can't set info (Err: " & GetLastWin32Error() &
")")
End If
End If
End Sub

Thanks a lot!!!!!!!!!!!!!!!!!
Jul 21 '05 #1
2 3814
Cor
Hi Paolo,

You can better ask this kind of questions in the newsgroup.

microsoft.public.dotnet.languages.vb

I have seen a lot of answers on this kind of question.
I do not have them at hand.

Cor
Jul 21 '05 #2
Cor
Hi Paolo,

You can better ask this kind of questions in the newsgroup.

microsoft.public.dotnet.languages.vb

I have seen a lot of answers on this kind of question.
I do not have them at hand.

Cor
Jul 21 '05 #3

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

Similar topics

1
812
by: paolo.riba | last post by:
Hi everybody! Could anyone know how can I syncronize a horizontal scrollbar with a listview? Actually I can only syncronize the horizontal scrollbar with the listview horizontal scrollbar, but...
2
3910
by: Eddy | last post by:
Hi, I set the maximum value of an HScrollbar on 255. When I scroll to the maximum, the maximum value remains 246. How is this possible?? I put some code in the Scroll event, make the...
0
1023
by: meicher | last post by:
Hello, HScrollBar and VScrollBar respond to the arrow keys. How can I disable this ? I tried to override the key methodes from this two classes. It didn't help. :?: Posted Via Usenet.com...
0
1110
by: meicher | last post by:
Hi, I have an application with forms. Every form includes a VScrollBar and a HScrollBar. The ScrollBars allways get the arrow keys and start blinking ? How can I catch these key events ? KeyUp,...
1
2054
by: Alberto | last post by:
I have in the minimun property of a hscrollbar the value -50 and in the maximun 50. The Maximun value that the bar gives me is 41. Why? Thank you.
0
1196
by: Valerie Hough | last post by:
I have created an owner draw ListBox object. I have added an HScrollBar control to its Control collection. I have set the Anchor property to AnchorStyles.Bottom and the Dock property to...
1
1434
by: john doe | last post by:
I'm subclassing a HScrollBar and overriding the WndProc method: protected override void WndProc(ref Message m) { base.WndProc (ref m); System.Diagnostics.Debug.WriteLine((Msg)m.Msg); } ...
9
2087
by: Patrick | last post by:
Hello I'm running two Webservers Using ASP.NET. both are running the same ASP.NET Application, with <sessionState mode="SQLServer" stateConnectionString="tcpip=127.0.0.1:42424"...
3
2385
by: Michael.Suarez | last post by:
Is it me, or does it seem like they put no effort into creating the listview control in .Net. listview. A few gripes I have with .Net listview that aren't present in vb6: -Inability to set...
0
1149
by: lazzypink | last post by:
Hi guys! May i know how to use HScrollBar to control listview scrollbar? thanks!
0
7121
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
7197
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...
0
7375
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4899
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4584
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1411
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
287
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.