Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CreateCompatibleBitMap and Win2000
Message
From
19/12/2001 23:11:35
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:
00596564
Views:
19
George,
Did I mention that this was copied from a posting on new2news? I don't actually understand in any detail this code. I hope this is the part that you are interested in (thanks):

hFormDC = GetWindowDC(hwnd)
= getWinRect (hwnd, @pnWidth, @pnHeight)

* scaling factor values from screen to printer
xScale = GetDeviceCaps(hPrnDC, LOGPIXELSX)/GetDeviceCaps(hFormDC, LOGPIXELSX)
yScale = GetDeviceCaps(hPrnDC, LOGPIXELSY)/GetDeviceCaps(hFormDC, LOGPIXELSY)

* creating screen compatible DC and BITMAP to pass image
* through them from screen to printer; no direct screen to printer copying
hMemDC = CreateCompatibleDC (hFormDC)
hMemBmp = CreateCompatibleBitmap (hFormDC, pnWidth, pnHeight)
hSavedBitmap = SelectObject(hMemDC, hMemBmp)

* copying bitmap data from screen to virtual device context
* and unselecting the bmp from the memory device context
= BitBlt (hMemDC, 0,0, pnWidth,pnHeight, hFormDC, 0,0, SRCCOPY)
= SelectObject(hMemDC, hSavedBitmap)

* retrieving bits from the compatible bitmap into a buffer
* as a device-independent bitmap (DIB) with a BitsPerPixel value
* as one of the printer device context
lcBInfo = InitBitmapInfo(hPrnDC)
lpBitsArray = InitBitsArray()
= GetDIBits (hMemDC, hMemBmp, 0, pnHeight,;
lpBitsArray, @lcBInfo, DIB_RGB_COLORS)

lcDocInfo = Chr(20) + Repli(Chr(0), 19) && DOCINFO struct - 20 bytes
IF StartDoc(hPrnDC, @lcDocInfo) > 0
= StartPage(hPrnDC)

= StretchDIBits (hPrnDC, xOffsPrn, yOffsPrn,;
xOffsPrn + Int(xScale * pnWidth),;
yOffsPrn + Int(yScale * pnHeight),;
0,0, pnWidth, pnHeight,;
lpBitsArray, @lcBInfo, DIB_RGB_COLORS, SRCCOPY)

= EndPage(hPrnDC)
= EndDoc(hPrnDC)
ENDIF
A problem is a problem only as long as it has a possible solution. Lacking that, it becomes a FACT!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform