Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21103

Clicking on anywhere in a picturebox and move it around the form

$
0
0
Hi there everyone.

I am working on a student attendance prog. When they come in, they see a picturebox with their name on it called Container1, and move it to a certain spot on the board, and it will sign them in.

The problem is, each picturebox has a label caption such as StudentNameLBL1, a background picture called studentimg1, and a small avatar called Avatar1.

In an old version, they just clicked on the label caption, because it was just their name, using this code.

VB Code:
  1. Private Sub StudentNameLBL1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  2.    
  3.    
  4.     If Button = vbLeftButton Then
  5.         Xx = x
  6.         yy = y
  7.         Container1.MousePointer = vbSizeAll
  8.     End If
  9. End Sub
  10.  
  11. Private Sub StudentNameLBL1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
  12.     If Button = vbLeftButton Then
  13.         With Container1
  14.             .Left = .Left - (Xx - x)
  15.             .Top = .Top - (yy - y)
  16.         End With
  17.     End If
  18. End Sub
  19.  
  20. Private Sub StudentNameLBL1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
  21. With Container1
  22.     Container1.MousePointer = vbDefault
  23.     If Val(StudentNum.Text) <= 19 Then
  24.                  If (.Top > 3000 And .Top < 6240) And (.Left > 3370 And .Left < 7200) Then
  25.                     If AttendanceV3.LanguageTXT.Text = "EN" Then
  26.                      Message2.Show
  27.                      Message2.StudentChosenTXT.Text = "1"
  28.                      StudentChosenTXT.Text = "1"
  29.                      StudentNameTXT.Text = StudentNameLBL1.Caption
  30.                     Call WhenStudentSignsInEN
  31.                     Container1.Visible = False
  32.                    
  33.                     End If
  34.                    
  35.                      If AttendanceV3.LanguageTXT.Text = "FR" Then
  36.                      MessageFR.Show
  37.                      MessageFR.StudentChosenTXT.Text = "1"
  38.                      StudentChosenTXT.Text = "1"
  39.                      StudentNameTXT.Text = StudentNameLBL1.Caption
  40.                     Call WhenStudentSignsInFR
  41.                     Container1.Visible = False
  42.                     End If
  43.                    
  44.                  End If
  45.     End If
  46.    
  47.         If Val(StudentNum.Text) >= 20 Then
  48.                  If (.Top > 3000 And .Top < 6240) And (.Left > 4560 And .Left < 8280) Then
  49.                     If AttendanceV3.LanguageTXT.Text = "EN" Then
  50.                      Message2.Show
  51.                      Message2.StudentChosenTXT.Text = "1"
  52.                      StudentChosenTXT.Text = "1"
  53.                      StudentNameTXT.Text = StudentNameLBL1.Caption
  54.                     Call WhenStudentSignsInEN
  55.                     Container1.Visible = False
  56.                    
  57.                     End If
  58.                    
  59.                      If AttendanceV3.LanguageTXT.Text = "FR" Then
  60.                      MessageFR.Show
  61.                      MessageFR.StudentChosenTXT.Text = "1"
  62.                      StudentChosenTXT.Text = "1"
  63.                      StudentNameTXT.Text = StudentNameLBL1.Caption
  64.                     Call WhenStudentSignsInFR
  65.                     Container1.Visible = False
  66.                     End If
  67.                    
  68.                  End If
  69.     End If
  70.  End With
  71. End Sub

But that would only let them move the new sign in box as long as they click on the label, is there a way that if they click anywhere on the picturebox, which is called Container1, it would be the same as clicking on the image inside the box called studentimg1, the avatar, called Avatar1, or the label caption called StudentNameLBL1??

Thanks!!!

Viewing all articles
Browse latest Browse all 21103

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>