Le 7 déc. 06 à 13:23 Soir, Francois Van Lerberghe a écrit:
le 5/12/06 12:58, Arnaud Nicolet <[EMAIL PROTECTED]> a écrit :
I'm using some code to print a listbox:
dim g As graphics
dim i As integer
dim j As integer
g=OpenPrinterDialog()
if g=nil then Return True
i=GetColumnsWidth 'A method that computes the width of the listbox.
It works fine.
if i>g.Width then
if i<=g.Height and app.MyPrefs.PrintTryLandscape then
m=new MessageDialog
m.Message="The list is too large to be printed in that format.
Would you like to print it as landscape format?"
m.ActionButton.Caption="Landscape"
m.CancelButton.Caption="Cancel"
m.CancelButton.Visible=True
b=m.ShowModal
Now, what should I do if the user hits "Cancel"? Actually, a blank
page will be printed anyhow as soon as "g" goes out of scope, unless
I kill my app (apparently).
I don't know any way to avoid this. Perhaps a workaround could be
to test
"if i<=g.Height and app.MyPrefs.PrintTryLandscape" before showing
the open
printer dialog.
The problem with your solution (well, what a phrase!) is that I don't
know which format the user will choose when the OpenPrinterDialog is
shown. I may assume he print in A4 format, but, if he changes
(smaller or greater), then it will fail. So I must check after the
dialog, where I can't cancel the print anymore.
Actually, I'm just showing the message box without cancel choice. But
it would be so nice, for example, to be allowed to write:
if b=m.CancelButton then
g=nil
end if
and RB then cancels the print order. This behaviour would also be
logical since g is no longer useable for what it was first created.
Also, when the dialog "Processing page: x" is shown, the user can
cancels the print using the "Cancel" button. How do I detect that
from my RB app?
You can use a declare to test the print manager error. Here is my
code :
Create the Function "CancelPrinting"
dim ok As Boolean
// MACINTOSH
#IF TargetMacOS
#IF TargetCarbon
Declare SUB PMError Lib "CarbonLib" () as Integer
#ELSE
Declare SUB PMError Lib "InterfaceLib" alias "PrError" () as Short
#ENDIF
ok = (PMError() <> 0)
// WINDOWS
#ELSE
ok = False // Don't know if it's possible in Win32
#ENDIF
RETURN ok
Now in your main loop, just before beginning drawing a new page,
test if the
user have not hit the Cancel button :
If CancelPrinting() then
...
End if
If someone knows if it's possible in Windows and how to do that,
let's us
know.
Best regards
Thank you very much.
I'm happy you already asked yourself the same questions (including
the one in the first part of the message)._______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>