Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
My mouse wheel zooms the page instead of scrolling | Excel Discussion (Misc queries) | |||
How to keep the wheel mouse from scrolling horizontally? | Excel Discussion (Misc queries) | |||
Wheel Scrolling | Excel Discussion (Misc queries) | |||
Scrolling with mouse wheel crashes | Excel Discussion (Misc queries) | |||
Scrolling with mouse wheel in VBE | Excel Programming |