Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2006

Tip: Looking for answers? Try searching our database.

Custom title bar size in Non-client area

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Anze V - 11 Jul 2006 11:21 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.