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

Is there a way to make a paint brush "stamp" when you draw on a picturebox?

$
0
0
Hello everyone. I am working on a tool that lets me write on a picturebox, but it is focused on teaching math to students, and I am trying to integrate a "stamp" of sorts like you might see in some paint brush programs.

I can use the mouse to "draw" ink on the picturebox like this..

VB Code:
  1. Private Sub DrawPicture_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2.     PastePicture.Visible = False
  3.     PasteResize.Visible = False
  4.     If SelectionStart = True Then
  5.       PastePicture.Move XX, YY
  6.       mSetPicture_Click
  7.     End If
  8.     If cmdSelectTool.Value = False Then
  9.       If Button = vbKeyLButton Then
  10.         Drawing = True
  11.         drawpicture.DrawWidth = CInt(BrushSize.Text)
  12.         'drawpicture.DrawWidth = PenInkSizeLBL.Caption
  13.         drawpicture.ForeColor = BrushColor.BackColor
  14.         drawpicture.PSet (X, Y)
  15.       End If
  16.     Else
  17.       SelectPicture = True
  18.     End If
  19.     XX = X
  20.     YY = Y
  21.    
  22.     'If Button = vbKeyRButton Then PopupMenu mDrawMenu
  23.    
  24.   End Sub
  25.  
  26.  
  27.   Private Sub DrawPicture_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  28.   On Error Resume Next
  29.    
  30.     If Button = vbKeyLButton Then
  31.       If Drawing Then
  32.         drawpicture.PSet (X, Y)
  33.         drawpicture.Line (XX, YY)-(X, Y), BrushColor.BackColor
  34.         XX = X
  35.         YY = Y
  36.       End If
  37.  
  38.       If SelectPicture Then
  39.         With DrawSelection
  40.           .Visible = True
  41.           .Move XX, YY, (X - XX), (Y - YY)
  42.         End With
  43.       End If
  44.     End If
  45.   End Sub
  46.  
  47.  
  48.   Private Sub DrawPicture_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  49.     Drawing = False
  50.     SelectPicture = False
  51.     If XX = X Then If YY = Y Then Exit Sub
  52.     If cmdSelectTool.Value = True And SelectionStart = False Then
  53.      
  54.  
  55.      
  56.       PastePicture.Move DrawSelection.Left, DrawSelection.Top, DrawSelection.Width, DrawSelection.Height
  57.       PasteResize.Move DrawSelection.Left + DrawSelection.Width - PasteResize.Width, DrawSelection.Top + DrawSelection.Height - PasteResize.Height
  58.      
  59.       PastePicture.Visible = True
  60.       PasteResize.Visible = True
  61.       Picture1.Visible = False
  62.       Picture1.Left = DrawSelection.Left
  63.       Picture1.Top = DrawSelection.Top
  64.       Picture1.Width = DrawSelection.Width
  65.       Picture1.Height = DrawSelection.Height
  66.       Picture1.PaintPicture drawpicture.Image, 0, 0, DrawSelection.Width, DrawSelection.Height, DrawSelection.Left, DrawSelection.Top, DrawSelection.Width, DrawSelection.Height
  67.       Picture1.Picture = Picture1.Image
  68.       PastePicture.Picture = LoadPicture()
  69.       PastePicture.Stretch = True
  70.       DrawSelection.Visible = False
  71.       Picture1.Visible = False
  72.      
  73.       Set PastePicture.Picture = Picture1.Image
  74.      
  75.       Picture1.Picture = LoadPicture()
  76.       With PastePicture
  77.         drawpicture.PaintPicture Picture1.Image, .Left, .Top, .Width, .Height
  78.       End With
  79.       SelectionStart = True
  80.     Else
  81.     SelectionStart = False
  82.     End If
  83.   End Sub

But I would like to add clip art that the students are interested in. Perhaps from their favorite cartoons. That way I can use them for showing them how multiplication works. Is there a way that if I were to click on a command button, to have the mouse cursor when clicked on the picturebox, leave a copy of the "stamp". You know what I mean? Thanks!

Viewing all articles
Browse latest Browse all 21843

Trending Articles



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