Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Commondialog.showprinter

65 views
Skip to first unread message

Carlos Gonzalez

unread,
Aug 14, 2009, 2:33:01 PM8/14/09
to
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

unread,
Aug 14, 2009, 6:17:10 PM8/14/09
to

"Carlos Gonzalez" <CarlosG...@discussions.microsoft.com> wrote in
message news:5DB85146-9088-4A17...@microsoft.com...

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

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

--
Mike

Jeff Johnson

unread,
Aug 17, 2009, 9:34:26 AM8/17/09
to
"MikeD" <nob...@nowhere.edu> wrote in message
news:u7lD8zSH...@TK2MSFTNGP02.phx.gbl...

> 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

unread,
Aug 17, 2009, 6:18:39 PM8/17/09
to

"Jeff Johnson" <i....@enough.spam> wrote in message
news:O8gMx9zH...@TK2MSFTNGP04.phx.gbl...

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.

--
Mike

0 new messages