Voglio fare un'applicazione SS. Ma ho problemi su questo argomento. Voglio che l'utente sia in grado di selezionare un'area speciale per fare screenshot. Voglio anche che il desktop sia attivo mentre l'utente sta selezionando l'area. Ad esempio, l'utente vuole prendere un SS del frame specifico di un video. L'utente deve essere in grado di farlo mentre il video è in riproduzione. Ho provato questo utilizzando il disegno direttamente sul desktop. Ma sfarfallio così tanto. Come posso risolvere questo problema o esiste un modo alternativo?Come fare una selezione dell'area screenshot disegnando sul desktop per fare screenshot?
Il mio codice:
[DllImport("User32.dll")]
static extern IntPtr GetDC(IntPtr hwnd);
[DllImport("user32.dll")]
static extern bool InvalidateRect(IntPtr hWnd, IntPtr lpRect, bool bErase);
public Form1()
{
InitializeComponent();
this.Load += Form1_Load;
}
void Form1_Load(object sender, EventArgs e)
{
Start();
}
IntPtr handle;
Graphics grp;
void Start()
{
handle = GetDC(IntPtr.Zero);
grp = Graphics.FromHdc(handle);
grp.SmoothingMode = SmoothingMode.HighQuality;
timer2.Start();
}
private void timer2_Tick(object sender, EventArgs e)
{
grp.DrawLine(Pens.Red, 0, Cursor.Position.Y, Screen.PrimaryScreen.Bounds.Width, Cursor.Position.Y);
InvalidateRect(IntPtr.Zero, IntPtr.Zero, false);
}
FYI - [Greenshot] (http://getgreenshot.org/) lo fa ed è un codice .NET gratuito e open source. Puoi semplicemente "sbirciare" dal loro codice. – ja72