Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None,后窗体只有工作区了,我想为为它画边框,我在onpaint方法里画了后发现边框把工作区占了,如何在非工作区画上边框呢?
RT
C#或VB.NET都可以的。
非常感谢!
Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs) MyBase.OnPaintBackground(e) Dim p As New Pen(Color.Red, 10) e.Graphics.DrawRectangle(p, e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.Width - 1, e.ClipRectangle.Height - 1) End Sub
this.Padding = new Padding(this.m_BorderWidth, this.m_BorderWidth + this.m_CaptionHeight, this.m_BorderWidth, this.m_BorderWidth);
[解决办法]
[System.Runtime.InteropServices.DllImport("user32.dll")] public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int wndproc); [System.Runtime.InteropServices.DllImport("user32.dll")] public static extern int GetWindowLong(IntPtr hWnd, int nIndex); public const int WS_CAPTION = 0xC00000; public const int GWL_STYLE = -16; private void Form1_Load(object sender, EventArgs e) { this.FormBorderStyle = FormBorderStyle.Sizable; SetWindowLong(this.Handle, GWL_STYLE, (~WS_CAPTION) & GetWindowLong(this.Handle, GWL_STYLE)); this.Height = this.ClientSize.Height; }
[解决办法]
觉得这需要细细调整,不是一两个技巧几句话就可以做成完好外观的。楼主好好再研究一下吧,我相信楼主会做出来好的效果的。