Magnifier window that follows mouse - how?

This is a discussion on Magnifier window that follows mouse - how? within the Windows Programming forums, part of the Platform Specific Boards category; So I have a thought that I want to make a magnifier application. I have seen some of them but ...

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    9

    Question Magnifier window that follows mouse - how?

    So I have a thought that I want to make a magnifier application. I have seen some of them but they miss one useful feature: I need something that works actually like a hand-held magnifier - moves with the mouse and magnifies the portion of the screen under the mouse cursor.

    I have played a bit with BitBlt and DCs and know how to transform bitmaps. The problem is that if app window follows the mouse, it obscures the screen area which I want to magnify and also steels the mouse focus. I need something "transparent". Is there any way I can get DesktopDC for entire desktop except my own application and also pass mouse clicks to windows behind my app (without causing my app to flicker a lot)?

    If someone have an idea of a good solution for this, I would be grateful.

    Thanks.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,672
    So you want to learn how the built-in magnifier in XP works (for example)?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Oct 2007
    Posts
    9
    I have an idea of how Win XP magnifier works. But it lacks the feature I need - although it has "Follow mouse" option, the magnifier window itself does not follow the mouse, it only displays where the mouse is. And if you try to move the mouse onto the window, you see that window gets gray - it is not possible to magnify area behind that window. But I want to overcome that problem somehow (if only I knew how ).

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,672
    So it would follow the mouse a bit like some tool-tips do, and reposition itself relative to the mouse when nearing the edge of the screen?

    A brief search reveals http://www.codeproject.com/gdi/magnify.asp
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Oct 2007
    Posts
    9
    Thanks, Salem, for good found! It is almost what I look for. Now I just have to try to figure out how to make it work globally, not just in the application window.

    This
    http://www.codeproject.com/dialog/magnifyglass.asp
    is even closer, but the problem is the same - the mouse becomes inactive at the time of zooming. They are using a big invisible window to get it work.
    Even commercial magnifiers
    http://www.download.com/3000-2094_4-10706010.html
    are like tooltip windows - they follow the mouse, but does not go around the mouse :-(
    Is it really impossible?
    Last edited by midix; 10-02-2007 at 12:17 PM.

  6. #6
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    No but think about it. You are wanting to magnify the place where the mouse is but your mouse cursor is there. Before you blit the magnified portion you will need to hide the mouse cursor.

    I would imagine if you trap for WM_MOUSEMOVE, hide the cursor, perform the magnify and blit ops, show the window, etc. you would have a window that followed the mouse.

    I did this just fine in my tile editor and see no reason why you would not be able to do the same.

  7. #7
    Registered User
    Join Date
    Oct 2007
    Posts
    9
    Mouse cursor would not be the biggest problem - if I grab bitmap from DesktopDC, then mouse is invisible anyway. The problem is - I need to grab the area where my app window is. So I have to hide window, grab bitmap, show window with stretched bitmap. I hope, it will not cause bad flickering?
    And the worst - my window must be "transparent" for all WM_xxx except mousemove. If user clicks my app window, the app must make operating system pass messages to the next window. But there may be more then one window behind my app so I really don't know which window needs WM_xxx.

    Is there any way how I can return received message to OS and tell it - "My app window will not process it, so pass it to the next window, which is behind my app window" ?

    I have read that commercial screen magnifiers (like ZoomText) use video driver interception but I do not want to dig that deep, maybe there is simpler solution? Maybe DirectDraw could help?

    Anyway, I'll try experimenting, maybe Bubba's approach will be ok, thanks.

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by midix View Post
    Mouse cursor would not be the biggest problem - if I grab bitmap from DesktopDC, then mouse is invisible anyway.
    I can't really comment on anything else, but the above will depend on whether the mouse cursor is implemented in the same layer as the desktop, or in some sort of overlay layer. This in turn will depend on both the hardware in the graphics card, the driver, and quite possibly also the settings used at the time - when you don't use overlays, the cursor part of the driver uses the overlay layer to draw the cursor, but if there is a need to do overlay graphics (such as windows media player), then the cursor becomes software generated.

    So just because YOUR hardware and software combination happens to not suffer from the problem of the cursor being part of what you copy, it may well be under other circumstances.

    [When I worked for a graphics company, I implemented the cursor management, so I do have a fair idea how this can be done].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #9
    Registered User
    Join Date
    Oct 2007
    Posts
    9
    matsp, thanks for the warning, I somehow thought that mouse is always overlay. Uhh, obviously I need more experience....

  10. #10
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by midix View Post
    matsp, thanks for the warning, I somehow thought that mouse is always overlay. Uhh, obviously I need more experience....
    It probably ALWAYS is in the high end modern graphics cards (it doesn't cost much to add another layer when you already have some ten or hundred millions of gates in the chip).

    But not everyone has a fancy graphics chip, they may have a cheapo-lowend machine with built-in graphics chip that is a few years old.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  2. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 10:06 AM
  3. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  4. problem with open gl engine.
    By gell10 in forum Game Programming
    Replies: 1
    Last Post: 08-21-2003, 04:10 AM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 09:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21