Selecting a part of a form

Hello All,

l have a form in VB5 with a bitmap image attached to its .picture and want to be able to select a given  area of the picture in the form and copy it to the System Clipboard, using the Mouse, can l
grab any area on the forms picture and save the co-ordinates.

hope you undestand what lm wanting to achieve here

regards Ashtray
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Example code below (assumes a form (Form1) and a PictureBox (Picture1)). Picture1 must have AutoRedraw property set True.
You'll want to add in some error traps to make sure MouseUp coords are higher than MouseDown coords, but you'll get the idea.

Dim msngStartX As Single
Dim msngStartY As Single

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    msngStartX = X
    msngStartY = Y
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim sngHeight As Single
    Dim sngWidth As Single
    sngWidth = X - msngStartX
    sngHeight = Y - msngStartY
    Picture1.Width = sngWidth
    Picture1.Height = sngHeight
    Picture1.PaintPicture Form1.Picture, 0, 0, sngWidth, sngHeight, msngStartX, msngStartY, sngWidth, sngHeight
    Clipboard.SetData Picture1.Image, vbCFDIB
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
Moderator, my recommended disposition is:

    Accept phildaley's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.