用MO时如何自定义填充样式? (50分)

T

tanyg

Unregistered / Unconfirmed
GUEST, unregistred user!
我用DELPHI+MO开发GIS
但是许多区域的填充样式是自定义的,不知如何自己定义填充样式?
望各位大虾赐教,最好能有完整的源代码。
谢了!!
 
各位大虾,快救救我吧!!
 
我也遇到同样的问题,不过,我不知道MO时什么,仅仅在DELPHI中,我涌了一个比较锉的解决方案,
说出来,讨论一下:
填充样式采用静态底图,定义号填充区域和填充颜色,使用一个PANEL,和填充区域一样大小,
在PANEL上放置同样大小的静态图,但是在填充区域采用填充颜色,
改变PANEL 的高度或者宽度,就有填充效果。不太好,权宜之计,水有好的想法或者控件,
帮忙


 
用TBrush.Bitmap去扩充吧。
 
楼上的,能不能详细一点。
 
我说的是在Delphi中扩充Brush的方法。
var
BMP : TBitmap;
begin

BMP := TBitmap.Create;
BMP.Width := 20;
BMP.Height := 20;
BMP.Ellipse(5,5,15,15);
Canvas.Brush.Bitmap := BMP;
Canvas.Ellipse(10,10,200,200);
BMP.Free;
end;

MO中可能不能吧,我没有MO,不能帮你实验。
也许在ArcView或ArcInfo中作好了扩充可以加到MO中去。
 
我也想过用位图来填充,但如果这样,我一个区域中如果只想填充一个如何做,
也就是说如果要填充的区域比位图大将由若干个位图来填充,但我不管区域多大
都只用一个位图来填充,该如何做?
 
你不用担心,系统会自动给你平铺。
 
对不起,请问一下你们所说的MO是指什么?
 
MapObject,ESRI的专业地理信息系统ActiveX控件。
 
to 吕雪松:
我就是不想让系统自动平铺。
————————————
| |
| |
| # |
| |
|———————————
就象上面一样,矩形是一个区域,“#”是填充的位图,但“#”不能平铺,也就是说
区域中只能有一个“#”。该如何做?
谢谢!!!
 
另:MO中的HELP中有自定义线型和填充类型的例子,可惜是VB的,我看不懂,
麻烦哪位大虾翻译一下。谢谢!!!
 
贴出VB的例子才可以翻译嘛
 
一共有三种:
1.用位图当SYMBOL
2.自定义线型
3.自定义填充类型

1.
Point symbol example using a Bitmap

Here is an example of some code for a custom point symbol server, using a Bitmap to render each Point feature:

Option Explicit

'Indicate that this class will implement ICustomMarker
'Remember that you must first browse for the type library
Implements AFCustom.ICustomMarker

'Internal data members
Private m_filename As String
Private m_dpi Asdo
uble
Private m_picture As IPicture

'External method which allows users to specify the
'image path and name to be rendered.
Public Sub SetFileName(fn As String)
m_filename = fn
End Sub

'The draw method. This method is called for each symbol.

Private Sub ICustomMarker_Draw(ByVal hDC As Long, ByVal x As Long, ByVal y As Long)
Dim pixWidth Asdo
uble, pixHeight Asdo
uble

'Convert the picture width (normally in HI_METRIC) to pixels
'using the previously stored dpi member.
pixWidth = m_picture.Width * m_dpi / 2540
pixHeight = m_picture.Height * m_dpi / 2540

'Always check for a valid interface before using it.
If Not m_picture Is Nothing then

'Render the picture, centered on the given point.

m_picture.Render hDC, x - pixWidth / 2, y + pixWidth / 2, pixWidth, -pixHeight, _
0, 0, m_picture.Width, m_picture.Height, Null
End If

End Sub

'This method is called once per refresh, at the completion of rendering.
Private Sub ICustomMarker_ResetDC(ByVal hDC As Long)
'Set the picture object to nothing, free all resources.
Set m_picture = Nothing
End Sub

'This method is called once per refresh, prior to rendering.
Private Sub ICustomMarker_SetupDC(ByVal hDC As Long, ByVal dpi Asdo
uble, ByVal pBaseSym As Object)

'Store thedo
ts per inch.
m_dpi = dpi

'Try to load the specified picture.
Set m_picture = LoadPicture(m_filename)
End Sub


To use this custom symbol in a Visual Basic project, you may write code like this:

Private Sub Form_Load()

Dim bmpSym As New MyCustomSymbol.CustomBitmapMarker

'Use the SetFileName property to set the location of the
'image to use as the symbol
bmpSym.SetFileName "C:/MyImages/MyMapSymbol.gif"
Set Map1.Layers(0).Symbol.Custom = bmpSym

End Sub


2.
Line symbol example

Here is an example of some code for a custom line symbol server:

Option Explicit
Implements AFCustom.ICustomLine

Dim g_hOldPen As Long
Dim g_hPen As Long

Private Declare Function Polyline Lib "gdi32" (ByVal hDC As Long, lppt As Long, ByVal cCount As Long) As Long
Private Declare Function PolyPolyline Lib "gdi32" (ByVal hDC As Long, lppt As Long, lpdwPolyPoints As Long, ByVal cCount As Long) As Long
Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal hObject As Long) As Long

Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long

Private Declare Function GetLastError Lib "kernel32" () As Long

Public Sub ICustomLine_Draw(ByVal hDC As Long, points As Long, partCounts As Long, ByVal numParts As Long)
PolyPolyline hDC, points, partCounts, numParts
End Sub

Public Sub ICustomLine_ResetDC(ByVal hDC As Long)
' clean up pen
If Not g_hPen = 0 then

SelectObject hDC, g_hOldPen
DeleteObject g_hPen

End If
End Sub

Public Sub ICustomLine_SetupDC(ByVal hDC As Long, ByVal dpi Asdo
uble, ByVal pBaseSym As Object)
' Set pen attributes to match base symbol
g_hPen = CreatePen(pBaseSym.Style, pBaseSym.Size, pBaseSym.Color)
g_hOldPen = SelectObject(hDC, g_hPen)
End Sub



3.
Fill symbol example

Here is an example of some code for a custom fill symbol server:

Option Explicit
Implements AFCustom.IcustomFill

Dim g_hOldPen As Long
Dim g_hPen As Long
Dim g_hOldBrush As Long
Dim g_hBrush As Long

Private Declare Function PolyPolygon Lib "gdi32" (ByVal hDC As Long, lppt As Long, lpdwPolyPoints As Long, ByVal cCount As Long) As Long
Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long

Private Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long

Private Declare Function GetLastError Lib "kernel32" () As Long

Public Sub ICustomFill_Draw(ByVal hDC As Long, points As Long, partCounts As Long, ByVal numParts As Long)
PolyPolygon hDC, points, partCounts, numParts
End Sub

Public Sub ICustomFill_ResetDC(ByVal hDC As Long)
' clean up pen

If Not g_hPen = 0 then

SelectObject hDC, g_hOldPen
DeleteObject g_hPen
End If
If Not g_hBrush = 0 then

SelectObject hDC, g_hOldBrush
DeleteObject g_hBrush
End If
End Sub

Public Sub ICustomFill_SetupDC(ByVal hDC As Long, ByVal dpi Asdo
uble, ByVal pBaseSym As Object)
' Set pen attributes to match base symbol
g_hPen = CreatePen(pBaseSym.Style, pBaseSym.Size, pBaseSym.OutlineColor)
g_hOldPen = SelectObject(hDC, g_hPen)
g_hBrush = CreateSolidBrush(pBaseSym.Color)

g_hOldBrush = SelectObject(hDC, g_hBrush)
End Sub
 
大侠们,帮帮忙,翻译一下吗?
 
各位大侠,板主们,难道嫌票子少吗?
回答完了定加上几百大洋!!!
 
tanyg:

请查看你的信箱。你会满意的。呵呵
 
可以告诉我怎么解决的么?
或者直接解答该问题!
http://www.delphibbs.com/delphibbs/dispq.asp?lid=521344

谢谢!
 
to :黑天鹅
我照你的方法做了,可是程序过不去,说是出现无效类别字符串。
望赐教!!!
 
顶部