Public Class Form1
Private _zkouska1 As New Bitmap("C:\Users\w\Desktop\zkouska1.gif")
Private _zkouska2 As New Bitmap("C:\Users\w\Desktop\zkouska2.gif")
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
e.Graphics.DrawImageUnscaled(New Bitmap(_zkouska1), 0, 0)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MyNewSub()
End Sub
Sub MyNewSub()
BackColor = Color.Red
TransparencyKey = BackColor
End Sub
Private Sub Example_ControlAdded(ByVal sender As Object, ByVal e As System.Windows.Forms.ControlEventArgs) Handles Me.ControlAdded
AddHandler e.Control.MouseClick, AddressOf Example_MouseClick
End Sub
Private Sub Example_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
If True Then e.Graphics.DrawImageUnscaled(New Bitmap(_zkouska2), 0, 0) = True
End Sub
End Class
答案 0 :(得分:0)
您没有具体说明导致问题的是哪条线,但是这一行存在问题:
If True Then e.Graphics.DrawImageUnscaled(New Bitmap(_zkouska2), 0, 0) = True
是MouseEventArgs没有Graphics成员。也许这里要做的是使用Mouse_Clicked事件来设置一个变量来跟踪鼠标是否被点击(以及在哪里),并使用Paint事件来进行实际绘图。
所以你要在类中添加一个布尔变量:
Private _clicked As Boolean
将MouseClicked事件更改为以下内容:
Private Sub Example_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
_clicked = True
End Sub
添加一个Paint事件并使该事件发生如下:
Private Sub Form1_Paint(sender As System.Object, e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
If _clicked Then
e.Graphics.DrawImageUnscaled(New Bitmap(_zkouska2), 0, 0)
End If
End Sub