问题描述
你好, 班级 Hello, Class Window1 Window1 昏暗 Pt0 如 点 Dim Pt0 As Point 昏暗 Pt1 如 点 Dim Pt1 As Point 昏暗 Pt2 如 点 Dim Pt2 As Point 昏暗 Pt3 如 点 Dim Pt3 As Point 昏暗 矩形 如 新建 多边形 Dim Rectangle As New Polygon 私有 子 Btn_MouseMove( ByVal 发送者 As 对象 , ByVal e As System.Windows.Input.MouseEventArgs) 手柄 Btn.MouseMove Private Sub Btn_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Input.MouseEventArgs) Handles Btn.MouseMove 我 .Title = e.GetPosition(Btn).X& " ," & e.GetPosition(Btn).Y Me.Title = e.GetPosition(Btn).X & " , " & e.GetPosition(Btn).Y 结束 子 End Sub 私有 子 Btn_SizeChanged( ByVal 发送者 As 对象 , ByVal e As System.Windows.SizeChangedEventArgs) 手柄 Btn.SizeChanged Pt0 = Private Sub Btn_SizeChanged(ByVal sender As Object, ByVal e As System.Windows.SizeChangedEventArgs) Handles Btn.SizeChanged Pt0 = 新 点(20,20) Pt1 = New Point(20, 20) Pt1 = 新 点(180,20) Pt2 = New Point(180, 20) Pt2 = 新 点(180,180) Pt3 = New Point(180, 180) Pt3 = 新 点(20,180) Rectangle.Points.Add(Pt0) New Point(20, 180) Rectangle.Points.Add(Pt0) Rectangle.Points.Add(Pt1) Rectangle.Points.Add(Pt1) Rectangle.Points.Add(Pt2) Rectangle.Points.Add(Pt2) Rectangle.Points.Add(Pt3) Rectangle.Points.Add(Pt3) Rectangle.Stroke =刷子.黑色 Rectangle.Stroke = Brushes.Black Btn.Content =矩形 Btn.Content = Rectangle 结束 子 结束 End Sub End 类 Class 这篇关于在按钮上绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
我正在尝试在按钮上绘制一个矩形.我将按钮的宽度"和高度"设置为200.
请尝试我的代码,并告诉我为什么将鼠标置于我设置的点(20,20)时实际上显示为(30,30)
这是代码:
I am trying to draw a rectangle on a button. I set the Width and Height of the button to be 200.
Please try my code and tell me why when you put the mouse on the point that I set (20,20) it is actually (30,30) shown on the Window title.
Here is the code :推荐答案