Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / VB Syntax / August 2009



Tip: Looking for answers? Try searching our database.

Commondialog.showprinter

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Carlos Gonzalez - 14 Aug 2009 19:33 GMT
Hi evereone,

I would like to know what command I should use with the
COMMONDIALOG.SHOWPRINTER (ex.: Commondialog1.showprinter) to cancel the print
job.

My problem is that when I call the commondialog1.showprinter and I would
like to cancel the job, when I click "Cancel"; I am still getting the print
out.

I will would like to know what could be the command line to be used.

Thanks for your help

Carlos Gonzalez
MikeD - 14 Aug 2009 23:17 GMT
> Hi evereone,
>
[quoted text clipped - 7 lines]
> print
> out.

There is no "command". You have to set the CancelError property to True and
then trap for an error the control raises when the user clicks the Cancel
button.  Here's some example code:

-----BEGIN CODE SNIPPET
   On Error GoTo EH

   CommonDialog1.CancelError = True
   CommonDialog1.ShowPrinter

    <do your printing>

   Exit Sub

EH:

   Select Case Err.Number
       Case cdlCancel
           'User clicked Cancel button on Print dialog box
       Case Else
           MsgBox Err.Description
   End Select
-----END CODE SNIPPET

Yes, it's stupid. It'd be MUCH better if the various Showxxx methods simply
returned a Boolean with False meaning the user clicked Cancel. But the
reason it is the way it is goes clear back to VB1 when the control didn't
have those methods.  Instead, it had an Action property that you assigned a
value to display a certain dialog box.

This is one of many things that people find annoying about this particular
control. Because of the annoyances of the control, and it's rather limited
capability, most people use Win32API functions to show the common
dialogs...at least in production apps (they might use the control in demo
apps and the like).

Signature

Mike

Jeff Johnson - 17 Aug 2009 14:34 GMT
> Yes, it's stupid. It'd be MUCH better if the various Showxxx methods
> simply returned a Boolean with False meaning the user clicked Cancel. But
> the reason it is the way it is goes clear back to VB1 when the control
> didn't have those methods.  Instead, it had an Action property that you
> assigned a value to display a certain dialog box.

Hurray for backwards compatibility....

Barf.
MikeD - 17 Aug 2009 23:18 GMT
>> Yes, it's stupid. It'd be MUCH better if the various Showxxx methods
>> simply returned a Boolean with False meaning the user clicked Cancel. But
[quoted text clipped - 5 lines]
>
> Barf.

Yep. You know exactly what I'm talking about.  <g>

Backwards compatibility is great....but it doesn't mean you can't move
forward either.

Signature

Mike

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.