Results 1 to 7 of 7

Thread: insert picturebox into picturebox

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2009
    Posts
    2

    image into picture

    i was improve my knowledge about picturebox in vb 6,
    i just want to know can i

    inside an image into picturebox when i was
    klik the part in the picturebox, and the image will
    show in the spot i was klik in the picturebox

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: image into picture

    Moved to VB6. The FAQ forum isn't for asking questions.

  3. #3
    Hyperactive Member su ki's Avatar
    Join Date
    Oct 2007
    Posts
    354

    Re: image into picture

    hey randichan
    pls be more specific regarding asking questions

    what i understand from your post is u want to know where user has clicked in picturebox ??
    so just put picturebox on form from toolbox and put this code

    vb Code:
    1. Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    2. Debug.Print "X:" & X, "Y:" & Y
    3. End Sub

    this will show ur position in debug window

    it debug window is not shown then hit ctrl+g to visible it

    or else pls explain with more details
    * If my post helped you, please Rate it
    * If your problem is solved please also mark the thread resolved it is there in right top of page under thread tools
    * Why Rating is useful

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2009
    Posts
    2

    picturebox into picturebox

    Thanks for your reply, sorry about uncomplete question,
    i have a code from vb forum. The result of the code is when
    i was klik the place in the picture outer, the picture inner will
    show in the place i was klik. But in diagonal place,
    it wasnt in the right place i was klik

    picturebox1 name = PictOuter
    picturebox2 name = PictInner

    Dim pos As String
    Dim bos As String

    pos = Format(x / PictOuter.Width * 100, "0")
    bos = Format(y / PictOuter.Height * 100, "0")

    PictInner.left = PictOuter.Width * pos / 100
    PictInner.Top = PictOuter.Height * bos / 100
    PictInner.Visible = True

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: insert picturebox into picturebox

    I've got no idea why you are doing all of that work - you do a calculation, store the result to a formatted String (thus lose precision), and then undo the calculation.

    Why not assign the values directly? eg:
    Code:
    Private Sub picOuter_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
      picInner.Left = X
      picInner.Top = Y
    
    End Sub
    The X and Y parameters are in the scalemode of picOuter, and so are .Left and .Top of picInner (as it is inside picOuter), so this sets the top-left of picInner to wherever you click.

    If you want the centre of picInner to be where you click, just offset it by that amount, eg:
    Code:
    Private Sub picOuter_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
      picInner.Left = X - (picInner.Width / 2)
      picInner.Top = Y - (picInner.Height / 2)
    
    End Sub

  6. #6
    Frenzied Member
    Join Date
    Mar 2009
    Posts
    1,182

    Re: insert picturebox into picturebox

    >klik future reference "click"

    change both picture boxes scalemode to vbpixels in code or through properties. Use the mouse move event of the outer picture box to know where you are and and which mouse button is push and where. From there it should be easy to accomplish what you want.

    Good Luck
    Option Explicit should not be an Option!

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: insert picturebox into picturebox

    Duplicate threads merged - please post each question (or variation of it) only once.

Tags for this Thread

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