Results 1 to 6 of 6

Thread: Mousedown feature on a Pic Box added via controls.add? {RESOLVED}

  1. #1

    Thread Starter
    Hyperactive Member stilekid007's Avatar
    Join Date
    Apr 2005
    Location
    DUDE! I'm your neighbor! HELLO!!!
    Posts
    388

    Resolved 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:
    1. Private Sub mnuPopCopy_Click()
    2.    
    3.     Dim mobjPicture As PictureBox
    4.     If shpCrop.Visible = False Then Exit Sub
    5.    
    6.     Set mobjPicture = Controls.Add("VB.PictureBox", "Pic")
    7.  
    8.     With mobjPicture
    9.         .Width = intWidth
    10.         .Height = intHeight
    11.         .AutoSize = True
    12.         .AutoRedraw = True
    13.         .Visible = True
    14.         .Left = Picture1.Left
    15.         .Top = Picture1.Top
    16.     End With
    17.    
    18.     mobjPicture.PaintPicture Picture1.Picture, 0, 0, , , intLeft, intTop
    19.    
    20.     Clipboard.Clear
    21.     Clipboard.SetData mobjPicture.Image
    22.  
    23.     Picture1.Visible = False
    24.  
    25.     shpCrop.Visible = False
    26.     Set mobjPicture = Nothing
    27.    
    28.    
    29. 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:
    1. Private Sub mobjPicture_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    2. MsgBox "YES!"
    3. 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.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    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:
    1. Option Explicit
    2.  
    3. Dim WithEvents mobjPicture As PictureBox

  3. #3

    Thread Starter
    Hyperactive Member stilekid007's Avatar
    Join Date
    Apr 2005
    Location
    DUDE! I'm your neighbor! HELLO!!!
    Posts
    388

    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 Attached Files

  4. #4
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Mousedown feature on a Pic Box added via controls.add?

    Well the project works for me just the way it is


    Has someone helped you? Then you can Rate their helpful post.

  5. #5
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    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.

  6. #6

    Thread Starter
    Hyperactive Member stilekid007's Avatar
    Join Date
    Apr 2005
    Location
    DUDE! I'm your neighbor! HELLO!!!
    Posts
    388

    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
  •  



Click Here to Expand Forum to Full Width