Programming Examples
Starting the Designer
Programming Examples Printing
.NET
protected void button1_Click (object sender, System.EventArgs e) { try { // Bind to a DataSet object LL.SetDataBinding(myDataSet, "Orders");
// Set Properties LL.AutoDesignerFile = "subreport.lst"; LL.AutoProjectType = LlProject.List; LL.AutoDialogTitle = "Sample"; LL.AutoShowSelectFile = true;
// Call the Designer LL.Design(); } // Catch Exceptions: catch (Exception LlException) { MessageBox.Show("Information: " + LlException.Message,"Information", MessageBox.IconInformation | MessageBox.OK); } }
Delphi
{Start the Designer}
procedure TForm1.DesignButtonClick(Sender: TObject); begin //Assign data source LL.DataSource := dsCustomers;
//Pass customer data as fields LL.AutoMasterMode := mmAsFields;
//Set the default project name LL.AutoDesignerFile := 'subrep.lst';
//Switch print mode to preview LL.AutoDestination := adPreview;
//Call Designer LL.AutoDesign('Invoice List', ''); end;
C++
// Define special fields
normal text field: LlDefineFieldExt(job, "Text", "Testtext",LL_TEXT, NULL);
// Footer field, i.e. numeric:
LlDefineFieldExt(job, "Subtotal", "12.34", LL_NUMERIC | LL_TABLE_FOOTERFIELD, NULL);
// Barcode field:
LlDefineFieldExt(job, "BC_EAN_128", "123456789abcd", LL_BARCODE_EAN128, NULL);
// Variable graphics by file name:
LlDefineFieldExt(job, "Regular Graphic","sunny.bmp", LL_DRAWING, NULL);
// File open dialog with sketch: LlSelectFileDlgTitleEx(job, hWnd, "File open", LL_PROJECT_LIST, szFile,sizeof(szFile), NULL);
// Remove a certain menu command from the Designer:
LlDesignerProhibitAction(job, 211);
// Start the Designer with the above fields: LlDefineLayout(job, hWnd, "Title", LL_PROJECT_LIST, szFile);
Visual Basic
Private Sub ButtonDesign_Click() 'Start the Designer with the title "Invoice" and the file "invoice.rpt": ListLabel1.Design(0, hWnd, "Invoice", LL_PROJECT_LIST, "invoice.rpt", 1) End Sub
For data definition the event ListLabel1_CmndDefineFields is used.
.NET
private void button2_Click(object sender, System.EventArgs e) { try { // Bind to a DataSet object LL.SetDataBinding(myDataSet, "Orders");
// Set Properties LL.AutoDesignerFile = "subreport.lst"; LL.AutoProjectType = LlProject.List; LL.AutoDialogTitle = "Example"; LL.AutoShowSelectFile = true; // Start Print LL.Print(); } // Catch Exceptions: catch (Exception LlException) { MessageBox.Show("Information: " + LlException.Message,"Information", MessageBox.IconInformation | MessageBox.OK); } }
Delphi
{Printing}
procedure TForm1.PrintButtonClick(Sender: TObject); begin //Assign data source LL.DataSource := dsCustomers;
//Pass customer data as fields LL.AutoMasterMode := mmAsFields;
//Set the default project name LL.AutoDesignerFile := 'subrep.lst';
//Switch print mode to preview LL.AutoDestination := adPreview;
//Print LL.AutoDesign('Invoice List', ,); end;
C++
//=====================================
void CMainFrame::DoLabelPrint() //===================================== { // Define special fields, regular text field: LLDefineFieldExt(job, "Text", "Testtext",LL_TEXT, NULL);
// Numeric field: LLDefineVariableExt(job, "Subtotal", "12.34", LL_NUMERIC | LL_NUMERIC, NULL);
// Barcode field: LLDefineVariableExt(job, "BC_EAN_128", "123456789abcd", LL_BARCODE_EAN128, NULL);
// Variable graphic by file name:
LLDefineVariableExt(job, "Graphic","sunny.bmp", LL_DRAWING, NULL);
// Start printing: LlPrintWithBoxStart(job, LL_PROJECT_LABEL, szFile, LL_PRINT_EXPORT, LL_BOXTYPE_BRIDGEMETER, hWnd, "Printing..."); //Print label: nErrorValue = LlPrint(job);
// End printing: LlPrintEnd(job,0); }
Visual Basic
Private Sub ButtonPrint_Click()
'Print the project "test.rpt" on the printer: Data1.Recordset.MoveFirst ListLabel1.Print(0, LL_PROJECT_LIST, "test.lst",_ True, LL_PRINT_NORMAL,_ LL_BOXTYPE_NORMALWAIT, hWnd,_ "Print, True, Environ$("temp"))
End Sub
Private Sub ListLabel1_CmndDefineFields(ByVal nUserData As Long, ByVal bDummy As Long, nProgressInPerc As Long, pbLastRec As Long)
'This event is called by the commands Print and Design. 'It is called for each record to declare the fields and 'their contents to List & Label. 'Repeat for all fields of a 'record: For i = 0 To Form1.Data1.Recordset.Fields.Count - 1 content$ = Data1.Recordset.Fields(i) nRet = ListLabel1.LlDefineFieldExt _ (Data1.Recordset.Fields(i).Name,_ content$, LL_TEXT) Next i 'Skip to next record: Form1.Data1.Recordset.MoveNext 'Stop printing of last record is reached: If Form1.Data1.Recordset.EOF = True Then pbLastRec = 1 End If
End Sub
|