Shape.MouseMove 이벤트
셰이프 위에 마우스 포인터를 이동할 때 발생 합니다.
네임스페이스: Microsoft.VisualBasic.PowerPacks
어셈블리: Microsoft.VisualBasic.PowerPacks.Vs(Microsoft.VisualBasic.PowerPacks.Vs.dll)
구문
‘선언
<BrowsableAttribute(True)> _
Public Event MouseMove As MouseEventHandler
[BrowsableAttribute(true)]
public event MouseEventHandler MouseMove
[BrowsableAttribute(true)]
public:
event MouseEventHandler^ MouseMove {
void add (MouseEventHandler^ value);
void remove (MouseEventHandler^ value);
}
[<BrowsableAttribute(true)>]
member MouseMove : IEvent<MouseEventHandler,
MouseEventArgs>
JScript에서는 이벤트를 지원하지 않습니다.
설명
마우스 이벤트는 다음 순서대로 발생합니다.
MouseMove
MouseHover / MouseDown / MouseWheel
이벤트를 처리하는 방법에 대한 자세한 내용은 이벤트 사용을 참조하십시오.
예제
다음 예제에서는 사용 하는 방법을 보여 줍니다 있는 MouseDown, MouseMove, 및 MouseUp 선을 그릴 이벤트는 RectangleShape 컨트롤.이 예제에서는 사용자가 있어야는 RectangleShape 폼에 RectangleShape1 이라는 컨트롤입니다.
Private mousePath = New System.Drawing.Drawing2D.GraphicsPath()
Private Sub RectangleShape2_MouseDown(
ByVal sender As Object,
ByVal e As System.Windows.Forms.MouseEventArgs
) Handles RectangleShape2.MouseDown
Dim mouseDownLocation As New Point(e.X + RectangleShape2.Left,
e.Y + RectangleShape2.Top)
' Clear the previous line.
mousePath.Dispose()
mousePath = New System.Drawing.Drawing2D.GraphicsPath()
RectangleShape2.Invalidate()
' Add a line to the graphics path.
mousePath.AddLine(mouseDownLocation, mouseDownLocation)
End Sub
Private Sub RectangleShape2_MouseMove(
ByVal sender As Object,
ByVal e As System.Windows.Forms.MouseEventArgs
) Handles RectangleShape2.MouseMove
Dim mouseX As Integer = e.X + RectangleShape2.Left
Dim mouseY As Integer = e.Y + RectangleShape2.Top
' Add a line to the graphics path.
mousePath.AddLine(mouseX, mouseY, mouseX, mouseY)
End Sub
Private Sub RectangleShape2_MouseUp(
ByVal sender As Object,
ByVal e As System.Windows.Forms.MouseEventArgs
) Handles RectangleShape2.MouseUp
Dim mouseUpLocation = New System.Drawing.Point(e.X +
RectangleShape2.Left, e.Y + RectangleShape2.Top)
' Add a line to the graphics path.
mousePath.Addline(mouseUpLocation, mouseUpLocation)
' Force the shape to redraw.
RectangleShape2.Invalidate()
End Sub
Private Sub RectangleShape2_Paint(
ByVal sender As Object,
ByVal e As System.Windows.Forms.PaintEventArgs
) Handles RectangleShape2.Paint
' Draw the line.
e.Graphics.DrawPath(System.Drawing.Pens.DarkRed, mousePath)
End Sub
private System.Drawing.Drawing2D.GraphicsPath mousePath =
new System.Drawing.Drawing2D.GraphicsPath();
private void rectangleShape2_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
Point mouseDownLocation = new Point(e.X + rectangleShape2.Left,
e.Y + rectangleShape2.Top);
// Clear the previous line.
mousePath.Dispose();
mousePath = new System.Drawing.Drawing2D.GraphicsPath();
rectangleShape2.Invalidate();
// Add a line to the graphics path.
mousePath.AddLine(mouseDownLocation, mouseDownLocation);
}
private void rectangleShape2_MouseMove(object sender,
System.Windows.Forms.MouseEventArgs e)
{
int mouseX = e.X + rectangleShape2.Left;
int mouseY = e.Y + rectangleShape2.Top;
// Add a line to the graphics path.
mousePath.AddLine(mouseX, mouseY, mouseX, mouseY);
}
private void rectangleShape2_MouseUp(object sender,
System.Windows.Forms.MouseEventArgs e)
{
System.Drawing.Point mouseUpLocation =
new System.Drawing.Point(e.X + rectangleShape2.Left,
e.Y + rectangleShape2.Top);
// Add a line to the graphics path.
mousePath.AddLine(mouseUpLocation, mouseUpLocation);
// Force the shape to redraw.
rectangleShape2.Invalidate();
}
private void rectangleShape2_Paint(object sender,
System.Windows.Forms.PaintEventArgs e)
{
// Draw the line.
e.Graphics.DrawPath(System.Drawing.Pens.DarkRed, mousePath);
}
.NET Framework 보안
- 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.
참고 항목
참조
Microsoft.VisualBasic.PowerPacks 네임스페이스
기타 리소스
방법: LineShape 컨트롤로 선 그리기(Visual Studio)
방법: OvalShape 및 RectangleShape 컨트롤을 사용하여 도형 그리기(Visual Studio)