Tag: 窗口resize

带有底部边框的TextBox

我希望TextBox具有底部边框,但由于Color.Transparent为TextBox绘制的图形在resize时会扭曲/损坏。 使用我发现的代码,我能够创建一个带下划线的TextBox(带有透明顶部,左侧,右侧的绘制矩形)。 问题是当我调整窗体/窗口的大小时:当我将其调整为较小,然后再次resize以扩展它时,绘制的图形会失真。 对此有任何修复? 这是照片: 第二张照片已经调整得更小,然后又回到更大的尺寸。 这是代码: [DllImport(“user32”)] private static extern IntPtr GetWindowDC(IntPtr hwnd); struct RECT { public int left, top, right, bottom; } struct NCCALSIZE_PARAMS { public RECT newWindow; public RECT oldWindow; public RECT clientWindow; IntPtr windowPos; } float clientPadding = 0; int actualBorderWidth = 2; Color borderColor = Color.Black; protected override void WndProc(ref […]