4DToday.com
Home Directory Classifieds Reference Archives
Site Info
About 4DToday.com
Contact Us
Version française
Quote
Developers (720)
4D Developers (590)
Web Developers (334)
Tools Publishers (193)
Instructors (163)
Web Hosts (59)
Resellers (87)
Software Publishers (295)
Search Developers
Products (383)
Plug-Ins (111)
Components (48)
Code Libraries (9)
Books (7)
Tools (42)
Vertical Applications (145)
Search Products
User Groups
All User Groups (22)
Classified Ads (15)
Help Wanted (3)
Opportunities Wanted (9)
Hardware Wanted (0)
Hardware for Sale (0)
Software Wanted (1)
Software for Sale (0)
Other (0)
Resources
4D
4D, Inc.
4D International
4D Wiki
4D Partner Central
4D Beginner's Center
4D Online Documentation
4D 2004 Example Applications
4D Example Databases
4D BugDisplayer
4D, Inc. Training
Message Lists
4D Mailing Lists
4D Tech Google Group
iNUG Archives (Nabble)
iNUG Archives (Gmane)
iNUG Message Index
Other
4D Code Exchange
4D Resources
Sviluppo4D.it (Italy)
4D Sources (4D Plugin API, 4D Pop & Miyako
Quote
Doubt, of whatever kind, can be ended by action alone.
Thomas Carlyle  
  Suggest a Quote  
Developer News
There are no news items at this time.
 Submit Future News    Archive 
Technical Tip
Generic Listbox print routine
Submitted by Keith Culotta, Computer Dimensions, Inc.

// ----------------------------------------------------
  // Method: PrintOutBox - 4D v12.2
  // Description - Prints a selection based listbox by "copying" it to a
  // Description - listbox named "OPBox" on a printing form named "outPrint".
  // Description - OPBox starts out selection based (any Table will do) and has no columns.
  // Description - This example uses the font settings of OPBox.
  //
  // INPUT1: Pointer - to the listbox you would like to print
  // OUTPUT:
  // ----------------------------------------------------


C_POINTER($1;$SourceBox)
$SourceBox:=$1
PAGE SETUP("outPrint") // has a listbox named "OPBox" of no particular height or width
PRINT SETTINGS

If (OK=1)  // Get info about the source listbox
  C_LONGINT($vLBTableNum;$vLBWidth;$size;$i;$vLBHeight)
  ARRAY TEXT($aColNames;0)
  ARRAY TEXT($aHeaderNames;0)
  ARRAY POINTER($aColVars;0)
  ARRAY POINTER($aHeaderVars;0)
  ARRAY BOOLEAN($aVisible;0)
  ARRAY POINTER($aStyles;0)
  C_BOOLEAN($TotallyPrinted)
  
  LISTBOX GET ARRAYS($SourceBox->;$aColNames;$aHeaderNames;$aColVars;$aHeaderVars;$aVisible;$aStyles)
  $size:=Size of array($aColNames)
  ARRAY LONGINT($aColWidth;$size)
  ARRAY TEXT($aHeaderText;$size)
  
  $vLBWidth:=0
  For ($i;1;$size)
  $aColWidth{$i}:=LISTBOX Get column width($aHeaderVars{$i}->)
  $vLBWidth:=$vLBWidth+$aColWidth{$i}
  $aHeaderText{$i}:=OBJECT Get title($aHeaderVars{$i}->)
  End for
  
  LISTBOX GET TABLE SOURCE($SourceBox->;$vLBTableNum)
  
  OPEN PRINTING JOB
  OPEN PRINTING FORM("outPrint")
  
   //  adjust OPBox's size to the User's Print Settings
  SET PRINTABLE MARGIN(0;0;0;0)
  GET PRINTABLE AREA($vLBHeight)
  OBJECT MOVE(OPBox;0;0;$vLBWidth;$vLBHeight;*)  // note that the box can be set wider than the paper
  
  LISTBOX SET TABLE SOURCE(OPBox;$vLBTableNum)
  
    // Set up OPBox to look like the source listbox
  $size:=Size of array($aColNames)
  For ($i;1;$size)
    If ($aVisible{$i})  // don't print invisible columns
      $vLBWidth:=LISTBOX Get number of columns(OPBox)+1
      LISTBOX INSERT COLUMN(OPBox;$vLBWidth;$aColNames{$i};$aColVars{$i}->;$aHeaderNames{$i};$aHeaderVars{$i}->)
      LISTBOX SET COLUMN WIDTH($aHeaderVars{$i}->;$aColWidth{$i})
      OBJECT SET TITLE($aHeaderVars{$i}->;$aHeaderText{$i})
    End if
  End for
  
    // and print
  Repeat
    $TotallyPrinted:=Print object(OPBox)
    If (Not($TotallyPrinted))
      PAGE BREAK
    End if
  Until ($TotallyPrinted)
  
  CLOSE PRINTING JOB
  
End if
  Submit a Tip    Archive 
Spotlight
Active4D 64-bit
Active4D 64-bit Active4D is now available for 4D v12 64-bit Server! Take full advantage of your 64-bit hardware with the power of Active4D.
  Suggest a Spotlight  
Survey Results
Today, we asked you...
Are you going to the folk festival?
Survey Results

Your vote: (no vote)
Total votes received: 5
  Suggest a Survey  
Events
There are no events scheduled for the upcoming fortnight.
  Submit an Event