Private Sub UserControl_Resize()
UserControl.Width = UserControl.ScaleX(32, vbPixels, _
vbTwips)
UserControl.Height = UserControl.ScaleY(32, vbPixels, _
vbTwips)
End Sub
|
Public Event LineSelected(ByVal x0 As Single, ByVal y0 As _
Single, ByVal x1 As Single, ByVal y1 As Single)
' Start rubberband drawing.
Private Sub m_Canvas_MouseDown(Button As Integer, Shift As _
Integer, X As Single, Y As Single)
If Button <> vbLeftButton Then Exit Sub
m_Drawing = True
m_X0 = X
m_Y0 = Y
m_X1 = X
m_Y1 = Y
m_DrawMode = m_Canvas.DrawMode
m_Canvas.DrawMode = vbInvert
m_Canvas.Line (m_X0, m_Y0)-(m_X1, m_Y1)
End Sub
' Continue drawing.
Private Sub m_Canvas_MouseMove(Button As Integer, Shift As _
Integer, X As Single, Y As Single)
If Not m_Drawing Then Exit Sub
m_Canvas.Line (m_X0, m_Y0)-(m_X1, m_Y1)
m_X1 = X
m_Y1 = Y
m_Canvas.Line (m_X0, m_Y0)-(m_X1, m_Y1)
End Sub
' Finish drawing.
Private Sub m_Canvas_MouseUp(Button As Integer, Shift As _
Integer, X As Single, Y As Single)
If Not m_Drawing Then Exit Sub
m_Drawing = False
m_Canvas.Line (m_X0, m_Y0)-(m_X1, m_Y1)
m_Canvas.DrawMode = m_DrawMode
RaiseEvent LineSelected(m_X0, m_Y0, m_X1, m_Y1)
End Sub
|