none
Can I make a form act as a magnifying glass for anything that is under it? RRS feed

  • Question

  •  

    I need my form (or preferably part of it) to act as magnifying glass, without using my mouse cursor, is this possible in VB.net?

    Reason: I'm using an old POS software that has information displayed for customers in a small font on the second screen, I'm looking to magnify an area of that screen to be easier to read. 

    Edit:

    (Most 3rd party apps won't work because they serve a different purpose), they can't offer auto startup, they can't be set to certain areas of the screen (which is the seconds screen of my pc), this is why building my solution seems to be the only way.

    • Edited by M.Caplan Thursday, December 12, 2019 9:22 PM
    Thursday, December 12, 2019 8:22 PM

All replies

  •  

    I need my form (or preferably part of it) to act as magnifying glass, without using my mouse cursor, is this possible in VB.net?

    Reason: I'm using an old POS software that has information displayed for customers in a small font on the second screen, I'm looking to magnify an area of that screen to be easier to read. 


    Hi

    Is the Windows Magnifier not your best option?


    Regards Les, Livingston, Scotland

    Thursday, December 12, 2019 8:47 PM
  • I've tried every application I found, nothing remotely worked.
    Thursday, December 12, 2019 8:50 PM
  • Question, If not by moving the mouse how do you see this working ?

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Thursday, December 12, 2019 8:53 PM
    Moderator
  • I've tried every application I found, nothing remotely worked.

    Hi

    Was one of the applications you found Windows Magnifier?


    Regards Les, Livingston, Scotland

    Thursday, December 12, 2019 9:10 PM
  • yes, it was the worst of them.
    Thursday, December 12, 2019 9:16 PM
  • yes, it was the worst of them.

    Hi

    Hmmmm.....................

    What improvements do you need comparing your fantasy with Windows Magnifier?

    In what way did Windows Magnifier qualify for 'the worst of them'?

    What were the points with the others which made them better than Windows Magnifier?


    Regards Les, Livingston, Scotland

    Thursday, December 12, 2019 10:10 PM
  • This example has a transparent window on the form and that is captured and redrawn on the form x2 magnification.

    Public Class Form2
        Private SrcSize As Size = New Size(150, 150)
        Private MagRatio As Double = 2
    
        Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            ClientSize = New Size(450, 310)
            DoubleBuffered = True
            TransparencyKey = Color.Lime
            Form2_Resize(0, Nothing)
        End Sub
    
        Private Sub Form2_LocationChanged(sender As Object, e As EventArgs) Handles Me.LocationChanged
            Form2_Resize(0, Nothing)
        End Sub
    
        Private Sub Form2_Resize(sender As Object, e As EventArgs) Handles Me.Resize
            Invalidate()
        End Sub
    
        Private Sub Form2_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
    
            Using bmp1 As New Bitmap(SrcSize.Width, SrcSize.Height),
               g1 As Graphics = Graphics.FromImage(bmp1)
    
                'make capture transparent hole
                e.Graphics.FillRectangle(Brushes.Lime, 0, 0, SrcSize.Width, SrcSize.Height)
    
                'capture screen
                Dim ptScrn As Point = Me.PointToScreen(Point.Empty)
                g1.CopyFromScreen(ptScrn.X, ptScrn.Y, 0, 0, SrcSize)
    
                Using bmp2 As New Bitmap(CInt(MagRatio * SrcSize.Width), CInt(MagRatio * SrcSize.Height)),
                        g2 As Graphics = Graphics.FromImage(bmp2)
    
                    'magnify the screen image
                    g2.DrawImage(bmp1, 0, 0, bmp2.Width, bmp2.Height)
    
                    'draw magnified on form
                    e.Graphics.DrawImage(bmp2, SrcSize.Width + 10, 0)
                    e.Graphics.DrawRectangle(Pens.Black, SrcSize.Width + 10, 0, bmp2.Width, bmp2.Height)
    
                End Using
            End Using
        End Sub
    End Class

    Thursday, December 12, 2019 11:31 PM
  • Hi,

    Tommy has provided a great solution for you. Is this effect that you want?

    If his post helps to resolve your issue, please click the "Mark as Answer" of that post or click Answered "Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster.

    Best Regards,

    Julie


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, December 13, 2019 2:35 AM
    Moderator
  • If you are interested in duplication of some area from your second screen, displaying scaled copy on main screen, then consider “Desktop Duplication”. There is a sample: https://github.com/Microsoft/Windows-classic-samples/tree/master/Samples/DXGIDesktopDuplication. However, further adjustments do not require Visual Basic knowledge only.

    Friday, December 13, 2019 7:21 AM