May 22, 2024, 05:47:55 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Crash with Printbitmap

Started by Haim, April 11, 2006, 11:49:53 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Haim

I am trying to use printbitmap to directly output a bitmap to my printer, but the program crashes.
What am I doing wrong??

This is the  code I try:
prt=prtdialog(null,sp,ep,cop,col);
phdc=createdcA(0,prt,0,0);
hbitmap=bmp.LoadFromFile(filename,0);
// after checking the validity of both phdc and hbitmap and initializing a rect variable,  I call printbitmap as follows;
printbitmap(phdc,hbitmap,rectvariable);        // This is where the crash occurs


Ionic Wind Support Team

A few things.  Besides the fact that PrintBitmap is an internal command not meant for use outside of the library....

CreateDCA requires "WINSPOOL" as the driver, the name of the printer, and the DEVMODE structure to be filled in (last parameter). 

You shouldn't be creating a DC directly like that anyway.  The proper method is to get the device context for the printer using the API function PrintDlgA.  The hdc member of the PRINTDLG struction will have a properly setup DC for selected printer.

Your best option is to just create a hidden window, load the bitmap and render it to the window.  Then a call to PrintWindow will handle the rest.

Paul.
Ionic Wind Support Team

Haim

Thanks,
How can I, with the method you suggested to specify the coordinates for printing the bitmap?

Ionic Wind Support Team

render it on the window in the position you want.  The PrintWindow command will scale it to fit the page.

Ionic Wind Support Team

Haim