PrinterSetup()

PrinterSetup()

Postby Gilbert » Thu Nov 30, 2006 3:49 pm

Hi All,

Can someone tell me why PrinterSetup() always return NIL.

My logic says that if the OK button is pressed I should get something like a logic .T. or numeric 1. And when the cancel button is pressed a logic .F. or numeric 0.

When the Cancel button is pressed I want to cancel the printout. Is there a way of detecting if OK or Cancel button has been pressed.

Regards,
Gilbert Vaillancourt
turbolog@videotron.ca
Gilbert
 
Posts: 74
Joined: Thu Oct 20, 2005 4:30 pm
Location: Canada

Postby Antonio Linares » Thu Nov 30, 2006 5:11 pm

Gilbert,

PrinterSetup() is automatically used from Class TPrinter.

PrinterSetup() calls Windows API PrintDlg. According to Microsoft docs:

The PrintDlg function displays a Print dialog box or a Print Setup dialog box. The Print dialog box enables the user to specify the properties of a particular print job.

The Print Setup dialog box should not be used in new applications. It has been superseded by the Page Setup common dialog box created by the PageSetupDlg function.

BOOL PrintDlg(

LPPRINTDLG lppd // address of structure with initialization data
);


Parameters

lppd

Pointer to a PRINTDLG structure that contains information used to initialize the dialog box. When PrintDlg returns, this structure contains information about the user's selections.



Return Values

If the user clicks the OK button, the return value is nonzero. The members of the PRINTDLGstructure pointed to by the lppd parameter indicate the user's selections.
If the user cancels or closes the Print or Printer Setup dialog box or an error occurs, the return value is zero. To get extended error information, use the CommDlgExtendedError function, which can return one of the following values:

CDERR_FINDRESFAILURE PDERR_CREATEICFAILURE
CDERR_INITIALIZATION PDERR_DEFAULTDIFFERENT
CDERR_LOADRESFAILURE PDERR_DNDMMISMATCH
CDERR_LOADSTRFAILURE PDERR_GETDEVMODEFAIL
CDERR_LOCKRESFAILURE PDERR_INITFAILURE
CDERR_MEMALLOCFAILURE PDERR_LOADDRVFAILURE
CDERR_MEMLOCKFAILURE PDERR_NODEFAULTPRN
CDERR_NOHINSTANCE PDERR_NODEVICES
CDERR_NOHOOK PDERR_PARSEFAILURE
CDERR_NOTEMPLATE PDERR_PRINTERNOTFOUND
CDERR_STRUCTSIZE PDERR_RETDEFFAILURE


Remarks

If the hook procedure (pointed to by the lpfnPrintHook or lpfnSetupHook member of the PRINTDLG structure) processes the WM_CTLCOLORDLG message, the hook procedure must return a handle for the brush that should be used to paint the control background.

See Also

CommDlgExtendedError, CreateDC, DOCINFO, PRINTDLG, PrintHookProc, SetupHookProc, StartDoc, WM_CTLCOLORDLG

In FW, PrinterSetup() should return the handle of the device context if successfull:

_retnl( ( LONG ) ( PrintDlg( &pd ) ? pd.hDC : 0 ) );
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Gilbert » Thu Nov 30, 2006 7:58 pm

Hi Antonio,

Do you mean that PrinterSetup will return a non zero value if OK button is presse and 0 value if Cancel button is pressed ?

Regards
Gilbert Vaillancourt
turbolog@videotron.ca
Gilbert
 
Posts: 74
Joined: Thu Oct 20, 2005 4:30 pm
Location: Canada

Postby Antonio Linares » Fri Dec 01, 2006 12:54 pm

Gilbert,

Yes
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Gilbert » Fri Dec 01, 2006 9:24 pm

Hi Antonio,

I sure will do some testing on this.

Thanks

Regards,

Gilbert
Gilbert Vaillancourt
turbolog@videotron.ca
Gilbert
 
Posts: 74
Joined: Thu Oct 20, 2005 4:30 pm
Location: Canada

Postby Gilbert » Sat Dec 02, 2006 12:32 am

Hi Antonio,


Sorry to tell you that PrinterSetup() return 0 whether I pressed OK or Cancel buttons.

Here`s the code I used for testing:


function Test()
local hDC

hDC := PrinterSetup()
MsgInfo(Str(hDC))

Return (NIL)

Regards,

Gilbert
Gilbert Vaillancourt
turbolog@videotron.ca
Gilbert
 
Posts: 74
Joined: Thu Oct 20, 2005 4:30 pm
Location: Canada

Postby Antonio Linares » Sat Dec 02, 2006 12:46 am

Gilbert,

You are right. There was a missing flag at PrinterSetup() function:

pd.Flags = PD_PRINTSETUP | PD_USEDEVMODECOPIES | PD_RETURNDC;

PD_RETURNDC was missing. Now it behaves as expected: hDC, or zero if cancel is pressed. Thanks!
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Gilbert » Sat Dec 02, 2006 1:15 am

Hi Antonio,

I knew there was someting about PrinterSetup(), cause I remember getting very frustrated trying to figure out why in the world was I not getting anything back.

How can I fix this function without recompiling the whole library ?
I would like to solve this problem so I can go on with the rest of my project. Right now I`m stuck...

Regards,
Gilbert Vaillancourt
turbolog@videotron.ca
Gilbert
 
Posts: 74
Joined: Thu Oct 20, 2005 4:30 pm
Location: Canada

Postby Antonio Linares » Sat Dec 02, 2006 9:06 am

Gilbert,

You may download printdc.obj for 16 bits from here:
http://www.uploading.com/files/EPJWV6HS ... C.ZIP.html

Just link it to your application as another OBJ of your own.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Gilbert » Sat Dec 02, 2006 5:43 pm

Hi Antonio,

Thanks. I`getting on it right anway

Regards,

Gilbert
Gilbert Vaillancourt
turbolog@videotron.ca
Gilbert
 
Posts: 74
Joined: Thu Oct 20, 2005 4:30 pm
Location: Canada


Return to FiveWin for CA-Clipper

Who is online

Users browsing this forum: No registered users and 2 guests