Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Scrolling with wheel in combobox list

I have a long list (400 entries) that I would like to scroll with the wheel
on the mouse rather than using the up and down pointers in the combo box.
Is this possible? If so, how? I am using Excel 2000.

Alternatively, if I could type in the first few characters of one of the
entries in the list and advance through the list that way, this would be
acceptable.

Finally, do the newer versions of Excel support having two sheets from the
same workbook viewable at the same time? Quite often when working on a
multi sheet workbook I end up opening a second copy of excel so I can view
two sheets from the same workbook at the same time. I have multiple
monitors so there is lots of room.

Thanks again for your help and support.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Scrolling with wheel in combobox list

All version support additional windows into an open workbook in the same
instance. (Window=New).

I don't see why any newer version would not support opening a copy of your
workbook as read only in another instance of excel.

If you are are using a combobox from the control toolbox toolbar, if the
data is sorted, you should be able to type the first letter as you describe.
This is the default option for the combobox.

--
Regards,
Tom Ogilvy

"Emile Zac" wrote in message
...
I have a long list (400 entries) that I would like to scroll with the

wheel
on the mouse rather than using the up and down pointers in the combo box.
Is this possible? If so, how? I am using Excel 2000.

Alternatively, if I could type in the first few characters of one of the
entries in the list and advance through the list that way, this would be
acceptable.

Finally, do the newer versions of Excel support having two sheets from the
same workbook viewable at the same time? Quite often when working on a
multi sheet workbook I end up opening a second copy of excel so I can view
two sheets from the same workbook at the same time. I have multiple
monitors so there is lots of room.

Thanks again for your help and support.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Scrolling with wheel in combobox list

Emile,

Oddly enough we just did this in CFPlus, well a ,listbox actually.

Create a normal module with the code below, and invoke from the form
initialise


UserformHook Me, Me.Caption


'---------------------------------------------------------------------------
'Module: mListboxScrol
'Module author: Jim Rech
' Bob Phillips - test for XL97 and call custom callbac
'Purpose: Contains all code for enabling mosue wheel scrolling
'---------------------------------------------------------------------------
Option Explicit

Private Declare Function CallWindowProc Lib "user32.dll" Alias
"CallWindowProcA" _
(ByVal lpPrevWndFunc As Long, _
ByVal hWnd As Long, _
ByVal Msg As Long, _
ByVal Wparam As Long, _
ByVal Lparam As Long) As Long

Private Declare Function SetWindowLong Lib "user32.dll" Alias
"SetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Private Const GWL_WNDPROC = -4
Private Const WM_MOUSEWHEEL = &H20A

Dim collUF As New Collection
Dim collPrevHdl As New Collection
Dim collUFHdl As New Collection

'---------------------------------------------------------------------------
Public Function WindowProc(ByVal Lwnd As Long, _
ByVal Lmsg As Long, _
ByVal Wparam As Long, _
ByVal Lparam As Long) As Long
'---------------------------------------------------------------------------
Dim Rotation As Long
Dim Btn As Long

If Lmsg = WM_MOUSEWHEEL Then
Rotation = Wparam / 65536 ''High order word indicates direction
Btn = Abs(Wparam) And 15 ''Low order word indicates various
virtual keys held down
MouseWheel collUF(CStr(Lwnd)), Rotation, Btn
WindowProc = 0 ''We handled event, no need to pass on (right?)
Else
WindowProc = CallWindowProc(collPrevHdl(CStr(Lwnd)), Lwnd, Lmsg,
Wparam, Lparam)
End If
End Function

'---------------------------------------------------------------------------
' Need both userform and its caption because Userform1.Caption is empty for
' some reason
Public Sub UserformHook(PassedForm As UserForm, _
Cap As String)
'---------------------------------------------------------------------------
Dim LocalHwnd As Long
Dim LocalPrevWndProc As Long
Dim cError As Long
Dim i As Long

LocalHwnd = FindWindow("ThunderDFrame", Cap)
'if Excel2000 or above use the built-in AddressOf operator to
'get a pointer to the callback function
If Val(Application.Version) 8 Then
LocalPrevWndProc = SetWindowLong(hWnd:=LocalHwnd, _
nIndex:=GWL_WNDPROC, _
dwNewLong:=AddrOf_Callback_Routine)

Else 'use K.Getz & M.Kaplan function to get a pointer
LocalPrevWndProc = SetWindowLong(hWnd:=LocalHwnd, _
nIndex:=GWL_WNDPROC, _
dwNewLong:=AddrOf("WindowProc"))
End If
On Error GoTo DupKey 'In case Windows assigns the same handle to a
'subsequent userform (altho it doesn't seem to do this)...
TryAgain:
collUF.Add PassedForm, CStr(LocalHwnd)
collPrevHdl.Add LocalPrevWndProc, CStr(LocalHwnd)
collUFHdl.Add LocalHwnd
Exit Sub
DupKey:
If cError = 0 Then ''Avoid infinite error loop
For i = 1 To collUFHdl.Count
If collUFHdl(i) = LocalHwnd Then
collUFHdl.Remove i
collUF.Remove i
collPrevHdl.Remove i
End If
Next
cError = 1
Resume TryAgain
End If
End Sub

'---------------------------------------------------------------------------
Public Sub UserformUnHook(UF As UserForm)
'---------------------------------------------------------------------------
Dim i As Long

For i = 1 To collUF.Count
If UF Is collUF(i) Then Exit For
Next
''SetWindowLong LocalHwnd, GWL_WNDPROC, LocalPrevWndProc
SetWindowLong collUFHdl(i), GWL_WNDPROC, collPrevHdl(i)
collUF.Remove i
collPrevHdl.Remove i
collUFHdl.Remove i
End Sub

'---------------------------------------------------------------------------
Public Sub MouseWheel(UF As UserForm, _
ByVal Rotation As Long, _
ByVal Btn As Long)
'---------------------------------------------------------------------------
' Function: Scrolls listbox 1 row or a full page if Ctrl is down
'---------------------------------------------------------------------------
Dim LinesToScroll As Long
Dim ListRows As Long
Dim Idx As Long

With UF
If TypeName(.ActiveControl) = "ListBox" Then
ListRows = .ActiveControl.ListCount
If Btn = 8 Then ''Ctrl
LinesToScroll = Int(.ActiveControl.Height / 10) ''Seems
to work for font size 8
Else
LinesToScroll = 1
End If
If Rotation 0 Then
'Scroll up
Idx = .ActiveControl.TopIndex - LinesToScroll
If Idx < 0 Then Idx = 0
.ActiveControl.TopIndex = Idx
Else
'Scroll down
Idx = .ActiveControl.TopIndex + LinesToScroll
If Idx ListRows Then Idx = ListRows
.ActiveControl.TopIndex = Idx
End If
End If
End With
End Sub


'---------------------------------------------------------------------------
' END OF CODE
'---------------------------------------------------------------------------
--

HTH

RP
(remove nothere from the email address if mailing direct)


"Emile Zac" wrote in message
...
I have a long list (400 entries) that I would like to scroll with the

wheel
on the mouse rather than using the up and down pointers in the combo box.
Is this possible? If so, how? I am using Excel 2000.

Alternatively, if I could type in the first few characters of one of the
entries in the list and advance through the list that way, this would be
acceptable.

Finally, do the newer versions of Excel support having two sheets from the
same workbook viewable at the same time? Quite often when working on a
multi sheet workbook I end up opening a second copy of excel so I can view
two sheets from the same workbook at the same time. I have multiple
monitors so there is lots of room.

Thanks again for your help and support.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
My mouse wheel zooms the page instead of scrolling DJS from Calgary Excel Discussion (Misc queries) 6 May 3rd 23 03:42 AM
How to keep the wheel mouse from scrolling horizontally? Frustrated with Horizontal Scrolling Excel Discussion (Misc queries) 2 December 1st 10 01:04 AM
Wheel Scrolling A_2the_Q Excel Discussion (Misc queries) 5 September 17th 08 10:49 PM
Scrolling with mouse wheel crashes Peter Ritchie [C# MVP] Excel Discussion (Misc queries) 4 August 29th 07 01:25 AM
Scrolling with mouse wheel in VBE Fred Lambelet Excel Programming 1 January 23rd 04 06:59 AM


All times are GMT +1. The time now is 05:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"