Question scroll PrintPreviewDialog

ALX

Well-known member
Joined
Nov 16, 2005
Messages
253
Location
Columbia, SC
Programming Experience
10+
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...

VB.NET:
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


... But it doesn't work. I can break inside of this sub and watch the VerticalScroll.Value changing, but nothing happens. Any thoughts ?
 
You could change the dialogs .PrintPreviewControl.StartPage on mouse wheel.
 
The print output is just 1 tall page, so I don't think changing the StartPage will help unless it can handle fractions of a page. Looks like I'm off to create my own PrintDialog. As always, thanks JM & John for the input. At least I know I'm not overlooking something basic.
 
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
 
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
 
Back
Top