Document generation - design approach needed

Started by John Montenigro, February 07, 2014, 03:20:08 PM

Previous topic - Next topic

John Montenigro

I'm checking back to see if I've strayed off course...

In FF, I've got two forms:
- frmMAIN contains textboxes, ListView, etc. to accept user inputs/selections of variable data,
   and a command button called "PREVIEW" that:
       - invokes my PrintPage() function, then
       - shows the second form:
- frmPREVIEW contains the control/container to receive the XPRINT PREVIEW results,
   and a command button called "SAVE AND PRINT" that writes data values to a file and
   sends XPRINT statements to an actual printer.

- the PrintPage() function accepts a parameter (ToPreview, ToPrinter, ToPDF) 
   (At this time I'm using the PDFCreator printer driver to generate a PDF)
   If the param is ToPreview:
      XPrint Attach Default       
      XPrint Preview HWND_FRMPREVIEW, HWND_FRMPREVIEW_GraphicControl1
      'XPrint Preview HWND_FRMPREVIEW, HWND_FRMPREVIEW_RICHEDIT1       
      'XPrint Preview HWND_FRMPREVIEW, HWND_FRMPREVIEW_Picture1       
      'I'm not sure which type of control to use, so I'm experimenting...)

   If the param is anything else:
      XPrint Attach SelectedPrinter, JobName       

   Then all the XPRINT statements that generate the text with the user's data embedded...
   and ending with the proper type of XPRINT {PREVIEW} CLOSE

- the SaveAndPrint button just writes the user data to a file, then invokes
   the PrintPage() function with the ToPrinter parameter...
   
When I run the program, I am able to successfully:
- enter the data
- invoke the PREVIEW form           '  <--- but it's BLANK, and THAT's the problem
- click the SaveAndPrint button
The result: the printed page on the proper printer; everything looks perfect!

BUT, the control on the PREVIEW form that was supposed to receive the XPRINT statements,
is BLANK. As far as I can tell, nothing displays.
(It could be that everything is there, but too tiny to see, but I just can't tell, and besides,
it shows up on the printer at the proper size; why would there be such a dramatic difference?)

So, the question is: What am I doing wrong with the XPRINT ATTACH PREVIEW statements in the PrintPage() function, or with the controls on the PREVIEW form? Why am I not seeing the XPRINT PREVIEW results????

Thinking that maybe the PREVIEW form doesn't exist until AFTER the PREVIEW button on frmMAIN has been clicked (Paul, is that correct?), I even tried to open and hide that form first, but that didn't help either...

Can anyone identify what I'm doing wrong?

Thanks for your help,
-John

Paul Squires

The preview must be sent to a PB Graphic Control or a PB Graphic Window. FF does not have those as controls that you can add to a Form. FF's Graphic Control is not the same as PB's Graphic Control. I am pretty sure then is code on this site that shows using those PB's controls in FF. Maybe even the \Examples\GraphicDDT could help.
Paul Squires
PlanetSquires Software

John Montenigro

I'm so sorry to be so dense, I feel I'm nibbling this to death...

I added a CustomControl to the second form (frmPREVIEW), cloned the code from the GraphicDDT example (yes, I know I'll eventually remove some of it, but I copied it "as is" just to learn how it works...), and in frmMain, under the PrintPage() function, for the ToPreview parameter, I replaced the experimental statements from the earlier post to these:
      XPrint Attach Default       
      XPrint Preview HWND_FRMPREVIEW, HWND_FRMPREVIEW_CustomControl1 


Now when I click the PREVIEW button on the first form (date entry), the second form comes up, and the blue square shows nicely, but I still don't see any of my XPRINT text...

I'm still confused about this. How do the XPRINT PREVIEW statements interface to the CustomControl???

Is it unworkable to do the data entry on one form, the XPRINTs in a function, and the preview on a second form? Is that the problem? If so, what's a better way to organize this?

-John

Paul Squires

Hi John, I don't use XPRINT PREVIEW. Let me convert Gary's gbPrintPreview to a DLL for you. I will post that code in a few minutes.
Paul Squires
PlanetSquires Software

Paul Squires

Paul Squires
PlanetSquires Software

John Montenigro

Holy smokes, Bullwinkle!

Took me 3 minutes to create a tiny include for the primary TYPE and the DLL's DECLARE, and it compiled first shot!

Now to head home, have a bite to eat, then get back in and connect the dots!

Thanks, Paul for the boost, and Gary for the useful code!

Chat later,
-John

P.S. Paul, I hadn't realized that you didn't use the XPRINT PREVIEW. Besides Gary's code, is there a technical reason?


Paul Squires

Hey John, no big reason other than I haven't had any need to implement a print preview in my PowerBASIC apps. I have used XPRINT to print to printers.
Paul Squires
PlanetSquires Software

James Klutho

Just a note.  The gbPrintPreview has some bad memory leaks.  The main one being the use of ICONs in the imagelist of the toolbar-change the images to bitmaps.  It is bug in DDT.  There are others also which are mostly DDT bugs (in my opinion).  They are talked about in the gbPrintPreview thread on the PB forum.  If the DLL is called a lot it could add up.

Knuth Konrad

Quote from: Nathan Durland on February 11, 2014, 06:22:20 PM
Quote from: Knuth Konrad on February 08, 2014, 12:32:40 PM
A reporting component I use, which has a free "Community Edition" so that you can try it out, is Virtual Print Engine.

We use VPE (pro edition) on a daily basis.  We got it mostly for it's ability to natively save PDF files without CutePDF or the equivalent, but we also do graphing, emailing and all the fun stuff.

Same here (daily usage), that's why I mentioned it.

John Montenigro

I get such a kick out of the amount of homework you guys dish out!

So, having read above about possible problems due to DDT leaks in the gbPrintPreview INC, I'm now reading the manuals for the VPE.

I searched for code examples using Virtual Print Engine with FF and/or PB, and did find a posting of an .INC  from Apr 13th, 2010, by Antonello Ventullo, and some sample code. So I'll be experimenting with that tomorrow. (Snow shoveling has been a priority today - 14 inches of the stuff and I'm running out of places to put it)

Thanks, all, for the guidance!
-John

P.S. There are some ideas that I am not quite ready to explore - like the HTML into browser... that will take me many more hours to study, so I've put it on my To Do list for summer vacation. (and thanks for the suggestion of that technique!)

Petrus Vorster

John, if you get an .inc for VPE and you can make this work, PLEASE post some examples for me!
Are you using the FREE version of VPE with the NAG screen or did you buy it?
-Regards
Peter

John Montenigro

I'd be happy to share code when I get it working! (Got hit with more snow last night, so it looks like my coding gets put off till tomorrow and Sunday)

It looked to me as if there's one VPE download that lets you select which version during installation.
I need email capability and to rotate BMPs, so was thinking of getting the Enhanced version. But the difference between free and $498 makes me wonder if I can handle those things myself cheaper. Not sure yet.

I think I'll start with the Community version and see how far I can go with it. Their documentation indicates there are no incompatibility issues changing to another (upwards) version.

I will keep you posted of progress, but you should expect me to be asking more questions, too!
-John

Paul Squires

It might be easier and cheaper to simply fix the memory leaks in gbPrintPreview that James has indicated. Basically, switch from using the DDT syntax to WinAPI.
Paul Squires
PlanetSquires Software

Petrus Vorster

John & Paul

I hope I dont understand this post of John wrong, but my need is not for preview, therefore the Xprint preview or the GB one really doesnt help.
The need is to be able to create a professional form on the fly with images, words, backgrounds, tables and so forth, and then sends it out via PFD or a printer.
VPE seems to have the answer to this, an easy form/report creator. Making such a form in PB is very difficult (for me).

But then I cannot see on their site any PB support. Just C headers, which i dont have the skills to translate. And then there's the price....
-Regards
Peter

Petrus Vorster

John
;D
Dont complain about the snow!!! We are hitting summer temperatures around 40 degrees celsius!!!! We would LOVE that snow you have!!!!

;D
-Regards
Peter