Jim

FYI. If you want to print a list box The code is rather slow. Its actually 
better to convert it to a Quick report.

The following code will print any listbox area. As you can see I have not 
optimised this for V16. I need to look at the way it is setting the font and 
size etc, it also uses some formats from my system -should not take much to 
adapt this to your needs.(I tried it with a million rows i think and it was 
pretty impressive)

ARRAY TEXT($arrColNames;0)              
                ARRAY TEXT($arrHeaderNames;0)
                ARRAY POINTER($arrColVars;0)
                ARRAY POINTER($arrHeaderVars;0)
                ARRAY BOOLEAN($arrColsVisible;0)
                ARRAY POINTER($arrStyles;0)
                
C_LONGINT($left;$Top;$Right;$Bottom;$MaxRows;$MaxPortrait;$MaxHeight;$MaxWidth)


                LISTBOX GET 
ARRAYS(DB_b_OutputArrays;$arrColNames;$arrHeaderNames;$arrColVars;$arrHeaderVars;$arrColsVisible;$arrStyles)<—use
 your listbox area reference here
                $TotalWidth:=0
                For ($i;1;Size of array($arrColNames))
                        $TotalWidth:=$TotalWidth+LISTBOX Get column 
width(*;$arrColNames{$i})

                End for 
                //$OK:=PRINT_SetSIZE ("A4";"P”)<—This is  piece of code  i have 
that sets the print size-its 
                

$QRarea:=QR New offscreen area                  
                        QR SET REPORT TABLE($QRarea;DB_l_CurrentDisplayedForm)
                        $ColumnNumber:=0
                        For ($i;1;Size of array($arrColNames))

                                RESOLVE 
POINTER($arrColVars{$i};$vsVarName;$vlTableNum;$vlFieldNum)
                                If ($vlTableNum>0) | ($vsVarName#"")
                                        $ColumnNumber:=$ColumnNumber+1
                                        If ($vlTableNum>0)
                                                
$Field:=Field($vlTableNum;$vlFieldNum)
                                        Else 
                                                $Field:=Get pointer($vsVarName)
                                        End if 
                                        $HeadVar:=$arrHeaderVars{$i}
                                        QR INSERT 
COLUMN($QRarea;$ColumnNumber;$Field)
                                        C_TEXT($title;$displayFormat)
                                        C_LONGINT($hide;$repeatedValue)
                                        C_LONGINT($size)

                                        $type:=Type(($Field)->)
                                        $Format:=""
                                          //LB_SetFormat ($Area;1;"";$i;$i;3)
                                        Case of 
                                                : (($type=1)) & ($Format="")
                                                        $Format:="|AccountsNZ"
                                                : (($Type=8)) & ($Format="")
                                                        $Format:="|integers"
                                                : (($type=9)) & ($Format="")
                                                        $Format:="|Longint"

                                                : ($type=Is time) & 
($Format="")  
                                                        $Format:="&/5"
                                                : ($type=4) & ($Format="")
                                                        $Format:=""

                                                Else 
                                                        $Format:=""
                                        End case 

                                        C_TEXT($object)
                                        QR GET INFO 
COLUMN($QRarea;$ColumnNumber;$title;$object;$hide;$size;$repeatedValue;$displayFormat)
                                        $ColumnWidth:=LISTBOX Get column 
width(*;$arrColNames{$i})
                                        $Hide:=Num(($ColumnWidth=0) | 
($arrColsVisible{$i}=False))

                                        $ColumnTitle:=OBJECT Get 
title($HeadVar->)

                                        QR SET INFO 
COLUMN($QRarea;$ColumnNumber;$ColumnTitle;$object;$Hide;$ColumnWidth;1;$Format)
                                        If (True)
                                                QR SET TEXT 
PROPERTY($QRarea;$ColumnNumber;qr title;_O_qr font;_o_Font number(<>FontBold))

                                                QR SET TEXT 
PROPERTY($QRarea;$ColumnNumber;qr title;qr font size;<>FontDefaultBoldSize)
                                                QR SET TEXT 
PROPERTY($QRarea;1;-1;qr bold;1)
                                                  //QR SET TEXT 
PROPERTY($QRarea;1;-1;qr text color;0x0000FF00)

                                                QR SET TEXT 
PROPERTY($QRarea;$ColumnNumber;qr detail;_O_qr font;_o_Font number(<>FontPlain))
                                                QR SET TEXT 
PROPERTY($QRarea;$ColumnNumber;qr detail;qr font size;<>FontDefaultPlainSize)
                                        End if 
                                End if 
                        End for 
                        If ($TotalWidth>$MaxPortrait)
                                //$OK:=PRINT_SetSIZE ("A4";"L”)<-changes the 
print to landscape
                                GET PRINTABLE AREA($MaxRows;$MaxLandcscape)
                                If ($MaxLandcscape<$TotalWidth)
                                        Gen Confirm ("Format to one sheet 
wide?";"Yes";"No")
                                        If (OK=1)
                                                
$PC:=Int($MaxLandcscape/($TotalWidth/100))


                                                If ($PC<100)
                                                        SET PRINT OPTION(Scale 
option;$PC)
                                                End if 
                                        End if 
                                End if 
                                GET PRINTABLE MARGIN($left;$Top;$Right;$Bottom)
                                GET PRINTABLE AREA($MaxHeight;$MaxWidth)
                        Else 
                                GET PRINTABLE MARGIN($left;$Top;$Right;$Bottom)
                                GET PRINTABLE AREA($MaxHeight;$MaxWidth)
                        End if 
                        $maxlines:=Int($MaxHeight/16)

                          //PRINT SETTINGS
                        QR RUN($QRarea)
                        QR DELETE OFFSCREEN AREA($QRarea)


Nigel Greenlee


> On 2 Aug 2017, at 19:18, James Crate via 4D_Tech <[email protected]> wrote:
> 
> I am printing a listbox on a form which just has a detail section (i.e. Print 
> Form). The listbox is printing, but variable sized according to the arrays, 
> and I’d like fixed size with empty rows. There isn’t much documentation on 
> printing listboxes, there’s no “Print variable frame” checkbox like text 
> areas, and they don’t even receive the normal printing events. Is there a way 
> to accomplish this?
> 
> Jim Crate
> 
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[email protected]
> **********************************************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to