110,533
社区成员
发帖
与我相关
我的任务
分享
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.Style = cp.Style | 0x20000 | 0x00040000;//允许最小化操作;
return cp;
}
}
if (m.WParam != IntPtr.Zero)
{
NCCALCSIZE_PARAMS rcsize = (NCCALCSIZE_PARAMS)Marshal.PtrToStructure(m.LParam, typeof(NCCALCSIZE_PARAMS));
AdjustClientRect(ref rcsize.rcNewWindow);
Marshal.StructureToPtr(rcsize, m.LParam, false);
}
else
{
RECT rcsize = (RECT)Marshal.PtrToStructure(m.LParam, typeof(RECT));
AdjustClientRect(ref rcsize);
Marshal.StructureToPtr(rcsize, m.LParam, false);
}
public struct RECT
{
public int Left; //最左坐标
public int Top; //最上坐标
public int Right; //最右坐标
public int Bottom; //最下坐标
}
struct NCCALCSIZE_PARAMS
{
public RECT rcNewWindow;
public RECT rcOldWindow;
public RECT rcClient;
IntPtr lppos;
}
private void AdjustClientRect(ref RECT rc)
{
rc.Left += 6;
rc.Right -= 6;
rc.Top += 6;
rc.Bottom -= 6;
}
case 0x0001:
case WM_NCCALCSIZE:
case WM_NCACTIVATE:
NCCALCSIZE_PARAMS rcsize = (NCCALCSIZE_PARAMS)Marshal.PtrToStructure(m.LParam, typeof(NCCALCSIZE_PARAMS));
GetWindowRect(m.HWnd, ref rcsize.rcOldWindow);
SetWindowPos(m.HWnd,
0,
rcsize.rcOldWindow.Left, rcsize.rcOldWindow.Top,
rcsize.rcOldWindow.Right - rcsize.rcOldWindow.Left,
rcsize.rcOldWindow.Bottom - rcsize.rcOldWindow.Top,
0x20);
break;
改为C#的代码后,只出现了右边和下边的边框,应该只有一个像素,左边和右边边框没了,且内容全部都是透明的,我这个页面在右上角有个关闭按钮,我点了下,也是有效的,只是看不见
case WM_CREATE:
case WM_NCCALCSIZE:
case WM_NCACTIVATE:
{
RECT rcClient;
GetWindowRect(hWnd, &rcClient);
// Inform the application of the frame change.
SetWindowPos(hWnd,
NULL,
rcClient.left, rcClient.top,
rcClient.right - rcClient.left, rcClient.bottom - rcClient.top,
SWP_FRAMECHANGED);
}break;