阅读:4537回复:12
如何实现打印MapControl控件内容?
RT,新手,搞了好几天未果,请各位高手拉小弟一把,谢谢了先!!!
|
|
|
1楼#
发布于:2005-07-28 15:12
<P>使用pagelayerout打印啊</P>
<P>问点具体的问题哦</P> |
|
|
2楼#
发布于:2005-07-29 09:24
<P>呵呵,我现在是想用MAPCONTROL打印,不用pagelayerout</P>
<P>MapControl可以输出各种格式的图片文件,那如何直接输出打印呢?</P> |
|
|
3楼#
发布于:2005-09-21 17:39
<P>帮楼主顶</P>
<P>希望高手来解答一下</P><img src="images/post/smile/dvbbs/em02.gif" /><img src="images/post/smile/dvbbs/em02.gif" /> |
|
4楼#
发布于:2005-09-21 22:12
<DIV class=quote><B>以下是引用<I>hope_xt</I>在2005-7-29 9:24:44的发言:</B><BR>
<P>呵呵,我现在是想用MAPCONTROL打印,不用pagelayerout</P> <P>MapControl可以输出各种格式的图片文件,那如何直接输出打印呢?</P></DIV> <P>那可以直接调用打印机打印了了 <P>如果需要例如比例尺\边框等要素的设置,建议使用pagelayerout控件吧</P> |
|
|
5楼#
发布于:2005-09-22 14:47
<P>麻烦站长帮解答下</P>
<P>直接调用打印机的话</P> <P>怎么初始化IPrinter接口呢?就是说怎么把PRINTER对象中的打印机信息赋值给ENGINE中的IPrinter呢?</P><img src="images/post/smile/dvbbs/em02.gif" /><img src="images/post/smile/dvbbs/em02.gif" /> |
|
6楼#
发布于:2005-09-23 10:32
<P>Private Function ConvertMapUnitsToPixels(RWUnits As Double) As Double<BR> On Error GoTo ErrorHandler</P>
<P> Dim realWorldDisplayExtent As Double<BR> Dim pixelExtent As Long<BR> Dim sizeOfOnePixel As Double<BR> Dim pDT As esriCore.IDisplayTransformation<BR> Dim deviceRECT As tagRECT<BR> Dim pEnv As esriCore.IEnvelope<BR> <BR> <BR> ' Get the width of the display extents in Pixels<BR> ' and get the extent of the displayed data<BR> ' work out the size of one pixel and then return<BR> ' the pixels units passed in mulitplied by that value<BR> Dim pActiveView As esriCore.IActiveView<BR> Set pActiveView = m_pHook.ActiveView<BR> Set pDT = pActiveView.ScreenDisplay.DisplayTransformation<BR> deviceRECT = pDT.DeviceFrame<BR> pixelExtent = deviceRECT.Right - deviceRECT.Left<BR> Set pEnv = pDT.FittedBounds<BR> <BR> realWorldDisplayExtent = pEnv.Width<BR> sizeOfOnePixel = realWorldDisplayExtent / pixelExtent<BR> ConvertMapUnitsToPixels = RWUnits / sizeOfOnePixel</P> <P><BR> Exit Function<BR>ErrorHandler:<BR> HandleError False, "ConvertMapUnitsToPixels " ; c_ModuleFileName ; " " ; GetErrorLineNumberString(Erl), Err.Number, Err.Source, Err.Description, 1<BR>End Function</P> <P>Private Sub PrintToPrinter()<BR> On Error GoTo ErrorHandler</P> <P> Dim pPrinter As esriCore.IPrinter<BR> Dim screenResolution As Long<BR> Dim userRECT As tagRECT<BR> Dim pDriverBounds As esriCore.IEnvelope<BR> Dim oPrinter As Object<BR> <BR> Set oPrinter = Printer<BR> <BR> If (oPrinter Is Nothing) Then<BR> Beep<BR> MsgBox "To plot the map you must have a printer installed", vbExclamation + vbOKOnly, "No Printer Installed"<BR> Exit Sub<BR> End If<BR> <BR> SetupPrinter oPrinter, pPrinter</P> <P> Dim pActiveView As esriCore.IActiveView<BR> Set pActiveView = m_pHook.ActiveView<BR> screenResolution = pActiveView.ScreenDisplay.DisplayTransformation.Resolution<BR> pPrinter.Resolution = screenResolution<BR> <BR> userRECT.Top = 0<BR> userRECT.Left = 0<BR> userRECT.Right = ConvertMapUnitsToPixels(pActiveView.Extent.Width)<BR> userRECT.bottom = ConvertMapUnitsToPixels(pActiveView.Extent.Height)<BR> <BR> Set pDriverBounds = New Envelope<BR> pDriverBounds.PutCoords userRECT.Left, _<BR> userRECT.bottom, _<BR> userRECT.Right, _<BR> userRECT.Top<BR> pActiveView.Output pPrinter.StartPrinting(pDriverBounds, 0), screenResolution, userRECT, pActiveView.Extent, Nothing<BR> pPrinter.FinishPrinting</P> <P><BR> Exit Sub<BR>ErrorHandler:<BR> HandleError False, "PrintToPrinter " ; c_ModuleFileName ; " " ; GetErrorLineNumberString(Erl), Err.Number, Err.Source, Err.Description, 1<BR>End Sub</P> <P>Private Sub SetupPrinter(oPrinter As Object, pPrinter As esriCore.IPrinter)<BR> On Error GoTo ErrorHandler</P> <P> Dim pPsPrinter As esriCore.IPsPrinter<BR> Dim pPaper As esriCore.IPaper<BR> Dim vbPrinter As Printer<BR> <BR> If (oPrinter Is Nothing) Then Exit Sub<BR> Set vbPrinter = oPrinter<BR> <BR> ' Build the Postscript printer object<BR> Set pPsPrinter = New PsPrinter<BR> Set pPrinter = pPsPrinter<BR> Set pPaper = New Paper<BR> <BR> pPaper.PrinterName = vbPrinter.DeviceName<BR> Set pPrinter.Paper = pPaper<BR> pPaper.Orientation = vbPrinter.Orientation</P> <P><BR> Exit Sub<BR>ErrorHandler:<BR> HandleError True, "SetupPrinter " ; c_ModuleFileName ; " " ; GetErrorLineNumberString(Erl), Err.Number, Err.Source, Err.Description, 1<BR>End Sub<BR></P> |
|
7楼#
发布于:2005-10-12 23:00
<P>楼上的高手</P>
<P>我用你的方法实现打印的话</P> <P>Mapcontrol上添加的文字标注好像不能一起打印出来啊?</P> <P>怎么办呢</P> |
|
8楼#
发布于:2007-11-06 14:54
好东西,学习了,借鉴一下,回去看能不能搞定
|
|
|
9楼#
发布于:2007-11-07 10:25
<P>怎么打印不了阿,楼主怎么解决的</P><img src="images/post/smile/dvbbs/em08.gif" />
|
|
|
上一页
下一页