Tag: wm paint

鼠标进入/离开时WM_PAINT中绘制的TextBox闪烁

我有一个自定义的TextBox,当它为空时我在其中绘制一些占位符文本。 它运行得很好,但是当鼠标进入和离开TextBox时它会闪烁。 当鼠标hover在控件上时(我在Windows 8.1上),它似乎与边框变成蓝色有关。 知道如何解决这个问题吗? 我尝试了各种SetStyles标志但没有成功。 class MyTextBox : TextBox { public string PlaceHolder { get; set; } static readonly Brush sPlaceHolderBrush = new SolidBrush(Color.FromArgb(70, 70, 78)); static readonly StringFormat sFormat = new StringFormat { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center }; private Font mPlaceHolderFont; [DllImport(“user32”)] private static extern IntPtr GetWindowDC(IntPtr hwnd); protected override void […]

C#中的SetWindowsHookEx

我正试图挂钩第三方应用程序,以便我可以绘制到它的屏幕。 绘制到屏幕很容易,我不需要帮助,但我似乎遇到使用SetWindowsHookEx来处理WH_GETMESSAGE的问题。 我无法弄清楚最后2个参数要传递什么。 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 WindowDrawer { public partial class Form1 : Form { private delegate int HookProc(int code, IntPtr wParam, IntPtr lParam); static IntPtr hHook; IntPtr windowHandle; uint processHandle; HookProc PaintHookProcedure; [System.Runtime.InteropServices.DllImport(“user32.dll”, EntryPoint = “FindWindow”, SetLastError = true)] static […]