Crisp
Aug 11th, 2001, 08:25 AM
Hi all,
I am having a wierd problem using BitBlt on a Printer's DC. I've tracked the problem to be the following: BitBlitting to the Printer DC without an offset works fine, but from the moment you specify a destination top/left position, it crashes.
Here's what I do:
First I create a DC using CreateCompatibleDC(Printer.hDC). Immediatelly afterwards a call to CreateCompatibleBitmap(Printer.hDC) is made to create a drawing bitmap. The newly created bitmap is selected in the compatible DC. We'll call these hDC1 and BMP1
I do misc. rendering calls to this DC, printing some text, drawing some lines (all API, no VB involvement here).
Then I draw a graph in another DC and another Bitmap (let's call these hDC2 and BMP2). These are once again allocated using the printer's hDC, and the bitmap BMP2 is selected in hDC2
What I want to do is blit the graph from hDC2 to hDC1 using an offset, so it appears at the correct position on the printer's page. I use the following call for that:
BitBlt(hDC1, Left, Top, Width, Height, hDC2, 0, 0, SRCCOPY)
This crashes under Win98. If I remove the Left/Top values and replace them by zero's, it works. The code works fine on Windows 2000 and Windows NT 4 (SP5) with and without offsets.
The MSDN knowledge base addresses some issues with BitBlt() and I tried the following:
Since it is a large bitmap I am blitting, I tried blitting an extra scanline (knowledge base article Q87494 (http://support.microsoft.com/support/kb/articles/Q87/4/94.ASP)). This did not solve the problem.
The knowledge base mentions a workaround for inter-device blitting using Device-Independent and Device-Dependent bitmaps. However, this should not be an issue since both hDC's and BMP's are allocated compatible with the Printer's hDC.
I've tried replacing BitBlt by StretchBlt and other blitting calls, but this does not work either (probably because they all refer to BitBlt at one point). I should also mention that BitBlitting to the screen with offsets does work on Win98.
Anyway, I am completely stuck at the moment. Anybody has suggestions on how to solve this problem ? Or is there another way of blitting a hDC's contents to another with an offset ?
Thanks,
Crisp
I am having a wierd problem using BitBlt on a Printer's DC. I've tracked the problem to be the following: BitBlitting to the Printer DC without an offset works fine, but from the moment you specify a destination top/left position, it crashes.
Here's what I do:
First I create a DC using CreateCompatibleDC(Printer.hDC). Immediatelly afterwards a call to CreateCompatibleBitmap(Printer.hDC) is made to create a drawing bitmap. The newly created bitmap is selected in the compatible DC. We'll call these hDC1 and BMP1
I do misc. rendering calls to this DC, printing some text, drawing some lines (all API, no VB involvement here).
Then I draw a graph in another DC and another Bitmap (let's call these hDC2 and BMP2). These are once again allocated using the printer's hDC, and the bitmap BMP2 is selected in hDC2
What I want to do is blit the graph from hDC2 to hDC1 using an offset, so it appears at the correct position on the printer's page. I use the following call for that:
BitBlt(hDC1, Left, Top, Width, Height, hDC2, 0, 0, SRCCOPY)
This crashes under Win98. If I remove the Left/Top values and replace them by zero's, it works. The code works fine on Windows 2000 and Windows NT 4 (SP5) with and without offsets.
The MSDN knowledge base addresses some issues with BitBlt() and I tried the following:
Since it is a large bitmap I am blitting, I tried blitting an extra scanline (knowledge base article Q87494 (http://support.microsoft.com/support/kb/articles/Q87/4/94.ASP)). This did not solve the problem.
The knowledge base mentions a workaround for inter-device blitting using Device-Independent and Device-Dependent bitmaps. However, this should not be an issue since both hDC's and BMP's are allocated compatible with the Printer's hDC.
I've tried replacing BitBlt by StretchBlt and other blitting calls, but this does not work either (probably because they all refer to BitBlt at one point). I should also mention that BitBlitting to the screen with offsets does work on Win98.
Anyway, I am completely stuck at the moment. Anybody has suggestions on how to solve this problem ? Or is there another way of blitting a hDC's contents to another with an offset ?
Thanks,
Crisp