Results 1 to 7 of 7

Thread: scroll PrintPreviewDialog

  1. #1
    .NET Framework
    .NET 4.0
    Join Date
    Nov 2005
    Location
    Columbia, SC
    Posts
    197
    Reputation
    166

    scroll PrintPreviewDialog

    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...

    Code:
    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 ?

  2. #2
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    14,012
    Reputation
    1732
    Without looking into whether your specific issue can be addressed, there's always the possibility of creating your own dialogue containing a PrintPreviewControl.

  3. #3
    .NET Framework
    .NET 4.0
    Join Date
    Nov 2005
    Location
    Columbia, SC
    Posts
    197
    Reputation
    166
    That will be my next step if I can't get the standard PrintPreview to function as my other controls...

  4. #4
    .NET Framework
    .NET 4.5
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    15,222
    Reputation
    2863
    You could change the dialogs .PrintPreviewControl.StartPage on mouse wheel.
    [xcode=vb] code here [/xcode] - see bbcode list or use formatting buttons in posting editor.

    Visual Studio Community 2017

  5. #5
    .NET Framework
    .NET 4.0
    Join Date
    Nov 2005
    Location
    Columbia, SC
    Posts
    197
    Reputation
    166
    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.

  6. #6
    .NET Framework
    .NET 4.5
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    15,222
    Reputation
    2863
    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
    [xcode=vb] code here [/xcode] - see bbcode list or use formatting buttons in posting editor.

    Visual Studio Community 2017

  7. #7
    .NET Framework
    .NET 4.0
    Join Date
    Nov 2005
    Location
    Columbia, SC
    Posts
    197
    Reputation
    166
    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

Similar Threads

  1. Add Free Scroll bar but not to scroll the form
    By bee55 in forum Windows Forms
    Replies: 2
    Last Post: 08-20-2013, 5:00 PM
  2. Question PrintPreviewDialog Problem
    By madon in forum Reporting / Printing
    Replies: 0
    Last Post: 05-01-2012, 2:50 PM
  3. PrintPreviewDialog
    By ALX in forum Reporting / Printing
    Replies: 2
    Last Post: 03-11-2011, 7:19 AM
  4. printpreviewdialog HasMorePages ?
    By showai in forum Reporting / Printing
    Replies: 10
    Last Post: 07-31-2009, 11:17 AM
  5. Replies: 2
    Last Post: 09-19-2006, 2:14 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •