Here is some code i have written to take a screen shot of the primary monitor and show an icon where the mouse is located.

The function first takes a screen shot then goes onto to draw an icon at the same posistion where the mouse is located.

private Bitmap GetScreenShot()
        {
            //here is the code to capture the screen
            System.Drawing.Size rec = Screen.PrimaryScreen.Bounds.Size;
            Bitmap pic = new Bitmap(rec.Width,
                rec.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            Graphics g = Graphics.FromImage(pic);
            g.CopyFromScreen(0, 0, 0, 0, new Size(rec.Width, rec.Height));

            //Draw the icon < after the screen has been
            //captured, add a icon to the bitmap
            Point cp = new Point();
            User32.GetCursorPos(out cp);
            g.DrawIcon(SystemIcons.Hand, cp.X, cp.Y);
           
            //return the picture, and display it in a control
            return pic;

        }

To get the posistion of the mouse can be done a couple ways, in this code i used the pinvoke way calling the User32 functions

static class User32
    {

        [DllImport("user32.dll")]
        public static extern IntPtr GetCursor();

        [DllImport("user32.dll")]
        public static extern bool GetCursorPos(out Point lpPoint);

    }

Here is an example look at the caution icon, that is where the mouse was.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Trust Level

Published 1/29/2008 by Dave in asp.net
Tags:

FYI one of the best links to do with trust levels

<http://msdn2.microsoft.com/en-us/library/ms998326.aspx>

 During the setup of this blog (BlogEngine.Net, which is awesome BTW) I ran into a small snag. The hosting comapny could not run this blog with high trust set. So as I was a little rusty on what the difference between High and Medium (which is what this is now running at) I googled away. The above link contains all the details between all the levels.

Also if you are experencing the same problem, delete the line in the config file, this will then resort to medium trust (if that is the max the server will allow), which will mean you can run the blog

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5