Results 1 to 8 of 8

Thread: [RESOLVED] Copying image

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Location
    England
    Posts
    283

    Resolved [RESOLVED] Copying image

    i wondered if it was possible to copy an image in code each time it was clicked on for example.

    eg, the user clicks on a picture of a face, the code copies the image and positions somewhere on the form (unimportant where).

    basically i need to be able to copy an image an infinite number of times if needed, so i can't just create another image and make it visible when the first image is clicked.

    Thanks for any reply

    GTJ

  2. #2
    Hyperactive Member Disiance's Avatar
    Join Date
    Sep 2004
    Location
    Denver, CO
    Posts
    439

    Re: Copying image

    Name a form "Form1" and set it's ScaleMode to Pixels (#3).

    Add a picture box, name it "Picture1".

    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    4. Private Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
    5.  
    6. Private Sub Picture1_Click()
    7.     Randomize Timer
    8.     Dim NewX As Long, NewY As Long
    9.     NewX = Int(Rnd * Form1.ScaleWidth)
    10.     NewY = Int(Rnd * Form1.ScaleHeight)
    11.     BitBlt Form1.hDC, NewX, NewY, Picture1.Width, Picture1.Height, Picture1.hDC, 0, 0, SRCCOPY
    12. End Sub
    "I don't want to live alone until I'm married" - M.M.R.P

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Location
    England
    Posts
    283

    Re: Copying image

    when i do this code i just get white lines in this shape:

    _/ (the slash is vertical in the program i just couldn't type a vertical line!)

    any help?

    cheers

    GTJ

  4. #4
    Hyperactive Member Disiance's Avatar
    Join Date
    Sep 2004
    Location
    Denver, CO
    Posts
    439

    Re: Copying image

    can you paste the full code you are using?
    "I don't want to live alone until I'm married" - M.M.R.P

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Location
    England
    Posts
    283

    Re: Copying image

    urrr, i just copied what you wrote in post #2

  6. #6
    Hyperactive Member Disiance's Avatar
    Join Date
    Sep 2004
    Location
    Denver, CO
    Posts
    439

    Re: Copying image

    Download the attatched project and see if that works for you.
    Attached Files Attached Files
    "I don't want to live alone until I'm married" - M.M.R.P

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Location
    England
    Posts
    283

    Re: Copying image

    do i set the position of the picture using the 'newx' and 'newy' variables?

  8. #8
    Hyperactive Member Disiance's Avatar
    Join Date
    Sep 2004
    Location
    Denver, CO
    Posts
    439

    Re: Copying image

    That is correct.
    "I don't want to live alone until I'm married" - M.M.R.P

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