On my form I have a section that's created using some code I found online. What it does is basically simulates the Microsoft Magnifier so I can view what's on my extended monitor while only being able to see my primary monitor.
Here's the dilemma I'm facing: On the extended monitor will be a PDF document, it will be rotated clockwise so that the whole page will fit in a portrait style layout. When it is rotated, the Magnifier section on the primary monitor is rotated as well, I need that to be rotated -90 degrees so it appears normal.
Here's the code that takes the constant screen shots:
Dim e As Graphics = Me.CreateGraphics
Dim hr As Integer = Screen.PrimaryScreen.Bounds.Width
Dim vr As Integer = Screen.PrimaryScreen.Bounds.Height
'Get Zoom Percentage
Dim percent As Single = 1
Dim lengthX As Single = 1010
Dim lengthY As Single = 728
'Center Image Around The Mouse
Dim offsetX As Single = (lengthX - 585) \ 2
Dim offsetY As Single = (lengthY - 390) \ 2
'Actual Area To Blit To
Dim blitAreaX As Integer = 1010
Dim blitAreaY As Integer = 728
'New Bitmap & Graphics Object
Dim b As New Bitmap(CInt(blitAreaX), CInt(blitAreaY))
Dim g As Graphics = Graphics.FromImage(b)
'Try to make things faster
g.SmoothingMode = Drawing2D.SmoothingMode.HighSpeed
g.CompositingQuality = Drawing2D.CompositingQuality.HighSpeed
g.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighSpeed
g.InterpolationMode = Drawing2D.InterpolationMode.Low
'Try to make things faster
e.SmoothingMode = Drawing2D.SmoothingMode.HighSpeed
e.CompositingQuality = Drawing2D.CompositingQuality.HighSpeed
e.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighSpeed
e.InterpolationMode = Drawing2D.InterpolationMode.Low
'DC Of Desktop And Graphics Object
Dim hWndWindow As IntPtr = GetDesktopWindow()
Dim hdcWindow As IntPtr = GetDC(hWndWindow)
Dim hdcGraphics As IntPtr = g.GetHdc()
'BitBlt & Graphics.DrawImage Solution
'------------------------------------------
'BitBlt the Screen (Captures Transparent Windows & Prevents Mirror Effect)
BitBlt(hdcGraphics.ToInt32, 585, 390, blitAreaX, blitAreaY, hdcWindow.ToInt32, Cursor.Current.Position.X - offsetX, Cursor.Current.Position.Y - offsetY, SRCCOPY Or CAPTUREBLT Or NOMIRRORBITMAP)
'Free Memory
ReleaseDC(hWndWindow.ToInt32, hdcWindow.ToInt32)
g.ReleaseHdc(hdcGraphics)
e.DrawImage(b, New Rectangle(0, 0, blitAreaX, blitAreaY), 0, 0, lengthX, lengthY, GraphicsUnit.Pixel)
e.Dispose()
Here's the dilemma I'm facing: On the extended monitor will be a PDF document, it will be rotated clockwise so that the whole page will fit in a portrait style layout. When it is rotated, the Magnifier section on the primary monitor is rotated as well, I need that to be rotated -90 degrees so it appears normal.
Here's the code that takes the constant screen shots:
Dim e As Graphics = Me.CreateGraphics
Dim hr As Integer = Screen.PrimaryScreen.Bounds.Width
Dim vr As Integer = Screen.PrimaryScreen.Bounds.Height
'Get Zoom Percentage
Dim percent As Single = 1
Dim lengthX As Single = 1010
Dim lengthY As Single = 728
'Center Image Around The Mouse
Dim offsetX As Single = (lengthX - 585) \ 2
Dim offsetY As Single = (lengthY - 390) \ 2
'Actual Area To Blit To
Dim blitAreaX As Integer = 1010
Dim blitAreaY As Integer = 728
'New Bitmap & Graphics Object
Dim b As New Bitmap(CInt(blitAreaX), CInt(blitAreaY))
Dim g As Graphics = Graphics.FromImage(b)
'Try to make things faster
g.SmoothingMode = Drawing2D.SmoothingMode.HighSpeed
g.CompositingQuality = Drawing2D.CompositingQuality.HighSpeed
g.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighSpeed
g.InterpolationMode = Drawing2D.InterpolationMode.Low
'Try to make things faster
e.SmoothingMode = Drawing2D.SmoothingMode.HighSpeed
e.CompositingQuality = Drawing2D.CompositingQuality.HighSpeed
e.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighSpeed
e.InterpolationMode = Drawing2D.InterpolationMode.Low
'DC Of Desktop And Graphics Object
Dim hWndWindow As IntPtr = GetDesktopWindow()
Dim hdcWindow As IntPtr = GetDC(hWndWindow)
Dim hdcGraphics As IntPtr = g.GetHdc()
'BitBlt & Graphics.DrawImage Solution
'------------------------------------------
'BitBlt the Screen (Captures Transparent Windows & Prevents Mirror Effect)
BitBlt(hdcGraphics.ToInt32, 585, 390, blitAreaX, blitAreaY, hdcWindow.ToInt32, Cursor.Current.Position.X - offsetX, Cursor.Current.Position.Y - offsetY, SRCCOPY Or CAPTUREBLT Or NOMIRRORBITMAP)
'Free Memory
ReleaseDC(hWndWindow.ToInt32, hdcWindow.ToInt32)
g.ReleaseHdc(hdcGraphics)
e.DrawImage(b, New Rectangle(0, 0, blitAreaX, blitAreaY), 0, 0, lengthX, lengthY, GraphicsUnit.Pixel)
e.Dispose()