Hi Herfried,
Thanks for the reply, that's exactly what I did, but instead of using
Graphics.DrawImage I use the StretchBlt Api. It is working now, I
place the "zooming code" at one of my TabPage's Paint Event, and a
Timer set at 50milliseconds, to zoom in and out, a Vertical Scrollbar
is used.
However, could you kindly help me remove the flickering? In any
Interval I use at the Timer, there is still some amount of flickering.
Even if I use Graphics.DrawImage. I just wanted it to be the same as
Microsoft's Magnifier, it doesen't flicker at all
Thanks,
Henry
Private Sub tbpPatternMovement_Paint(ByVal sender As Object, ByVal e
As System.Windows.Forms.PaintEventArgs) Handles
tbpPatternMovement.Paint
'Mouse Coordiantes To Statusbar
Me.stbVideoPatternControl.Text = "X = " &
Cursor.Current.Position.X & ", Y = " & Cursor.Current.Position.Y
'Get Handle Of Desktop
Dim hdc As IntPtr = GetDC(IntPtr.Zero)
'Get Screen Dimensions
Dim hr As Integer = Screen.PrimaryScreen.Bounds.Width
Dim vr As Integer = Screen.PrimaryScreen.Bounds.Height
Dim percent As Single = Me.vsbVideoPatternControl.Value / 100
Dim lengthX As Single = (Me.tbpPatternMovement.Width -
Me.vsbVideoPatternControl.Width) * percent
Dim lengthY As Single = (Me.tbpPatternMovement.Height -
Me.stbVideoPatternControl.Height) * percent
'Center image around the mouse
Dim offsetX As Single = lengthX \ 2
Dim offsetY As Single = lengthY \ 2
'Actual area to blit to
Dim blitAreaX As Integer = Me.tbpPatternMovement.Width -
Me.vsbVideoPatternControl.Width
Dim blitAreaY As Integer = Me.tbpPatternMovement.Height -
Me.stbVideoPatternControl.Height
Dim ret As Integer = StretchBlt(e.Graphics.GetHdc.ToInt32, 0,
0, blitAreaX, blitAreaY, hdc.ToInt32, Cursor.Current.Position.X -
offsetX, Cursor.Current.Position.Y - offsetY, lengthX, lengthY,
SRCCOPY)
Dim dsHWND As Integer = GetDesktopWindow()
'Free Memory
e.Graphics.ReleaseHdc(hdc)
e.Dispose()
ReleaseDC(dsHWND, hdc.ToInt32)
End Sub
Private Sub tmrVideoPatternControl_Tick(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
tmrVideoPatternControl.Tick
Me.tbpPatternMovement.Invalidate()
End Sub