添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
It's possible that I'm trying to the impossible once again. My app has many panels and images that are too large for most displays, so of course I provide scroll bars, and every one of them has been given the ability to scroll up or down with the mouse wheel. All except for a PrintPreviewDialog that I've been fussing with trying to get it to scroll with the mouse wheel. 'Seems pretty straight forward to me...
Private Sub PPDMouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PrintPreviewDialog1.MouseWheel
        Dim j As Integer
        If e.Delta > 0 Then
            If PrintPreviewDialog1.VerticalScroll.Value < 1 Then Exit Sub
            j = PrintPreviewDialog1.VerticalScroll.Value - 15
            If j < 0 Then j = 0
        ElseIf e.Delta < 0 Then
            If PrintPreviewDialog1.VerticalScroll.Value >= PrintPreviewDialog1.VerticalScroll.Maximum Then Exit Sub
            j = PrintPreviewDialog1.VerticalScroll.Value + 15
            If j > PrintPreviewDialog1.VerticalScroll.Maximum Then j = PrintPreviewDialog1.VerticalScroll.Maximum
        End If
        PrintPreviewDialog1.VerticalScroll.Value = j
        PrintPreviewDialog1.Invalidate()
    End Sub
Posting guidelines
DIY: Before posting, try to debug your code, try to search documentation/web for information/solutions.
Where: Try to post in proper subforum, all forums here are for VB.Net questions.
How: Explain the problem so other people can understand it. Give a brief title describing the topic. State project type and .Net version.
Code: Use code button </> when posting code. Avoid screenshots of code.
Resolved button is at top of page, Mark as solution button right side of post.
Visual Studio Community 2022
Visual Basic docs
.Net API browser
SendMessage WM_VSCROLL to the dialogs .PrintPreviewControl.Handle works for that for me. (scrolling a zoomed page)
MouseWheel event:
SendMessage(PrintPreviewDialog1.PrintPreviewControl.Handle, WM_VSCROLL, If(e.Delta < 0, SB_PAGEDOWN, SB_PAGEUP), 0)
Declarations used:
Private Const WM_VSCROLL As Integer = &H115
Private Const SB_PAGEUP As Integer = 2
Private Const SB_PAGEDOWN As Integer = 3
<DllImport("User32.dll")>
Public Shared Function SendMessage(hWnd As IntPtr, msg As UInteger, wParam As IntPtr, lParam As IntPtr) As Integer
End Function
Posting guidelines
DIY: Before posting, try to debug your code, try to search documentation/web for information/solutions.
Where: Try to post in proper subforum, all forums here are for VB.Net questions.
How: Explain the problem so other people can understand it. Give a brief title describing the topic. State project type and .Net version.
Code: Use code button </> when posting code. Avoid screenshots of code.
Resolved button is at top of page, Mark as solution button right side of post.
Visual Studio Community 2022
Visual Basic docs
.Net API browser
I knew deep down that John would be able to solve this riddle. What a resource you are ! ... and it's all right here ladies and gentlemen... and it's all FREE !!!
Thanks again, John
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies. Accept Learn more…