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,
PrinterSetup()
PrinterSetup()
Gilbert Vaillancourt
turbolog@videotron.ca
turbolog@videotron.ca
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
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 ) );
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 ) );
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
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
turbolog@videotron.ca
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Hi Antonio,
I sure will do some testing on this.
Thanks
Regards,
Gilbert
I sure will do some testing on this.
Thanks
Regards,
Gilbert
Gilbert Vaillancourt
turbolog@videotron.ca
turbolog@videotron.ca
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
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
turbolog@videotron.ca
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
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,
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
turbolog@videotron.ca
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
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.
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.
Hi Antonio,
Thanks. I`getting on it right anway
Regards,
Gilbert
Thanks. I`getting on it right anway
Regards,
Gilbert
Gilbert Vaillancourt
turbolog@videotron.ca
turbolog@videotron.ca