Results 1 to 6 of 6

Thread: PrintDialog Windows 7

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2011
    Posts
    14

    PrintDialog Windows 7

    Hi,

    I'm using a 64 Bit Windows 7 system and trying to use PrintDialog. I know it doesn't work on Windows 7 unless you add this code:

    PrintDialog1.UseEXDialog = True

    So I have added that code but then I get this error for the following code:

    Dim result As DialogResult = PrintDialog1.ShowDialog()

    And the error:

    "An exception of type 'System.Runtime.InteropServices.SEHException' occurred in System.Windows.Forms.dll but was not handled in user code

    Additional information: External component has thrown an exception."


    Could you please help me fix this issue
    Thanks

  2. #2
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: PrintDialog Windows 7

    Works fine for me on Win7 Ultimate x64 SP1
    Code:
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim dlg As DialogResult
            Using prt As New PrintDialog() With {.Document = New PrintDocument(), .UseEXDialog = True}
                dlg = prt.ShowDialog(Me)
            End Using
            MessageBox.Show(dlg.ToString)
        End Sub
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: PrintDialog Windows 7

    works for me too

  4. #4

    Thread Starter
    New Member
    Join Date
    Nov 2011
    Posts
    14

    Re: PrintDialog Windows 7

    Thanks juggalo the new code works

  5. #5
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: PrintDialog Windows 7

    Quote Originally Posted by RoomTen View Post
    Thanks juggalo the new code works
    So the question is, what's the difference between your code and my bare-bones code that simply tests whether the dialog window opens/shows or not?
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  6. #6

    Thread Starter
    New Member
    Join Date
    Nov 2011
    Posts
    14

    Re: PrintDialog Windows 7

    I'm honestly not sure. Something just messed up with:

    Dim result As DialogResult = PrintDialog1.ShowDialog()

    Which produced that error. To be honest your code threw a "Thread Error" because of cross threading but I know how to fix that error but yep I fixed that and now it's all done I hope

Posting Permissions

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



Click Here to Expand Forum to Full Width