PlanetSquires Forums

Support Forums => PlanetSquires Software => Topic started by: Paul Squires on March 17, 2023, 10:01:22 AM

Title: CPrintPreview (version 1.0.0)
Post by: Paul Squires on March 17, 2023, 10:01:22 AM
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!

Title: Re: CPrintPreview (version 1.0.0)
Post by: James Klutho on March 17, 2023, 05:29:57 PM
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?
Title: Re: CPrintPreview (version 1.0.0)
Post by: SeaVipe on March 17, 2023, 07:53:45 PM
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.
Title: Re: CPrintPreview (version 1.0.0)
Post by: Paul Squires on March 17, 2023, 09:27:35 PM
Quote from: James Klutho on March 17, 2023, 05:29: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.
Title: Re: CPrintPreview (version 1.0.0)
Post by: Paul Squires on March 17, 2023, 09:29:13 PM
Quote from: SeaVipe on March 17, 2023, 07:53: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.
Title: Re: CPrintPreview (version 1.0.0)
Post by: Paul Squires on March 17, 2023, 09:31:12 PM
Quote from: James Klutho on March 17, 2023, 05:29:57 PMI love the simplicity of your code.  Very nicely done.

BTW, Jim are you still working on or modifying your EZP print control?
Title: Re: CPrintPreview (version 1.0.0)
Post by: James Klutho on March 17, 2023, 10:13:26 PM
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". 
Title: Re: CPrintPreview (version 1.0.0)
Post by: SeaVipe on March 21, 2023, 03:12:26 PM
Hi Paul, I'll have another look. Thanks again for the CPrintPreview class!

Title: Re: CPrintPreview (version 1.0.0)
Post by: Petrus Vorster on March 22, 2023, 02:42:54 AM
I missed that post that its available!
Thanks a million Paul.

Will be testing this today!

-Peter
Title: Re: CPrintPreview (version 1.0.0)
Post by: Petrus Vorster on March 22, 2023, 09:09:05 AM
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
Title: Re: CPrintPreview (version 1.0.0)
Post by: Paul Squires on March 22, 2023, 09:15:43 AM
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.