[英]Creating a screen magnifier in C#
我跟隨這個網站用C#制作了一個放大鏡。 http://www.ultimateprogrammingtutorials.info/2013/03/how-to-make-simple-magnifier-in-c.html但是在Visual Studio中對其進行調試后,我得到的只是一個空白表格。 我的代碼做錯了嗎?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Magnifier
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Graphics g;
Bitmap bmp;
private void Timer1_Tick(object sender, EventArgs e)
{
bmp = new Bitmap(250, 200);
g = this.CreateGraphics();
g = Graphics.FromImage(bmp);
g.CopyFromScreen(MousePosition.X - 100, MousePosition.Y - 10,
0, 0, new Size(300, 300));
PictureBox1.Image = bmp;
}
}
}
您不僅需要從網站復制並粘貼代碼,還需要在表單中添加計時器組件並將其Tick
事件綁定到Timer1_Tick
方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.