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.
Stoitcho Goutsev (100) - 11 Jul 2006 13:48 GMT
Anze,
According to the docs lParam contains pointer to NCCALCSIZE_PARAMS struct
only if the wParam is TURE - that means non-zero. Your codition is reversed.
This might be the reason for the exception you are getting.
form MSDN:
...
If wParam is TRUE, lParam points to an NCCALCSIZE_PARAMS structure that
contains information an application can use to calculate the new size and
position of the client rectangle.
...

Signature
HTH
Stoitcho Goutsev (100)
> Hi!
>
[quoted text clipped - 30 lines]
>
> I would really appriciate any suggestions on this topic.
Anze V - 11 Jul 2006 14:09 GMT
Stoitcho,
thanks for your reply. I've tried fixing the condition but in that case the
client area gets strecthed across the whole form. I was wondering if you
might have an example handy that would accomplish this?
Thanks again!
With regards,
Anze
> Anze,
>
[quoted text clipped - 43 lines]
> >
> > I would really appriciate any suggestions on this topic.
Stoitcho Goutsev (100) - 12 Jul 2006 16:07 GMT
Anze,
I haven't work on that, but if you google the ng for WM_NCCALCSIZE you will
probably find some sample code. I found this thread, but there are probably
more
http://groups.google.ca/group/microsoft.public.dotnet.framework.windowsforms.con
trols/browse_thread/thread/aa5a5a9ac6bf86d0/faaf0883cc47938d?lnk=st&q=WM_NCCALCS
IZE+group%3Amicrosoft.public.dotnet.*&rnum=6&hl=en#faaf0883cc47938d

Signature
HTH
Stoitcho Goutsev (100)
> Stoitcho,
>
[quoted text clipped - 61 lines]
>> >
>> > I would really appriciate any suggestions on this topic.