As an alternative to painting the window you can always allow the system to
handle the border style and still be part of the non-client area using some
p/invokes. There are other border styles that you can use as well if you
look through the docs. But if you're painting the border yourself then you
might consider using the ControlPaint class to perform the drawing for you.
using System.Runtime.InteropServices;
private const int GWL_EXSTYLE = -20;
private const int WS_EX_DLGMODALFRAME = 0x00000001;
private const int SWP_NOSIZE = 0x0001;
private const int SWP_NOMOVE = 0x0002;
private const int SWP_NOZORDER = 0x0004;
private const int SWP_NOACTIVATE = 0x0010;
private const int SWP_FRAMECHANGED = 0x0020;
[DllImport("user32.dll")]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int
dwNewLong);
[DllImport("user32.dll")]
private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter,
int X, int Y, int cx, int cy, uint uFlags);
IntPtr hWnd = this.panel1.Handle;
int style = GetWindowLong(hWnd, GWL_EXSTYLE);
SetWindowLong(hWnd, GWL_EXSTYLE, (style | WS_EX_DLGMODALFRAME));
SetWindowPos(hWnd, IntPtr.Zero, 0, 0, 0, 0, (SWP_FRAMECHANGED | SWP_NOSIZE |
SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE));
--
Tim Wilson
..Net Compact Framework MVP
message news
[email protected]...
Hi,
I seems not to find how to change borderstyle of a panel so that it is not
sunken, but raised. I only find a 3d setting in obejct inspector... Someone
knows this ?