Jun 14th, 2005, 08:16 PM
#1
Thread Starter
Hyperactive Member
Mousedown feature on a Pic Box added via controls.add? {RESOLVED}
Hello,
I have this code here to create a PictureBox when the user clicks a cmd button.
Here is the code:
VB Code:
Private Sub mnuPopCopy_Click()
Dim mobjPicture As PictureBox
If shpCrop.Visible = False Then Exit Sub
Set mobjPicture = Controls.Add("VB.PictureBox", "Pic")
With mobjPicture
.Width = intWidth
.Height = intHeight
.AutoSize = True
.AutoRedraw = True
.Visible = True
.Left = Picture1.Left
.Top = Picture1.Top
End With
mobjPicture.PaintPicture Picture1.Picture, 0, 0, , , intLeft, intTop
Clipboard.Clear
Clipboard.SetData mobjPicture.Image
Picture1.Visible = False
shpCrop.Visible = False
Set mobjPicture = Nothing
End Sub
Now what I need to do is get it so that once this picture box is loaded I want it to have this code.
VB Code:
Private Sub mobjPicture_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
MsgBox "YES!"
End Sub
However even with this code, when I click on the new pic box nothing happens.
Does anyone know how to fix that?
Thank you and have a great day!
Stilekid007
Last edited by stilekid007; Jun 15th, 2005 at 07:22 AM .
Jun 14th, 2005, 08:31 PM
#2
Re: Mousedown feature on a Pic Box added via controls.add?
Declare your object variable in form's general section (instead of locally) using WithEvents keyword:
VB Code:
Option Explicit
Dim WithEvents mobjPicture As PictureBox
Jun 14th, 2005, 09:02 PM
#3
Thread Starter
Hyperactive Member
Re: Mousedown feature on a Pic Box added via controls.add?
Hmm no go. That didn't work either. Nothing happens when I click on the newly created pic box.
Here is the project if you wanna have a look I will rate you!
Thank you so much!
Stilekid007
Attached Files
Jun 14th, 2005, 10:24 PM
#4
Jun 14th, 2005, 11:51 PM
#5
Re: Mousedown feature on a Pic Box added via controls.add?
Well, the project did not work for me. The reason, you set the mobjPicture variable to nothing in the mnuPopCopy_Click event. Remove that line of code.
Jun 15th, 2005, 07:20 AM
#6
Thread Starter
Hyperactive Member
Re: Mousedown feature on a Pic Box added via controls.add?
aaHaaa! Brilliant bruceVB!!!! Your great thank you so much!
Thank you all for your responses and help!
Stilekid007
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width