If you test this, the printer will need to be turned on.
Having a lot of trouble getting a bitmap to print on the printer.
I have been able to get a bitmap shown on the screen.
I have looked at R. Thomas's showdib program and frankly dibs
are a complete mystery to me. Anyway the program doesn't do
what I want to do. All the goodies are zipped and attached here.
The tloadimage program is already compiled but you can do it
again with the included ".bat" file.
I am especially having trouble with the "LoadImage API".
According to what I have read the "LoadBitMap API" will not
write to a printer. Anyway the LoadImage failed.
LoadImage needs the handle of the Module (hInstance) that contains the Bitmap-resource.
Thank you qWord.
Loadimage shows no error now.
Getobject shows no errors.
SelectObject shows no errors.
Bitblt is showing an error.
I suspect the fields in bmpdc are invalid.
hello Jack
during WM_CREATE, you create a compatible DC with 0 as the parm
it must have an hDC
(the reason BitBlt is failing is the source hDC is 0 because it returns an error)
then, you must select the loaded bitmap handle into the compatible DC
if you want, you can use the desktop hDC as a reference
invoke GetDC,HWND_DESKTOP
mov hdcDesktop,eax
invoke CreateCompatibleDC,eax
mov hdcMem,eax
invoke ReleaseDC,HWND_DESKTOP,hdcDesktop
now, you can select the bitmap handle into hdcMem
invoke SelectObject,hdcMem,hBitmap
mov hbmpMem,eax ;save the original and restore it before deleting the DC
you may not need to use the desktop DC - you might be able to use the printer DC
i have never tried that :P
Hi Dave,
I just found out that 2 API's will not work when trying to print a bitmap.
LoadBitMap and BitBlt.
I must go the DIB route using Stretchdibits and God knows what else.
Nothing is ever easy.....
that's right - i remember reading that you have to use LoadImage with LR_CREATEDIBSECTION
Gave up on printing bitmaps.
Will find another way to skin the cat. Might not give
me all I need but better than the DIB mess.
As a side, R. Thomas's "showdib" program printed a bitmap
just fine. For some reason I deleted the "showdib.exe" file
and recompiled the program in Windows 7 pro 64-bit using
masm32. Guess what, the program no longer works. I think
it has something to do with the API upgrades from when Mr.
Thomas wrote the program and now.