[英]VB.NET PictureBox / Controls
So interesting dilemma, I've managed to make a label completely invisible, to where I can use it for a click event on certain parts of a picture. 如此有趣的困境,我设法使标签完全不可见,可以将其用于图片某些部分的单击事件。
I then use that click event to call another picturebox into focus using picturebox3.visible = true.. 然后,我使用该click事件使用picturebox3.visible = true调用另一个Picturebox使其成为焦点。
The issue I'm having is when it's calling that picturebox visibility..the controls from the new picturebox (Invisible labels) seem to not function or be missing from the picture in picturebox2 completely. 我遇到的问题是调用图片框可见性时..新图片框(不可见标签)中的控件似乎不起作用或完全不存在于picturebox2中的图片中。
I need to do this with about 30 different pictures in order to create a kind of "emulator" project for someone. 我需要用大约30张不同的图片来完成此操作,以便为某人创建一种“模拟器”项目。
Any ideas on this? 有什么想法吗? I can post code if needed. 如果需要,我可以发布代码。 Picturebox + controls on picturebox = headache. Picturebox + PictureBox上的控件=头痛。
Public Class InvisibleLabel
Inherits Label
Public Sub New()
Me.SetStyle(ControlStyles.Opaque, True)
Me.SetStyle(ControlStyles.OptimizedDoubleBuffer, False)
End Sub
Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
Get
Dim CC As CreateParams = MyBase.CreateParams
CC.ExStyle = CC.ExStyle Or &H20
Return CC
End Get
End Property
End Class 末级
This is the code for the invisible label, then I'm just using picturebox2.visible = true when certain parts of a picture are clicked. 这是不可见标签的代码,然后单击图片的某些部分时,我只是使用picturebox2.visible = true。
Use: 采用:
Private Sub PictureBox_MouseDown(sender As Object, e As MouseEventArgs) _
Handles PictureBox.MouseDown
'The code to change the picture goes here
End Sub
I made 3 textboxes 我做了3个文本框
textbox1 for X 'just for you to see X的textbox1,仅供您查看
textbox2 for Y 'just for you to see 用于Y的textbox2,仅供您查看
and 和
CurPicture to compare current image CurPicture比较当前图像
my picturebox is 300,300 我的画框是300,300
Private Sub PictureBox1_MouseClick(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseClick 私有子PictureBox1_MouseClick(作为对象发送,作为MouseEventArgs发送)处理PictureBox1.MouseClick
Dim LocX As Integer = e.X
Dim LocY As Integer = e.Y
TextBox1.Text = e.X.ToString
TextBox2.Text = e.Y.ToString
If LocX > 200 Then ' click right side op the picture , change LocX With LocY to make it bottom
If CurPicture.Text = "1" Then
PictureBox1.Image = My.Resources.Pic2
CurPicture.Text = "2"
ElseIf CurPicture.Text = "2" Then
PictureBox1.Image = My.Resources.Pic3
CurPicture.Text = "3"
ElseIf CurPicture.Text = "3" Then
PictureBox1.Image = My.Resources.Pic4
CurPicture.Text = "4"
ElseIf CurPicture.Text = "4" Then
PictureBox1.Image = My.Resources.Pic5
CurPicture.Text = "5"
ElseIf CurPicture.Text = "5" Then
PictureBox1.Image = My.Resources.Pic1
CurPicture.Text = "1"
End If
End If
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
PictureBox1.Image = My.Resources.Pic1
CurPicture.Text = "1"
End Sub
Hope this will help you get on the way :) 希望这可以帮助您:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.