阅读:2136回复:6
[求助]如何在标注中添加背景框
<P> 我现在可以显示标注了,但是我想实现这样的效果,据说在字的后面加个那种黄色的框,把字圈起来,该怎么做呀?</P>
|
|
1楼#
发布于:2006-07-22 19:46
<PRE>Private Sub TextLabel(ByVal LabelText As String, ByVal LabelPlacement As IPoint)
'dim and set new text element Dim pTextEl As ITextElement Set pTextEl = New TextElement 'check If pTextEl Is Nothing Then MsgBox "Text Element Object Not Set", , "Error - Text Label" Exit Sub End If 'set text element text pTextEl.Text = LabelText 'dim and set color object Dim pColor As IRgbColor Set pColor = Common.GetRGBColor(255, 255, 255) 'check If pColor Is Nothing Then MsgBox "RGB Color Object Not Set", , "Error - Text Label" Set pTextEl = Nothing Exit Sub End If 'dim and set balloon callout object Dim pBallCall As IBalloonCallout Set pBallCall = New BalloonCallout 'check If pBallCall Is Nothing Then MsgBox "Balloon Callout Object Not Set", , "Error - Text Label" Set pTextEl = Nothing Set pColor = Nothing Exit Sub End If 'dim and set fill symbol for callout element Dim pFill As IFillSymbol Set pFill = New SimpleFillSymbol 'check If pFill Is Nothing Then MsgBox "Fill Symbol Object Not Set", , "Error - Text Label" Set pTextEl = Nothing Set pBallCall = Nothing Set pColor = Nothing Exit Sub End If 'set fill color pFill.Color = pColor 'dim and set line symbol for 'callout outline Dim pLS As ILineSymbol Set pLS = New SimpleLineSymbol 'check If pLS Is Nothing Then MsgBox "Line Symbol Object Not Set", , "Error - Text Label" Set pTextEl = Nothing Set pBallCall = Nothing Set pColor = Nothing Set pFill = Nothing Exit Sub End If 'reset color object Set pColor = Nothing Set pColor = New RgbColor pColor.RGB = 0 'set outline color pLS.Color = pColor 'set fill symbol outline property to line symbol pFill.Outline = pLS 'set balloon callout object properties With pBallCall 'symbol property to fill symbol Set .Symbol = pFill 'set label anchor point .AnchorPoint = LabelPlacement 'leader tolerance to initially place 'label directly on anchor point .LeaderTolerance = 0 'callout style .Style = esriBCSRoundedRectangle End With 'now set properties to complete element 'dim and set text backgrount object Dim pTextBack As ITextBackground Set pTextBack = pBallCall 'check If pTextBack Is Nothing Then MsgBox "Text Background Object Not Set", , "Error - Text Label" Set pTextEl = Nothing Set pBallCall = Nothing Set pColor = Nothing Set pFill = Nothing Set pLS = Nothing Exit Sub End If 'dim and set formatted text symbol 'for specialized callout element Dim pLabelSymbol As IFormattedTextSymbol Set pLabelSymbol = New TextSymbol 'check If pLabelSymbol Is Nothing Then MsgBox "Formatted Text Symbol Object Not Set", , "Error - Text Label" Set pTextEl = Nothing Set pTextBack = Nothing Set pBallCall = Nothing Set pColor = Nothing Set pFill = Nothing Set pLS = Nothing Exit Sub End If 'set label symbol properties With pLabelSymbol Set .Background = pTextBack .Size = 10 End With 'set text element custom symbol pTextEl.Symbol = pLabelSymbol 'dim and set element properties object Dim pElemProp As IElementProperties Set pElemProp = pTextEl 'check If pElemProp Is Nothing Then MsgBox "Element Properties Object Not Set", , "Error - Text Label" Set pTextEl = Nothing Set pLabelSymbol = Nothing Set pTextBack = Nothing Set pBallCall = Nothing Set pColor = Nothing Set pFill = Nothing Set pLS = Nothing Exit Sub End If 'set element properties pElemProp.Type = "Jeffco Callout" 'add graphic to map AddBalloonElement pElemProp, LabelPlacement 'destroy variables Set pTextEl = Nothing Set pLabelSymbol = Nothing Set pTextBack = Nothing Set pBallCall = Nothing Set pColor = Nothing Set pFill = Nothing Set pLS = Nothing Set pElemProp = Nothing End Sub Public Sub AddBalloonElement(LabelElement As IElement, LabelPosition As IGeometry) Dim pMap As IMap Dim mGC As IGraphicsContainer Set pMap = Common.GetFocusMap Set mGC = pMap If TypeOf LabelPosition Is IEnvelope Then Dim pEnv As IEnvelope Set pEnv = LabelPosition LabelElement.Geometry = pEnv Else LabelElement.Geometry = LabelPosition End If mGC.AddElement LabelElement, 0 End Sub</PRE> |
|
|
2楼#
发布于:2006-07-24 08:40
<P>十分感谢楼上的 ,多谢了!!</P>
|
|
3楼#
发布于:2006-08-24 16:29
回复:(crx509)[求助]如何在标注中添加背景框
<P>怎么调用后啥都没显示?</P> |
|
4楼#
发布于:2006-08-24 17:59
<img src="images/post/smile/dvbbs/em03.gif" />
|
|
|
5楼#
发布于:2006-08-24 20:40
为什么老大都是用VB的呢
|
|
6楼#
发布于:2006-08-24 20:41
<P>有没有C#的 ???...........</P>
|
|