阅读:1268回复:0
Example in Visual Basic
Private Sub btnPrintLegend_Click()
Dim Legend as MapXLib.Legend ' there is no Printer.StartDoc method, it is done ' implicitly when you use one of the printer.print methods ' so we need to print something before we print our legend ' to start the page Printer.CurrentX = 0 Printer.CurrentY = 0 Printer.Print " " Set Legend = Map1.Datasets(1).Themes(1).Legend ' Print legend same width and height as is shown on the map ' coords must be in himetric ' Assumes a screen device with 96 pixels per inch (most are) ' There are 2540 himetric units per inch ' Legend.Width and Height are returned in Screen units '(pixels) ' so conversion from pixels to himetric is ' pixels/pixelsperinch * himetricperinch Legend.PrintLegend Printer.hDC, 0, 0, Legend.Width / _ 96 * 2540, Legend.Height / 96 * 2540 ' This example prints a legend in the upper left that ' is 4 by 3 inches ' 4 by 3 inches (2540 himetric units per inch) 'Map1.Datasets(1).Themes(1).Legend.PrintLegend Printer.hDC, '0, '0, 10160, 7620 ' VB4 needed an explicit NewPage before the EndDoc, ' but VB5 doesn't 'Printer.NewPage ' Send new page. Printer.EndDoc ' Printing is finished. End Sub |
|
|