• Welcome to PlanetSquires Forums.
 

CPrintPreview (version 1.0.0)

Started by Paul Squires, March 17, 2023, 09:31:22 AM

Previous topic - Next topic

Paul Squires

The CPrintPreview class is now ready for download and testing.

https://github.com/PaulSquires/CPrintPreview

I will enhance the class and fix any issues as I receive feedback.

The latest version of the WinFBE Editor does not (yet) have José's latest version of his WinFBX library and recently José made a small change to the CPrint.inc file that affects the CPrintPreview class. You can simply modify the CPrint.inc file (found in the inc/Afx folder off of the toolchain folder).

Around line 442, make sure the line reads:
   pd.DesiredAccess = PRINTER_ACCESS_USE

Rather than:
   pd.DesiredAccess = PRINTER_ALL_ACCESS

Good luck!

Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

James Klutho

#1
I love the simplicity of your code.  Very nicely done.  A note, I couldn't get the preview "zoom" to work though the demo printed just fine.  Also, will you support vertical or angled fonts?

SeaVipe

Thanks, Paul, your CPrintPreview class is head and shoulders above my kludgy old RTF stuff!
On my PC zoom and print work as expected. I've had to tweak several colour settings (my default Windows mode is set to dark maybe that's why most of the preview was black on black). Adding clrFill, clrBack and clrText values fixed all of that. Added #Include Once "WinFormsX/wfxColors.bi" to TestPrintPreview.bas.

pCanvas->WriteText( 1.5, 3.5, "Phone: (000) 000-0000", colors.Black, colors.White )
pCanvas->WriteTextBox( 12.5, 3.5, 16.6, 4.2, "INVOICE #", hPen, colors.LightSlateGray, DT_TOP or DT_RIGHT, colors.Black, colors.White )

I modified the following function to set a different colour rectangle:
' Draw a box (rectangle) using the passed Pen.
function CPrintPreview.DrawRect( _
                  byval nLeft as single, _
                  byval nTop as single, _
                  byval nRight as single, _
                  byval nBottom as single, _
                  byval hPen as HPEN _
                  ) as long
  return DrawRectInternal( nLeft, nTop, nRight, nBottom, hPen, -1 ) ' <- this last value sets the fill colour to Black.
end function

I added a parameter to CPrintPreview.DrawRect:
 byval clrFill as COLORREF  '' changed -1 to clrFill allowing the fill colour to be customized.

I'm sure I've overlooked something obvious, but the above works.
Clive Richey

Paul Squires

Quote from: James Klutho on March 17, 2023, 04:59:57 PMI love the simplicity of your code.  Very nicely done.  A note, I couldn't get the preview "zoom" to work though the demo printed just fine.  Also, will you support vertical or angled fonts?
Thanks Jim, appreciate it and, yes, vertical and angle fonts will part of the roadmap for sure.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

Quote from: SeaVipe on March 17, 2023, 07:23:45 PMI'm sure I've overlooked something obvious, but the above works.

Hi Clive, I think you missed the DrawSolidRect function? Your changes to DrawRect seem to mimic the functionality of DrawSolidRect.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

Quote from: James Klutho on March 17, 2023, 04:59:57 PMI love the simplicity of your code.  Very nicely done.

BTW, Jim are you still working on or modifying your EZP print control?
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

James Klutho

No, I have not modified the code since I uploaded it.  It was simply an exercise to see if I could get a print control working and to see if I could get a non-resource based dialog box implemented.  I had never done either.  I should have made it a class like you did.  If I remember right, I had made the printer portion a class but not the whole thing in its entirety. I must say that I love reading your well written code versus my "just get the darn thing working style". 

SeaVipe

Hi Paul, I'll have another look. Thanks again for the CPrintPreview class!

Clive Richey

Petrus Vorster

I missed that post that its available!
Thanks a million Paul.

Will be testing this today!

-Peter
-Regards
Peter

Petrus Vorster

Hi All
Paul, I have send you an enmail just now, to keep my blunders off the group.

Something that I noticed about barcode support, is I assume you speak of Barcodes as Image objects or physical barcode drawing?

I have spoken to a few people that develops for the retail industry, and they have all abandoned barcode drawings. The easiest method is a barcode font. You do the checkdigit and encoding in a string, and output that string to a font in a document. (saves pages of coding, and superfast output with simple text tools)

We can test this with a simple one I use. Download code39 barcode font and install on your PC.
To encode a string simply add *before and *after the string you need to scan. Use the font to write the barcode in the document. It works like a charm.
All these more complicated barcodes like code128 etc have (PAYABLE) fonts available as long as you encode the string right.

Having to go that extra mile to include barcodes may not be neccesary, if this font trick works.

-regards, Peter
-Regards
Peter

Paul Squires

Interesting! Yes, if just using a font works then by all means go for it. It would make life so much easier and then I can simply exclude not having to explicitly try to incorporate barcode support into the print preview code. The user could easily create the barcode themselves just like drawing any other text output. The only time I have ever dealt with barcodes in during the discussions that I've had with you because I have no real world use for them. Therefore my experience is very limited and I defer to you for advice on the best and easiest approach to implement barcodes in code.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer