Solved Move textbox with the mouse wheel in a continuous form (1 Viewer)

zelarra821

Registered User.
Local time
Today, 23:12
Joined
Jan 14, 2019
Messages
813
Hello. I'm looking for a way to disable scrolling when I enter a memo field, because I've discovered a trick to scroll when I'm focused on a memo field, but the latter only works for me when there's only one record in the form. I don't know if I explain myself. I can pass screenshots so that you understand it better.

Thank you very much.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 22:12
Joined
Feb 19, 2013
Messages
16,629
Your thread title is not clear - I think you are talking about scrolling with the mouse, not moving the scrollbar.

I've responded to the example you posted with other ways of identifying the control which may be of help. If you are talking about a continuous form, I'm not sure there is a solution, but building on June's suggestion, set the default scrollbars to none, and when you click on the control using perhaps the enter or got focus events set to vertical. Then set to none again in the exit or lost focus events.

The principle works for dynamic combo's in a continuous form, you would have to try it for mouse scrolling
 

zelarra821

Registered User.
Local time
Today, 23:12
Joined
Jan 14, 2019
Messages
813
Hello. I don't understand what you want to explain to me. My problem is the following: I have a continuous form. With a code (that I have posted this morning in this forum), I make it work with the mouse wheel when it tries to go down in the text box, but when I want to go up, it moves the screen, that's why I want to know how to disable the movement up and down the screen, and not within the control. Watch the video to understand:
 

Attachments

  • Video.zip
    1.8 MB · Views: 93

CJ_London

Super Moderator
Staff member
Local time
Today, 22:12
Joined
Feb 19, 2013
Messages
16,629
cannot open the video - unrecognised format.

As I said, I don't think there is a solution for a mouse scrolled textbox in a continuous form.

But I was suggesting

Another way is to identify the control below the mouse - use the control mousemove event to populate a control object and the form mousemove event to empty the control object.

This does require space around the control so the form can detect a mousemove event

then you would change this line

If ActiveControl.ControlType = acTextBox Then

to something like

if not gCtl is nothing then

in the 'txtMemo' control mousemove event

set gCtl=txtMemo

and the form mousemove event

set gCtl=nothing

might want to try empty rather than nothing
 

zelarra821

Registered User.
Local time
Today, 23:12
Joined
Jan 14, 2019
Messages
813
Ok, so that's what I'm going to do. Thank you very much.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 22:12
Joined
Feb 19, 2013
Messages
16,629
one other thought, try modifying your code to do nothing if a control not specified. You'll need to experiment - determine page and count values (probably just the latter) and modify as required - something like

Code:
if not gCtl is nothing then
    'scroll the textbox
else
    count=0
end if

It's just a suggestion - no idea if it will work
 

zelarra821

Registered User.
Local time
Today, 23:12
Joined
Jan 14, 2019
Messages
813
Let's see, I've made a small database with a table and two forms. These forms are a single form, and a continuous form. If you enter the form with the format a single form, you will see that you can move the textbox with the mouse wheel. On the contrary, if you enter the continuous form format, you will see that if you move the mouse wheel, only the screen moves, not the textbox on which you position yourself or focus. It can be fixed? Thank you very much.
 

Attachments

  • Prueba.accdb
    1 MB · Views: 70

CJ_London

Super Moderator
Staff member
Local time
Today, 22:12
Joined
Feb 19, 2013
Messages
16,629
As I've said, several times, I don't believe it can be fixed for a continuous form. I've provided some suggestions that might work, might not. I don't know. You will have to experiment

Alternatively upgrade to the latest version of access - mouse scrolling works there without the need for the code
 

riktek

New member
Local time
Today, 14:12
Joined
Dec 15, 2023
Messages
27
I actually developed a fix that allows text box scrolling without scrolling records in continuous forms.

When Access scrolls records in continuous forms on the MouseWheel event, it obviously just sends a Scrollbar message to the form. There aren't any hooks into that behavior but nothing prevents countermanding that message with another, which is what this does.

Credit to Carl Connett for the the code [I can't post links yet] on which this is based, including Dev Ashish' fhWnd() function for getting the control's handle.

Code:
Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As Long)

    Const WM_VSCROLL = &H115
    Const WM_HSCROLL = &H114
    Const SB_LINEUP = 0
    Const SB_LINEDOWN = 1

    If Me.ActiveControl.ControlType = acTextBox Then
    
        Dim intLinesToScroll As Integer
        Dim hwndActiveControl As Long
        Dim hwndMe As Long

        hwndActiveControl = fhWnd(Me.ActiveControl)
        hwndMe = Me.hwnd

        If Count < 0 Then
            If Me.DefaultView = 1 Then SendMessage hwndMe, WM_VSCROLL, SB_LINEDOWN, 0
            For intLinesToScroll = 1 To -1 * Count
                SendMessage hwndActiveControl, WM_VSCROLL, SB_LINEUP, 0
            Next
        Else
            If Me.DefaultView = 1 Then SendMessage hwndMe, WM_VSCROLL, SB_LINEUP, 0
            For intLinesToScroll = 1 To Count
                SendMessage hwndActiveControl, WM_VSCROLL, SB_LINEDOWN, 0
            Next
        End If
    
    End If

End Sub

HTH
 

Users who are viewing this thread

Top Bottom