473,386 Members | 1,766 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.

[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 3804
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
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
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
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
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
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
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
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
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
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
by: lazzypink | last post by:
Hi guys! May i know how to use HScrollBar to control listview scrollbar? thanks!
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.