Selecting a part of a form

Posted on 2003-03-09
Medium Priority
Last Modified: 2010-05-01
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
Question by:ashtray
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

phildaley earned 1000 total points
ID: 8099472
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

Expert Comment

ID: 8900442
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?
LVL 49

Expert Comment

ID: 9074536
Moderator, my recommended disposition is:

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

DanRollins -- EE database cleanup volunteer

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month12 days, 13 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question