We have already talked about the User-Defined symbol method in VC. Here we will talk about another application of user-defined symbols in VB, that is, displaying the vertex as a pool, as shown in
Otherwise, paste the Code directly:
Option explicit
Implements afcustom. icustommarker
'Data members
Private m_pen as long
Private m_oldpen as long
Private m_size as long
Private m_style as wsnodestyle
'Win32 API functions
Private declare function SelectObject lib "GDI32" (byval HDC as long, byval hobject 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 deleteobject lib "GDI32" (byval hobject as long) as long
Private declare function lineto lib "GDI32" (byval HDC as long, byval X as long, byval y as long) as long
Private declare function movetoex lib "GDI32" (byval HDC as long, byval X as long, byval y as long, lppoint as long) as long
Private declare function ellipse lib "GDI32" (byval HDC as long, byval X1 as long, byval Y1 as long, byval X2 as long, byval Y2 as long) as long
Private sub class_initialize ()
M_style = wswatertanknode
End sub
Public property let symbolstyle (byval vdata as wsnodestyle)
M_style = vdata
End Property
Public property get symbolstyle () as wsnodestyle
Symbolstyle = m_style
End Property
Public sub icustommarker_draw (byval HDC as long, byval X as long, byval y as long)
Select case m_style
Case wswatertanknode 'pool
Movetoex HDC, X-m_size, Y-m_size, 0
Lineto HDC, X-m_size, y
Lineto HDC, x + m_size, y
Lineto HDC, x + m_size, Y-m_size
Movetoex HDC, X-m_size, INT (Y-m_size * 2/5), 0
Lineto HDC, x + m_size, INT (Y-m_size * 2/5)
Case else
Ellipse HDC, X-m_size, Y-m_size, x + m_size, Y + m_size
End select
End sub
Public sub icustommarker_resetdc (byval HDC as long)
SelectObject HDC, m_oldpen
Deleteobject m_pen
End sub
Public sub icustommarker_setupdc (byval HDC as long, byval DPI as double, byval pbasesym as object)
M_pen = createpen (0, 1, pbasesym. color)
M_oldpen = SelectObject (HDC, m_pen)
M_size = pbasesym. Size
End sub