October 30, 2025, 11:46:24 AM

News:

IWBasic runs in Windows 11!


Printer

Started by Haim, March 27, 2006, 11:44:59 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Haim

I need to print an exact-size rectangle (dimensions in mm or inches given by the user), to a selected printer.
Can anyone show me how this can be  done?

Will there eventually be a "printer" class?

Any help will be apreciated.

Ionic Wind Support Team

Yes there will be more printing capabilities when I get the time to write them.  Some users have had success with DDOC (search google).

It is not that printing is necessarily hard, just very complicated with a lot of details to work out.  Windows uses mapping modes to display pixels on the screen, printer or whatever device.  The mapping modes determine the relationship between units.

The default mapping mode is MM_TEXT which means there is a one to one correlation between a pixel and a unit specified in a drawing operation.  DrawRect(0,0,100,100, RGB(0,0,0))  Draws a rectangle 100 pixels wide by a 100 pixels wide starting at the upper left corner  in MM_TEXT mode.  If you were to draw that directly on a printer that had a resolution of 600 DPI then the rectangle would only be 1/6 of an inch wide.

Changing mapping modes is easy enough but other details then come into play.  If you were to set the mapping mode to MM_LOMETRIC then each unit would be .1 mm  on both the printer and the screen, however Windows flips the Y axis so that positive values go up the screen and negative go down.  So drawing commands have to be adjusted. 

There are other ways to do it of course.  You can scale your drawing based on the DPI ratio of the printer/screen.  GetDeviceCaps with a device context of the printer can give you it's horiz/vert DPI, the same with the screen.  Which is how CWindow::PrintWindow works to scale the display to fit nicely on the printer in the horizontal direction.

This page probably explains it better ;)

http://www.functionx.com/visualc/gdi/gdicoord.htm
Ionic Wind Support Team

Haim

Thanks for the reference.
I'll try to go on from there.

Parker

That's really cool, I wasn't aware that windows allowed switching coordinate systems like that.

John S

I was able to port the DDOC system demo to IBasic Pro and I know it worked on IBStd.
I was going to try to port it to Aurora. 
I may have a chance next weekend now that I got my work and schooling under control (one of my midterms took 16 hours to finish).
John Siino, Advanced Engineering Services and Software