ERLEDIGT
NEIN
NEIN
ANTWORTEN
0
0
ZUGRIFFE
1236
1236
EMPFEHLEN
-
06.04.08 18:54 #1
Hi,
Ich habe ein Problem bein Zeichnen auf den Desktop:
Ich habe das Zeichnen nach unzähligen Versuchen einigermaßen über:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Drawing.Imaging; namespace TastaturVisualizer { public partial class Form1 : Form { public Form1() { InitializeComponent(); this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true); } private void Form1_Load(object sender, EventArgs e) { } private void timer1_Tick(object sender, EventArgs e) { IntPtr deskDC = User32.GetDC(IntPtr.Zero); Graphics g = Graphics.FromHdc(deskDC); Pen p = new Pen(Color.FromArgb(100, 0, 0), 10); g.DrawLine(p, 5, 5, 300, 300); User32.InvalidateRect(IntPtr.Zero, IntPtr.Zero, false); g.Dispose(); User32.ReleaseDC(0, deskDC); } } #region User32 internal class User32 { [DllImport("user32")] internal static extern IntPtr GetDC(IntPtr hwnd); [DllImport("User32.dll")] internal static extern void ReleaseDC(int hwnd, IntPtr hdc); [DllImport("user32.dll")] internal static extern bool InvalidateRect(IntPtr hWnd, IntPtr lpRect, bool bErase); } #endregion }
realisiert, allerdings flackert der Bildschirm dadurch unerträglich.
Ich habe schon nach Doublebuffering-Methoden gesucht, doch sie waren alle auf Fensterbetrieb ausgelegt und ich konnte das Prinzip nicht so recht auf den ganzen Bildschirm anwenden.
Kann mir da jemand mit dem Flackerproblem helfen?
Und gibt es eventuell eine einfachere Methode auf den Bildschirm zu zeichnen?
Wichtig ist mir dabei eigentlich nur, dass das Gezeichnete das Anklicken der Elemente im Hintergrund nicht verhindert (da dürften also transparente Fenster, in denen gezeichnet wird wegfallen)
EDIT: Problem gelöst: Man kann die Fenster doch als durchklickbar einstellen:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Drawing.Imaging; namespace TastaturVisualizer { public partial class Form1 : Form { [DllImport("user32.dll", SetLastError = true)] static extern int GetWindowLong(IntPtr hWnd, int nIndex); [DllImport("user32.dll", SetLastError = true)] static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); private const int GWL_EXSTYLE = -20; private const int WS_EX_TRANSPARENT = 0x20; public Form1() { InitializeComponent(); this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true); } private void Form1_Load(object sender, EventArgs e) { int exstyle = GetWindowLong(this.Handle, GWL_EXSTYLE); exstyle |= WS_EX_TRANSPARENT; SetWindowLong(this.Handle, GWL_EXSTYLE, exstyle); } } }Geändert von Sumpfkrautjunkie (08.04.08 um 15:32 Uhr)
Ähnliche Themen
-
Auf Desktop zeichnen?
Von Passer im Forum C/C++Antworten: 1Letzter Beitrag: 20.05.09, 11:25 -
Bitmap auf Desktop zeichnen
Von Kaiser206 im Forum C/C++Antworten: 2Letzter Beitrag: 12.07.08, 23:12 -
Auf Desktop zeichnen
Von XsilentX im Forum .NET Windows FormsAntworten: 4Letzter Beitrag: 15.12.06, 16:30 -
Desktop neu zeichnen?
Von wurzelholz im Forum Visual Basic 6.0Antworten: 2Letzter Beitrag: 22.08.05, 13:40 -
Auf Desktop zeichnen
Von James303 im Forum Visual Basic 6.0Antworten: 2Letzter Beitrag: 28.06.05, 18:07





Zitieren
Login





