Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
More screen print info
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00124126
Message ID:
00126215
Views:
20
>>
>>Here is an example of the method I use to print a form:
>>
>>* PrintWindow Method
>>LOCAL lnHWnd
>>LOCAL lcJobName
>>LOCAL lnRetVal
>>
>>DECLARE INTEGER GetFocus IN WIN32API
>>DECLARE INTEGER PrintWindow IN DibApi32 ;
>> INTEGER HWnd, ;
>> INTEGER fPrintArea, ;
>> INTEGER fPrintOpt, ;
>> INTEGER wxScale, ;
>> INTEGER wyScale, ;
>> STRING @ szJobName
>>
>>#DEFINE PW_WINDOW 1
>>#DEFINE PW_CLIENT 2
>>#DEFINE PW_BESTFIT 1
>>#DEFINE PW_STRETCHTOPAGE 2
>>#DEFINE PW_SCALE 3
>>
>>lnHWnd = GetFocus() && Use this to print a form
>>*lnHWnd = MainhWnd() && Use this to print the VFP screen
>>
>>lcJobName = "Print job name" + CHR(0)
>>lnRetVal = PrintWindow( lnHWnd, PW_WINDOW, PW_STRETCHTOPAGE, 0, 0, @lcJobName)
>>IF lnRetVal != 0
>> IF lnRetVal != 6 && 6 = User canceled printing
>> = MESSAGEBOX("Unable to print the window" + CRLF + ;
>> "PrintWindow API call returned " + STR(lnRetVal), ;
>> MB_ICONEXCLAMATION + MB_OK, ;
>> oApp.cApplicationName)
>> ENDIF
>>ENDIF
>>RETURN
>
>Steven - I followed your instructions and downloaded the dibapi32.dll, copied your code and tried running it in vfp. I continue to get the following error:-
> 'An error occured during this operation'
>I can't seem to get pass this error. I tried debugging the code and the error is occuring at the printwindow api function call. Could you help to guide this poor critter along the right path?

Sorry I didn't get back to you sooner but I missed your reply and only just noticed the counter on the mailbox had increased.

The example I gave you is almost verbatim from my application. I combined two functions into one. I have a PrintForm method that passes the handle and job name to the PrintWindow method. I just moved that code to PrintWindow for this example.

Make sure you are passing the lcJobName parameter by reference and check to make sure lnHWnd is valid. It should be non-zero.

I got my copy of DIBAPI32 from the Visual Studio samples. Possibly what's on the Microsoft site is not the same version.

The only problem I've had is memory overflow problems on older printers. But I get this message from the printer and not VFP.
Steve Ruhl
CitiMortgage, Inc.
steven.ruhl@citibank.com Office
Steve@steven-ruhl.com Home
Previous
Reply
Map
View

Click here to load this message in the networking platform