Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DocumentProperties anyone?
Message
 
To
02/05/2005 15:11:53
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01010251
Message ID:
01010367
Views:
20
Would you be willing to see if you can figure out where I'm going wrong? Below is as simplified an example as I can come up with that demonstrates the problem. You'll want to change the USE and REPORT FORM command near the end to use a table and report that you have available.
PRIVATE hWindow, hPrinter, nBufsize, cOrigDevMode, cModifiedDevMode, cPrinter

#DEFINE IDOK     1
#DEFINE IDCANCEL 2

#DEFINE DM_OUT_BUFFER 2
#DEFINE DM_IN_BUFFER  8
#DEFINE DM_IN_PROMPT  4

DECLARE INTEGER OpenPrinter IN winspool.drv;
      STRING pPrinterName, INTEGER @phPrinter, INTEGER pDefault

DECLARE INTEGER GetActiveWindow IN user32

DECLARE INTEGER DocumentProperties IN winspool.drv;
      INTEGER hWnd, INTEGER hPrinter, STRING pDeviceName,;
      STRING @pDevModeOutput, STRING @pDevModeInput, INTEGER fMode

cPrinter = GETPRINTER()
SET PRINTER TO NAME (cPrinter)

hWindow = GetActiveWindow()

hPrinter = 0
OpenPrinter(cPrinter, @hPrinter, 0)
IF hPrinter = 0
   Messagebox("Could not open default printer.", 48, "Error")
   RETURN
ENDIF

* being called this way the function returns DEVMODE buffer required size
nBufsize = DocumentProperties(hWindow, hPrinter, cPrinter,0,0,0)
cOrigDevmode = Repli(Chr(0), nBufsize)

* reading printer configuration
DocumentProperties(hWindow, hPrinter, cPrinter, @cOrigDevmode, 0, DM_OUT_BUFFER)
cModifiedDevmode = cOrigDevmode
* Show printer settings dialog.  I change the tray at this point
DocumentProperties(hWindow, hPrinter, cPrinter, @cModifiedDevmode, @cOrigDevmode, DM_IN_PROMPT+DM_IN_BUFFER+DM_OUT_BUFFER)
SET STEP ON 	&& The Watch Window shows that cOrigDevmode <> cModifiedDevmode
* Set the printer to the new options
DocumentProperties(hWindow, hPrinter, cPrinter, @cModifiedDevmode, @cModifiedDevmode, DM_IN_BUFFER+DM_OUT_BUFFER)
* Showing printer settings dialog again to see if the settings took
* This dialog comes up with the tray settings I chose previously
DocumentProperties(hWindow, hPrinter, cPrinter, @cModifiedDevmode, @cModifiedDevmode, DM_IN_PROMPT+DM_IN_BUFFER+DM_OUT_BUFFER)
USE WIP
REPORT FORM wip RANGE 1,1 TO PRINTER NOCONSOLE	&& The report ALWAYS uses the first available tray!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform