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.
> 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
François Van Lerberghe
Rue Thier Monty, 15 A
4570 Marchin
Belgique
_______________________________________________
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>