私はC#でウィンドウフォームを持っていますが、 "X"トップバーがなくても孤独なボタンのように見えます。私はそれを単なるボタンにしました。私はボタンを長くタッチすると、それを画面上で動かすことができます。長いクリック時に移動するウィンドウフォームの作成方法C#
私はそれを移動することができますが、私はボタンをタッチすると、私はそれを移動することができますしたいウィンドウのフォームの背景に触れることに成功しました。
インターネットで見た後、私はこのコードを作ったが、私はmoveApp()mehtodに何を書くべきか分からない。
これは私のコードです:
namespace Print_My_Screen
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void PrintScreen()
{
Bitmap printscreen = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics graphics = Graphics.FromImage(printscreen as Image);
graphics.CopyFromScreen(0, 0, 0, 0, printscreen.Size);
string subPath = @"C:\PrintMyScreen";
bool exists = System.IO.Directory.Exists(subPath);
if (!exists)
System.IO.Directory.CreateDirectory(subPath);
printscreen.Save(@"C:\PrintMyScreen\printscreen.png", ImageFormat.Png);
printIt();
MessageBox.Show("Your screen has been printed successfully","",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
private void button1_Click(object sender, EventArgs e)
{
PrintScreen();
}
private void printIt()
{
PrintDocument pd = new PrintDocument();
// pd.PrintPage += PrintPage;
pd.PrintPage += (sender, args) =>
{
System.Drawing.Image img = System.Drawing.Image.FromFile(@"C:\PrintMyScreen\printscreen.png");
img.RotateFlip(RotateFlipType.Rotate90FlipXY);
args.Graphics.DrawImage(img, args.MarginBounds);
};
pd.Print();
}
private void PrintPage(object o, PrintPageEventArgs e)
{
System.Drawing.Image img = System.Drawing.Image.FromFile(@"C:\PrintMyScreen\printscreen.png");
Point loc = new Point(100, 100);
e.Graphics.DrawImage(img, loc);
img.Dispose();
}
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case 0x84:
base.WndProc(ref m);
if ((int)m.Result == 0x1)
m.Result = (IntPtr)0x2;
return;
}
base.WndProc(ref m);
}
private void moveApp()
{
}
public void Repeater(Button btn, int interval)
{
var timer = new Timer { Interval = interval };
timer.Tick += (sender, e) => moveApp();
btn.MouseDown += (sender, e) => timer.Start();
btn.MouseUp += (sender, e) => timer.Stop();
btn.Disposed += (sender, e) =>
{
timer.Stop();
timer.Dispose();
};
}
}
}