Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month15 days, 4 hours left to enroll

577 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