Home » Category » Microsoft Visual Basic

Microsoft Visual Basic: zoom using mouse selection

202| Sat, 09 Feb 2008 18:12:00 GMT| marcosav| Comments (4)
Hi everybody...

how can I select a part of image (using mouse), and aplicate a zoom only on the selection ?

(example) I have a Picturebox (can be changed by a Image control) with a large picture, but I need to see some details, in any part of the picture (image), so I would select that details (dragging the mouse) and the selected area would receive a zoom...

Is it possible ?? If yes, how ??
I have tried to mark the initial position (X and Y on Mousedown) and the final position on MouseUp, but it not works !!!

Any idea ?

Thanks in advance...

Marcos.

Keywords & Tags: zoom, mouse, selection, microsoft, visual basic, vb

URL: http://www.programmerbase.com/visual-basic/560776/
 
«« Prev - Next »» 4 helpful answers below.
Which part of this are you having trouble with, receiving your co-ordinates, or zooming the image? You should be able to get your co-ords from the mousedown and mouseup events. The code for zooming would be in your mouseup event if the start co-ords do not equal your end co-ords.

chris256 | Fri, 09 Nov 2007 20:17:00 GMT |

Hello, Chris256...

In true, I'm having difficulty getting the initial and final position, and store in a variable, to compare the both (help)...
About zooming image, the % of zooming is pre defined in 35% (into the code). With a sigle click on the image, this one must back to its normal state...

Do you have some example code you can show me ??

I would very thanks !!!

Marcos.

marcosav | Fri, 09 Nov 2007 20:18:00 GMT |

Globals at the top:

Dim x1 as integer
Dim y1 as integer
Dim x2 as integer
Dim y2 as integer

Mousedown event of your image control, where x and y are parameters of the mousedown event

x1 = x
y1 = y

Mouseup event of your image control, where x and y are parameters of the mouseup event

x2 = x
y2 = y
if x2 <> x1 and y2 <> y1 then
'Zoom in
end if

chris256 | Fri, 09 Nov 2007 20:19:00 GMT |

How are you zooming based on the area selected if the amount of zoom is preset? You might find it simpler to use a single click to zoom in to the desired area rather than selecting a set of coordinates.

As for the selection itself, you can use the DrawFocusRect API to show a dotted line for the rectangle that will be zoomed.

wizbang | Fri, 09 Nov 2007 20:20:00 GMT |

Microsoft Visual Basic Hot Answers

Microsoft Visual Basic New questions

Microsoft Visual Basic Related Categories