Click here to Skip to main content
13,149,589 members (52,829 online)
Click here to Skip to main content
Add your own
alternative version


68 bookmarked
Posted 1 Apr 2007

Simple Magnifier

, 1 Apr 2007
Rate this:
Please Sign up or sign in to vote.
A fun little application: Simple magnifier for your desktop


This is a fun little gadget for your desktop: a simple magnifier.


I believe, many of you have already seen at least one magnifier application. I tried a few including the one which is built-in at the OS, however, I didn't like them one way or another. So, I decided to implement a simple one for my own usage.

Well, I've been using it quite sometime by now and it really works great. I thought you may find it interesting as well.

A Few Words About the Code

As I mentioned earlier, the program in fact is a simple application. However, it still demonstrates a few interesting points: First of all, it shows how to capture a screen image, double buffering, moving a Windows form programmatically, and serializing/deserializing configuration information through XmlSerializer. Second of all, the little application is designed to be a fun application in my mind, so it doesn't follow conventional Windows programming steps. Instead, I've used a very small borderless window as the main form. It has only 3 buttons (actually, hot spots) to do all functionality it provides. The first one instantiates a magnifier form, the second one to do the configuration, and finally, the third one is to exit from application.

Here is a screenshot of the application:

Screenshot - magSample1.jpg

The configuration section provides quite a few things to play with:

Screenshot - magConfig1.jpg

Some of the code snippets are also shown below:

// Make the window (the form) elliptical
GraphicsPath gp = new GraphicsPath();
Region = new Region(gp);
//--- Double Buffering --- 

protected override void OnPaintBackground(PaintEventArgs e)
    if (mConfiguration.DoubleBuffered)
        // Do not paint background (required for double buffering)!

protected override void  OnPaint(PaintEventArgs e)
    if (mBufferImage == null)
        mBufferImage = new Bitmap(Width, Height);
    Graphics bufferGrf = Graphics.FromImage(mBufferImage);

    Graphics g;

    if (mConfiguration.DoubleBuffered)
        g = bufferGrf;
        g = e.Graphics;

    if (mScreenImage != null)
        Rectangle dest = new Rectangle(0, 0, Width, Height);
        int w = (int)(Width / mConfiguration.ZoomFactor);
        int h = (int)(Height / mConfiguration.ZoomFactor);
        int x = Left - w / 2 + Width / 2;
        int y = Top - h / 2 + Height / 2;

            x, y,
            w, h,

    if (mImageMagnifier != null)
        g.DrawImage(mImageMagnifier, 0, 0, Width, Height);

    if (mConfiguration.DoubleBuffered)
        e.Graphics.DrawImage(mBufferImage, 0, 0, Width, Height);
//--- XML Serialization --- 
public class XmlUtility
    public static void Serialize(Object data, string fileName)
        Type type = data.GetType();
        XmlSerializer xs = new XmlSerializer(type);
        XmlTextWriter xmlWriter = new XmlTextWriter(fileName, System.Text.Encoding.UTF8);
        xmlWriter.Formatting = Formatting.Indented;
        xs.Serialize(xmlWriter, data);

    public static Object Deserialize(Type type, string fileName)
        XmlSerializer xs = new XmlSerializer(type);

        XmlTextReader xmlReader = new XmlTextReader(fileName);
        Object data = xs.Deserialize(xmlReader);


        return data;

Please take a look at the provided code to see the details in the implementation.


It was really fun to code this application. I shared it with my friends and many really liked it. Hope you guys will like it as much as I did.

Have a nice day!


  • 2nd April, 2007: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionNot Working if Two Monitors Connected Pin
itsdipak31-Mar-16 4:08
memberitsdipak31-Mar-16 4:08 
QuestionHello, Sir how I can to deploy windows form database application to other computer Pin
Member 108254999-Sep-14 21:18
memberMember 108254999-Sep-14 21:18 
QuestionAbout Multimonitor Pin
magefesa8-Oct-12 22:26
membermagefesa8-Oct-12 22:26 
QuestionFrom Circle to Square Pin
h.jaza2-Jan-10 7:03
memberh.jaza2-Jan-10 7:03 
GeneralC++ Pin
Super Garrison30-Sep-09 7:19
memberSuper Garrison30-Sep-09 7:19 
QuestionSuggestion Pin
Amin856-Feb-09 3:20
memberAmin856-Feb-09 3:20 
Generalsuggestion Pin
Rakesh Muraharishetty23-Apr-07 12:08
memberRakesh Muraharishetty23-Apr-07 12:08 
GeneralRe: suggestion Pin
Rakesh Muraharishetty23-Apr-07 12:11
memberRakesh Muraharishetty23-Apr-07 12:11 
GeneralRe: suggestion Pin
otigli23-Apr-07 21:06
memberotigli23-Apr-07 21:06 
GeneralReally cool Pin
Yury Goltsman11-Apr-07 1:07
memberYury Goltsman11-Apr-07 1:07 
GeneralRe: Really cool Pin
otigli11-Apr-07 9:12
memberotigli11-Apr-07 9:12 
GeneralGood job!!! Pin
aporra10-Apr-07 1:31
memberaporra10-Apr-07 1:31 
GeneralRe: Good job!!! Pin
otigli10-Apr-07 16:26
memberotigli10-Apr-07 16:26 
GeneralCool Pin
Muammar©9-Apr-07 23:28
memberMuammar©9-Apr-07 23:28 
GeneralRe: Cool Pin
otigli10-Apr-07 16:25
memberotigli10-Apr-07 16:25 
Generalgreat app Pin
jorgemar2-Apr-07 14:30
memberjorgemar2-Apr-07 14:30 
GeneralRe: great app Pin
otigli2-Apr-07 16:56
memberotigli2-Apr-07 16:56 
GeneralGreat Implimentation Pin
Custec2-Apr-07 1:46
memberCustec2-Apr-07 1:46 
GeneralRe: Great Implimentation Pin
otigli2-Apr-07 5:21
memberotigli2-Apr-07 5:21 
GeneralVery Nice Pin
Stephan Poirier1-Apr-07 22:15
memberStephan Poirier1-Apr-07 22:15 
GeneralRe: Very Nice Pin
otigli1-Apr-07 22:21
memberotigli1-Apr-07 22:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.170924.2 | Last Updated 2 Apr 2007
Article Copyright 2007 by otigli
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid