G
Guest
Hi!
I am trying to make a custom size title-bar in the non-client area of the
form. I've tried hooking to the NCCALCSIZE message with this code:
case (int)Native.NativeMethods.WindowMessages.WM_NCCALCSIZE:
if (m.WParam == IntPtr.Zero)
{
// get the NCCALCSIZE parameters
NativeMethods.NCCALCSIZE_PARAMS csp;
// Marshal them from the pointer
csp =
(NativeMethods.NCCALCSIZE_PARAMS)Marshal.PtrToStructure(m.LParam,
typeof(NativeMethods.NCCALCSIZE_PARAMS));
// Resize the client area to make more room above
csp.rectBeforeMove.top-= csp.rectBeforeMove.top/ 2;
Marshal.StructureToPtr(csp, m.LParam, false);
}
else
{
base.WndProc(ref m);
}
return;
However, it just says that I am trying to read or write into a protected
memory. If i modify any other value, i.e. right, left or bottom of the same
rectangle, it works OK yet there are no changes. I also tried changing the
other two rectangles, but the result is never what I need.
I would really appriciate any suggestions on this topic.
I am trying to make a custom size title-bar in the non-client area of the
form. I've tried hooking to the NCCALCSIZE message with this code:
case (int)Native.NativeMethods.WindowMessages.WM_NCCALCSIZE:
if (m.WParam == IntPtr.Zero)
{
// get the NCCALCSIZE parameters
NativeMethods.NCCALCSIZE_PARAMS csp;
// Marshal them from the pointer
csp =
(NativeMethods.NCCALCSIZE_PARAMS)Marshal.PtrToStructure(m.LParam,
typeof(NativeMethods.NCCALCSIZE_PARAMS));
// Resize the client area to make more room above
csp.rectBeforeMove.top-= csp.rectBeforeMove.top/ 2;
Marshal.StructureToPtr(csp, m.LParam, false);
}
else
{
base.WndProc(ref m);
}
return;
However, it just says that I am trying to read or write into a protected
memory. If i modify any other value, i.e. right, left or bottom of the same
rectangle, it works OK yet there are no changes. I also tried changing the
other two rectangles, but the result is never what I need.
I would really appriciate any suggestions on this topic.