Drawing in a VB App

I am developing software for a small eye doctor's office.  Part of the eye exam component requires that the doctor draw (nothing extensive, a few lines or so) a picture of each eye.  I need to incorporate this functionality in the app...namely, there should be a templated bitmap that contains an outline of eye to which the doctor can add his or her graphical input via the mouse.

How would you implement this functionality?  (PS - The graphic must be saved to file so that it can be associated with this exam)
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.

dfhainesAuthor Commented:
Edited text of question.
Paste this in a module:

    Public Function CaptureWindow(ByVal hWndSrc As Long, _
    ByVal Client As Boolean, ByVal LeftSrc As Long, _
    ByVal TopSrc As Long, ByVal WidthSrc As Long, _
    ByVal HeightSrc As Long) As Picture

' CaptureControl      
'    - Captures the Image inside a Control
'    - Returns a Picture object containing a bitmap of the Control's Area

Public Function CaptureControl(Ctl As PictureBox) As Picture

    ' Call CaptureWindow to capture the client area of the form given
    ' its window handle and return the resulting Picture object.
    Set CaptureControl = CaptureWindow(Ctl.hWnd, True, 0, 0, _
    Ctl.ScaleX(Ctl.ScaleWidth, Ctl.ScaleMode, vbPixels), _
    Ctl.ScaleY(Ctl.ScaleHeight, Ctl.ScaleMode, vbPixels))

End Function

Place a picture box call Picsave with autoredraw property to true on a form. Add the eye picture to the picture by assigning it to the picture property.

Add the following declaration at the top of the form
bdrawflag = true

To draw the line, i assume you have your own method or you can simply assign the codes as below:

On the picSave_Mousedown property put :

bDrawflag = True
picSave.PSet (X, Y)

on picSave_Mousemove put:

if bdrawflag = true then

On picSave_Mouseup put:

bdrawflag = false

Then on the form again, add another picbox control named pictemp and assign the scalewidth and scaleheight to 1.
Add a command button to save the modified picture.

On the command1_click event, put:

filename = "C:\Temp.bmp"
Set pictemp.Picture = CaptureControl(picFace)
savepicture pictemp, filename


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
dfhainesAuthor Commented:

So far so good...though where is the body of the CaptureWindow function?

I appreciate your generosity.

The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

You really do not need to capture the window, just set a picture variable to the picturebox image:

'General Declarations
Private PicTmp As StdPicture

'Save event code
Set PicTmp = picSave.Image
SavePicture PicTmp, "c:\temp.bmp"
dfhainesAuthor Commented:
Thank you yjt and erick37...

Side note Erick37 - Before I received your comment, I did precisely that...though I noticed that the size of the bitmap increased from 7k to 160k with only minor additions.  I saved the initial bitmap template (which I use to prefill the pic control) as a monochrome bitmap.  I don't suppose VB has any way of specifying the type of bitmap?
I believe that the SavePicture method saves as uncompressed BMP.  You could probably find a third party library or picturebox control which would allow you to save as compressed BMP or JPEG.
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.