CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2001
    Location
    Chicago, IL
    Posts
    27

    if printer is cancelled

    I was wondering if anyone knew what to add to my code so that if the user selects "cancel" instead of "print", he returns to the listbox(that's where the print items are located) with the items as they were before the print job. I think it has something to do with vbCancel, but I can't find it anywhere in my book. Thank you very much.

    Private Sub mnuPrint_Click()
    Dim Item As Integer

    cdlPrint.ShowPrinter
    Printer.NewPage

    ' Prints the contents of the lstShopping list box.

    For Item = 0 To lstShopping.ListCount - 1
    Printer.Print lstShopping.List(Item)
    Next

    Printer.EndDoc

    Archie Kantzavelos

  2. #2
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: if printer is cancelled

    If you set the CancelError property of a comm dialog box, then it will give a trappable error when the user presses the Cancel button. You can trap this error to cancel the operation.


    private Sub mnuPrint_Click()
    Dim Item as Integer
    on error Goto ErrHndlr
    cdlPrint.CancelError = true
    cdlPrint.ShowPrinter
    on error Goto 0
    Printer.NewPage

    ' Prints the contents of the lstShopping list box.

    for Item = 0 to lstShopping.ListCount - 1
    Printer.print lstShopping.List(Item)
    next

    Printer.EndDoc
    Exit Sub
    ErrHndlr:
    'The user pressed cancel
    End Sub






  3. #3
    Join Date
    Apr 2001
    Location
    Chicago, IL
    Posts
    27

    Re: if printer is cancelled

    This works great, but the only problem is that I do not see the microsoft form that allows me to select how many pages i want to print, and which printer i want to print with? Any ideas? Thank you.

    Archie Kantzavelos

  4. #4
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: if printer is cancelled

    What do you mean by "microsoft form"?
    The printer common dialog contains a combo box that allows you to select the printer, and allows you to choose whether you want to print all pages or from a certain page to another.


  5. #5
    Join Date
    Apr 2001
    Location
    Chicago, IL
    Posts
    27

    Re: if printer is cancelled

    Yes...but i do not get that combo box to appear...thus, I don't have the opportunity to push "cancel". Sorry for the confusion. Any idea? Thank you.

    Archie Kantzavelos

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

Featured