April 27, 2024, 06:46:07 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Printing Contents of a Listview Control.

Started by Jim Scott, February 10, 2007, 03:56:35 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Jim Scott

Is there an easy way of printing the contents of a Listview Control with borders around the items like a spread sheet program does?
Jim Scott

Ionic Wind Support Team

List view controls are just display devices, they don't have anything advanced put into them by Microsoft.

You're two easiest choices are html and rtf.  Create an html table onthe fly with the data from the listview control and load it into a browser window for printing.

Or create an RTF table and load it into a rich edit control, hidden or otherwise, and printi it from there.

Paul,
Ionic Wind Support Team

Jim Scott

Anyone have any examples of using multicolumn html and rtf tables within an EBASIC RichEdit control?  I'm having a hard time figuring it on my own?  The help isn't real helpful in this regard.
Jim Scott

Ionic Wind Support Team

The help isn't designed to teach HTML, there are enough web references on that subject.  If you are having a specific coding problem then by all means let us know.

The html would be loaded into a browser window using :

BROWSECMD win, @BROWSELOAD, htmlString

The reference in the users guide is under the section "Windows programming->Creating embedded browser controls".  After the string containing the html is loaded just call :

BROWSECMD win, @BROWSEPRINT

If you wish to use a Rich Edit control then you'll need to learn RTF format:

http://www.biblioscape.com/rtf15_spec.htm

Paul.
Ionic Wind Support Team

Jim Scott

ok, how about an example?

The following code creates a long text string with the RTF commands for a table with 9 columns and 2 rows + header row.
It then loads that into a RichEdit control but it doesn't come out right.  I've attached an RTF file with the same commands to illustrate what I'm trying to do within the code.

CONST RICHEDIT_1 = 1
Def text[100000] as IString

DIALOG d1
CREATEDIALOG d1,0,0,1200,673,0x80C80080,0,"Caption",&d1_handler
CONTROL d1,@RICHEDIT,"",0,44,1200,588,0x50A02084|@VSCROLL|@HSCROLL,RICHEDIT_1

text = "{\rtf1\ansi\ansicpg1252\deff0\deftab709{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}}"
text = text + "{\colortbl ;\red0\green0\blue0;}"
text = text + "{\*\generator Msftedit 5.41.15.1507;}"
text = text + "\viewkind4\uc1\trowd\trgaph10\trleft-20\trpaddl10\trpaddr10\trpaddfl3\trpaddfr3"
text = text + "\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrt\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx579\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrt\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx2454\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrt\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx4299\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrt\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx6339\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrt\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx9776\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrt\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx10886\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrt\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx11994\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrt\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx13106\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrt\brdrw1\brdrs\brdrcf1\clbrdrr\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx14094\pard\intbl\qc\lang1033\b\i\f0\fs24 "
text = text + "Loc."
text = text + "\cell "
text = text + "Last Name"
text = text + "\cell "
text = text + "First Name"
text = text + "\cell "
text = text + "Vehicle Type"
text = text + "\cell "
text = text + "Description"
text = text + "\cell "
text = text + "License"
text = text + "\cell "
text = text + "Date In"
text = text + "\cell "
text = text + "Date Out"
text = text + "\cell\pard\intbl\qc\tx210\tx330\tx555\tx585\tx630\tx795 "
text = text + "Balance"
text = text + "\cell\row\trowd\trgaph10\trleft-20\trpaddl10\trpaddr10\trpaddfl3\trpaddfr3"
text = text + "\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx579\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx2454\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx4299\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx6339\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx9776\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx10886\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx11994\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx13106\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrr\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx14094\pard\intbl\li72\b0\i0 "
text = text + "1"
text = text + "\cell "
text = text + "Newman"
text = text + "\cell "
text = text + "Alfred E."
text = text + "\cell "
text = text + "Old Jalopy"
text = text + "\cell "
text = text + "Very Rusty"
text = text + "\cell "
text = text + "123None"
text = text + "\cell "
text = text + "01/02/06"
text = text + "\cell "
text = text + "01/02/06"
text = text + "\cell\pard\intbl\ri72\qr "
text = text + "500"
text = text + "\cell "
text = text + "\row\trowd\trgaph10\trleft-20\trpaddl10\trpaddr10\trpaddfl3\trpaddfr3"
text = text + "\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx579\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx2454\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx4299\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx6339\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx9776\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx10886\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx11994\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx13106\clbrdrl\brdrw1\brdrs\brdrcf1\clbrdrr\brdrw1\brdrs\brdrcf1\clbrdrb\brdrw1\brdrs\brdrcf1 "
text = text + "\cellx14094\pard\intbl\li72 "
text = text + "2"
text = text + "\cell "
text = text + "Scott"
text = text + "\cell "
text = text + "James"
text = text + "\cell "
text = text + "5 th wheel"
text = text + "\cell "
text = text + "29' Prowler"
text = text + "\cell "
text = text + "abc123"
text = text + "\cell "
text = text + "06/01/00"
text = text + "\cell "
text = text + "02/10/07"
text = text + "\cell\pard\intbl\ri72\qr "
text = text + "0"
text = text + "\cell\row\pard\par"
text = text + "}"


Domodal d1
SUB d1_handler
SELECT @MESSAGE
CASE @IDINITDIALOG
CENTERWINDOW d1
ControlCMD d1,RichEdit_1,@RTLOAD,text,1
/* Initialize any controls here */
CASE @IDCLOSEWINDOW
CLOSEDIALOG d1,@IDOK
CASE @IDCONTROL
SELECT @CONTROLID
CASE RICHEDIT_1
/* respond to control notifications here */
ENDSELECT
ENDSELECT
RETURN
ENDSUB
Jim Scott

Ionic Wind Support Team

a \ in a string has to be written as \\ since it is an escape character.  Outlined in the users guide under "Constants and Literals".


CONST RICHEDIT_1 = 1
Def text[100000] as IString

DIALOG d1
CREATEDIALOG d1,0,0,1200,673,0x80C80080,0,"Caption",&d1_handler
CONTROL d1,@RICHEDIT,"",0,44,1200,588,0x50A02084|@VSCROLL|@HSCROLL,RICHEDIT_1

text = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deftab709{\\fonttbl{\\f0\\froman\\fprq2\\fcharset0 Times New Roman;}}"
text = text + "{\\colortbl ;\\red0\\green0\\blue0;}"
text = text + "{\\*\\generator Msftedit 5.41.15.1507;}"
text = text + "\\viewkind4\\uc1\\trowd\\trgaph10\\trleft-20\\trpaddl10\\trpaddr10\\trpaddfl3\\trpaddfr3"
text = text + "\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrt\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx579\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrt\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx2454\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrt\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx4299\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrt\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx6339\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrt\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx9776\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrt\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx10886\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrt\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx11994\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrt\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx13106\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrt\\brdrw1\\brdrs\\brdrcf1\\clbrdrr\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx14094\\pard\\intbl\\qc\\lang1033\\b\\i\\f0\\fs24 "
text = text + "Loc."
text = text + "\\cell "
text = text + "Last Name"
text = text + "\\cell "
text = text + "First Name"
text = text + "\\cell "
text = text + "Vehicle Type"
text = text + "\\cell "
text = text + "Description"
text = text + "\\cell "
text = text + "License"
text = text + "\\cell "
text = text + "Date In"
text = text + "\\cell "
text = text + "Date Out"
text = text + "\\cell\\pard\\intbl\\qc\\tx210\\tx330\\tx555\\tx585\\tx630\\tx795 "
text = text + "Balance"
text = text + "\\cell\\row\\trowd\\trgaph10\\trleft-20\\trpaddl10\\trpaddr10\\trpaddfl3\\trpaddfr3"
text = text + "\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx579\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx2454\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx4299\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx6339\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx9776\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx10886\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx11994\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx13106\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrr\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx14094\\pard\\intbl\\li72\\b0\\i0 "
text = text + "1"
text = text + "\\cell "
text = text + "Newman"
text = text + "\\cell "
text = text + "Alfred E."
text = text + "\\cell "
text = text + "Old Jalopy"
text = text + "\\cell "
text = text + "Very Rusty"
text = text + "\\cell "
text = text + "123None"
text = text + "\\cell "
text = text + "01/02/06"
text = text + "\\cell "
text = text + "01/02/06"
text = text + "\\cell\\pard\\intbl\\ri72\\qr "
text = text + "500"
text = text + "\\cell "
text = text + "\\row\\trowd\\trgaph10\\trleft-20\\trpaddl10\\trpaddr10\\trpaddfl3\\trpaddfr3"
text = text + "\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx579\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx2454\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx4299\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx6339\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx9776\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx10886\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx11994\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx13106\\clbrdrl\\brdrw1\\brdrs\\brdrcf1\\clbrdrr\\brdrw1\\brdrs\\brdrcf1\\clbrdrb\\brdrw1\\brdrs\\brdrcf1 "
text = text + "\\cellx14094\\pard\\intbl\\li72 "
text = text + "2"
text = text + "\\cell "
text = text + "Scott"
text = text + "\\cell "
text = text + "James"
text = text + "\\cell "
text = text + "5 th wheel"
text = text + "\\cell "
text = text + "29' Prowler"
text = text + "\\cell "
text = text + "abc123"
text = text + "\\cell "
text = text + "06/01/00"
text = text + "\\cell "
text = text + "02/10/07"
text = text + "\\cell\\pard\\intbl\\ri72\\qr "
text = text + "0"
text = text + "\\cell\\row\\pard\\par"
text = text + "}"


Domodal d1
SUB d1_handler
SELECT @MESSAGE
CASE @IDINITDIALOG
CENTERWINDOW d1
ControlCMD d1,RichEdit_1,@RTLOAD,text,1
/* Initialize any controls here */
CASE @IDCLOSEWINDOW
CLOSEDIALOG d1,@IDOK
CASE @IDCONTROL
SELECT @CONTROLID
CASE RICHEDIT_1
/* respond to control notifications here */
ENDSELECT
ENDSELECT
RETURN
ENDSUB
Ionic Wind Support Team

Jim Scott

Thanks Paul, that fixes that piece of code.  That's one of the problems with programming part time and in spurts.  At least now I can experiment, learn more and make some progress.

There are still some lingering questions I have.  I was hoping to gain more general guidance on program methodology from you folks with a lot more experience than me.

The application I'm working on has a bunch a data about our clients and their purpose for being here.  The same data will be used to create different forms, some printed, some are only for screen use, some of the forms are best made with listview controls and I suppose tables for printing, while others will be very custom forms for printing on perforated paper.  Some times I'm going to want to print a hard copy form for an entire list of clients while other times I'm going to want to print only 1 or a few of a bigger list.  In some cases I'm going to let the user manually change the data on a particular client before printing a form.

My current code has all on screen lists of this data in ListView controls.  I'm using tabs and Radio buttons to organize the data by client type and purpose for their being at the Ranch I work at.  I haven't gotten to the point of writing the code to select a subset of the lists and allowing the user to modify contents before acting on the data.  Am I better off using a RichEdit Control for selecting and modifying before printing or some other control?  Is it a good idea to use RTF (or maybe HTML) as a "Print Preview" method and also make this the place for the user to make last minute tweaks to the data?  Or is it better, from a GUI point of view, to make a Dialog pop-up in Modal mode to allow temporary modification of a single record before printing?

What general approaches have worked best for you?  I'm afraid of getting too far down the line, committed to a particular approach, only to learn latter that I could have done it some much better way.  I know this is just part of the learning process as I'm currently reviewing methods and getting ready to rewrite about 1500 lines of code that deal with the reading, sorting and listing of this data.

I guess that's why I was asking for any examples you folks may be willing to share.

Thanks for any help you can provide.

Jim Scott
Jim Scott

mrainey

You might want to take a look at the ddoc printing library ($25.00).  It works great with IBasic and EBasic.  There's a demo available.

http://www.greatwebdivide.com/software.htm
Software For Metalworking
http://closetolerancesoftware.com

Rod

I will add that I have purchased the ddoc software, and have been very pleased (and very successful) with it.

My app was printing a replica of a form which had been originally designed as a handwritten form, then filling it in with data obtained from a database query.

The only "tricky" part was getting things to line up perfectly. The first pass, based on following directions, plus my own intuition and calculations, got things pretty close to right. I printed out a test page, tweaked settings a bit, and printed again. It IS possible with this package to get just the look you want.

Jim Scott

Thanks guys,  I'll look into it.

Any thoughts on Control selection for large lists with the ability to modify items and print from mouse selected subsets?

Jim Scott
Jim Scott

John S

Quote from: Rod on February 12, 2007, 08:08:19 AM
I will add that I have purchased the ddoc software, and have been very pleased (and very successful) with it.

My app was printing a replica of a form which had been originally designed as a handwritten form, then filling it in with data obtained from a database query.

The only "tricky" part was getting things to line up perfectly. The first pass, based on following directions, plus my own intuition and calculations, got things pretty close to right. I printed out a test page, tweaked settings a bit, and printed again. It IS possible with this package to get just the look you want.

Rod,
I too have ddoc, but haven't used it yet.  I will be picking your brain about this.
John Siino, Advanced Engineering Services and Software