PDA

Click to See Complete Forum and Search --> : VB6 - PictureView usercontrol


Merri
Sep 24th, 2004, 02:05 PM
Sometimes you might to have a scrollable area where to show pictures. Well, here is a simple solution to that: add usercontrol to your project and you don't need to do any extra coding.

Features:
- center picture when no scrolling required
- move picture with the second mouse button
- can save in .JPG (thanks to JPEG Encoder Class (http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=50065&lngWId=1) by John Korejwa)
- customizable borderstyle
- customizable corner borderstyle (visible only when both scrollbars are visible)
- functions: ClearPicture, OpenPicture

Events:
- Click
- DblClick
- KeyDown
- KeyPress
- KeyUp
- MouseDown
- MouseMove
- MouseUp
- PictureLoaded


And here is the code with a simple sample project:

Merri
Sep 27th, 2004, 11:27 AM
Updated version. New features:
- NewPicture function, allows you to create new picture
- PictureDC function, returns the picture's hDC so you can use BitBlt or anything else directly from your app without editing the control
- PicturePaint sub, forces repaint of the control. Use this after painting.

Merri
Sep 27th, 2004, 05:08 PM
Yet another version, this time improved a lot: thanks to the new features, it is now possible to create a full Paint program!

You can this time find the code at PlanetSourceCode (http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=56382&lngWId=1) - you know I like votes, no matter to how old control they come :D