using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.InteropServices ;
using System.IO;
using System.Media;
namespace BaiheTest
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
this.FormBorderStyle = FormBorderStyle.None;
this.Size = Screen.PrimaryScreen.Bounds.Size;
this.Location = new Point(0,0);
SoundPlayer sp = new SoundPlayer(Properties.Resources.mp3);
sp.PlayLooping();
}
// 还可以这样 :
[DllImport("gdi32.dll")]
private static extern IntPtr CreateDC(string lpszDriver, string lpszDevice, string lpszOutput, IntPtr lpInitData);
[DllImport("gdi32.dll")]
private static extern bool BitBlt(IntPtr hdcDest,
int nXDest,
int nYDest,
int nWidth,
int nHeight,
IntPtr hdcSrc,
int nXSrc,
int nYSrc,
System.Int32 dwRop);
private void Form2_Load(object sender, EventArgs e)
{
panel1.Visible = false;
}
private void button1_Click(object sender, EventArgs e)
{
// SoundPlayer sp = new SoundPlayer();
// sp.Play();
this.Hide();
Application.DoEvents();
pauseMinSecond(2000);
int w = Screen.PrimaryScreen.Bounds.Width;
int h = Screen.PrimaryScreen.Bounds.Height;
IntPtr dc1 = CreateDC("Display", null, null, (IntPtr)null);
Graphics g1 = Graphics.FromHdc(dc1);
Bitmap bmp1 = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, g1);
Graphics bmp2 = Graphics.FromImage(bmp1);
IntPtr screenHandle = g1.GetHdc();
IntPtr imageHandle = bmp2.GetHdc();
BitBlt(imageHandle, 0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, screenHandle, 0, 0, 13369376);
g1.ReleaseHdc();
bmp2.ReleaseHdc();
MemoryStream oStream = new MemoryStream();
Bitmap photo = new Bitmap(w, h);
Graphics graphic = Graphics.FromImage(photo);
graphic.CopyFromScreen(0, 0, 0, 0, new Size(photo.Width, photo.Height));
photo.Save(oStream, System.Drawing.Imaging.ImageFormat.Jpeg);
Image img = Image.FromStream(oStream);
this.BackgroundImage = img;
// 这四句话就可以截屏了,但是就是不能截取视频的屏幕。。。
this.Show ();
Application.DoEvents();
}
void pauseMinSecond(int msecond)
{
DateTime t1 = DateTime.Now.AddMilliseconds(msecond);
while (DateTime.Now < t1)
{
int i = 3;
i += 6;
Application.DoEvents();
}
return;
}
private void button2_Click(object sender, EventArgs e)
{
Close();
}
private void button3_Click(object sender, EventArgs e)
{
MessageBox.Show("my baby?");
panel1.Visible = true;
this.BackgroundImage = Properties.Resources.to_My_bay1;
}
private void timer1_Tick(object sender, EventArgs e)
{
if (label1.Top <= -label1.Height) {
label1.Top = this.panel1.Height;
}
label1.Top -= 3;
}
private void panel1_DragOver(object sender, DragEventArgs e)
{
}
private void panel1_MouseHover(object sender, EventArgs e)
{
}
private void panel1_MouseEnter(object sender, EventArgs e)
{
timer1.Stop();
}
private void panel1_MouseLeave(object sender, EventArgs e)
{
timer1.Start();
}
}
}