Results 1 to 5 of 5

Thread: [RESOLVED] Fullscreen magnifier glass

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009

    Resolved [RESOLVED] Fullscreen magnifier glass

    Hello everyone, been a while since posting here...

    I'm trying to write a full-screen magnification program in Visual basic .NET, which will likely utilize the Windows API (Pinvoke) to do it's magic.
    The problem I am running into is that, when capturing the screen, you inevitably capture the window you display it on as well.
    You get the 'infiniwindow' effect, where the captured image is captured and displayed again. It also results in strange glitches when you have a dynamic moving image.

    I have tried several ways to capture the screen and displaying it WITHOUT ending up capturing my own drawn window. To do so, I need to draw 'above' the zero-DC buffer.

    This is the method I used to draw to the screen (no topmost window as that gets inevitably captured too):
    PHP Code:
    Public Class Magnifier
        Dim screen 
    As Screen
        Dim bounds 
    As Rectangle
        Dim g 
    As Graphics
        Dim zoom 
    As Double

    Public Sub New(ByVal screen As Screen)
    Me.screen screen
    .bounds Me.screen.Bounds
    End Sub

    Public Sub Dispose()
    End Sub

    Public Sub SetZoom(ByVal zoom As Double)
    Me.zoom zoom
        End Sub

    Public Sub Draw()
    g.CopyFromScreen(Cursor.Position, New Point(00), New Size(400400))
    End Sub
    As you can see, getting the Graphics for handle IntPtr.ZERO results in the same graphics used to capture the screen. So, I end up capturing myself.
    Draw is fired elsewhere using a timer.

    Is there some way to capture the screen while EXCLUDING everything I rendered 'on top' of it? Can it be done with a fullscreen topmost window?
    Alternatively, is it possible to be 'the man in the middle' transforming the graphics right before it is drawn to screen?

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    South Louisiana

    Re: Fullscreen magnifier glass

    Personally, I'd set up a property for Zoom:
        Private _zoom As Double
        Public Property Zoom() As Double
                Return _zoom
            End Get
            Set(ByVal value As Double)
                _zoom = value
            End Set
        End Property
    But, the situation could be different I suppose.

    I guess my question is, how often are you calling draw? Because what I think is happening is if you're calling draw to soon and the graphics.copyfromscreen gets placed in the cue and it creates a lag after being called to many times. A sort of 'hack' would be to call DoEvents, but this can leads to some other problems. Try adding the DoEvents and let us know if it's good 'nough

  3. #3
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012

    Re: Fullscreen magnifier glass

    Wouldn't Process.Start("magnify.exe") be a lot easier all round?
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009

    Re: Fullscreen magnifier glass

    I have a multiscreen issue. So far, all magnification programs stretch out their image over all monitors, and provide no way to show the same zoomed image on all monitors. So, I am forced to write my own alternative.
    Magnification stretched out over two monitors results in very strange zooming on both screens. As in, you can't properly look at the borders of a screen since it centered it there.

    Changing the interval had little to no effect. Since it is reading (BitBlt or something in the API itself) the same thing it is writing to, during the first capture it already messed up some parts. Doevents isn't going to help here either, since it is doesn't have to do with events in this case.

    So yeah, I am capturing the same thing I am displaying on, I need some form of split. I am now attempting iterating all active windows and rendering each one individually to screen, instead of capturing. Sadly, not all applications appear to support the Windows hDC API and end up rendering nothing/black.


    Iterating each window is not going to work here. Besides it being really glitchy, it also takes very long to render, likely even longer when adding a Bitmap buffer as well.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009

    Re: Fullscreen magnifier glass

    After a long, long browse through all corners of the Internet I finally found that there is someone out there that wrote a .NET interaction library with the Windows Magnifier. It allowed me to create a new Magnifier control and move it around. After converting the code to VB .NET and altering some of the Magnifier logic (of which, what the source area is) I am now able to magnify properly. Best of all, it supports Aero, so no weird glitches.

    Link is here:

    In addition I used my Window API container class to make the form click-throughable. In case people wish to know: set the layered and transparent Window Exstyles:
            Dim window As Window = window.FromControl(Me)
            window.ExStyle = window.ExStyle Or Window.ExStyles.Layered Or Window.ExStyles.Transparent
    Marking it solved, as my tests proved it to work very well, also fullscreen.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width