Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CreateCompatibleBitMap and Win2000
Message
From
20/12/2001 03:44:43
 
 
To
19/12/2001 09:26:00
Calvin Smith
Wayne Reaves Computer Systems
Macon, Georgia, United States
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00596108
Message ID:
00596590
Views:
14
>I recently copied a proc from an internet site (www.news2news.com/vfp) that allowed printing of VFP screens. This proc was different than others I had seen in the past because it allowed printing of a screen on a dot matrix printer without the screen background color and in a legible format. It worked great on Win98, however when I do this proc from a Win2000/WinXP machine the print quality if much lower ( even when printer resolution is all the way up) and the printer emulates the screen background by printing dots. The result is awful. I believe the difference is in the way the systems handle the WinFunction CreateCompatibleBitMap. Is there any other function I can use? Or, does someone know of a screen printing routine that works on all WinVersions with Dot Matrix printers. Thanks.

George asked me to take a look at the problem; I checked out the source code on news2news. There are a number of problems here; the biggest one is tha the code does not allow for grayscale converwhying from the bitmap or screen/window Device Context to a printer device context. The most straightforward approach to solving the problem is to use SetDIBitsToDevice() rahter than SlectObject and BitBlt to transfer the image; another alternative to is create your own color to grayscale conversion, perform the conversion to an internediate compatible DC construct, and then use SelectObject() and BitBlt() to transfer the bitmap converted to grayscale to the device context for the printer. A good resource on this is "Windows 98 Developer's Handbook" by Ben Ezzell, published by Sybex; it's targeted at the C programmer (all the code samples are in C++) but it covers a wide range of topics, including this one, in some detail.

Other approaches would include the use of metafiles rather than bitmaps or DIBs, or the use of OLE automation - you could create the bitmap and then rely on automating Paint to provide the PRINTTO service.

If push came to shove and I desperately needed this, I could probably write something in under a day to address the problem, but it's not terribly interesting as a problem, I'm not stuck for the solution, and I'm up to my eyeballs in work that pays the bills through mid-January. I'd recommend picking up Ezzell's book, or Dan Appleman's API for VB programmers, and fooling around with the code in them to do this; Appleman's book also addresses the bitmap transfer between Device Contexts in a VB syntax, but his explanation of the problems isn't as good as Ezzell's. I'd also be careful about the solutions outlined on news2news; the author of the article I read mis-cast a couple of things that might well cause problems in certain types of calls to the API, like the constant for 0xFFFFFFFF
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform