Re: Modifying windows layout(title bar)
- From: Tom Spink <tspink@xxxxxxxxx>
- Date: Thu, 05 Oct 2006 12:22:06 +0100
Jon Slaughter wrote:
I'm tryign to display my own title bar. I've created a window without one
but with a menu. The menu though is located in the upper left corner and I
need to move it down. I need to set the client windows location but I
can't seem to get the menu to move as it always starts at the upper left
of the form. I want basically to have the form work exactly like its
suppose to but implement my own title bar. i.e., I don't want to have to
position the menu manually as this is not done when I add a title bar to
the form.
But no matter what I try the menu always just ends up in the starting in
the upper left corner. I'm sure I can set the menu's location manually but
I want it to use the same feature it does when windows handles the title
bar.
I guess what I'm asking is how does window create a title bar for the form
so that the menu bar or client area does not interfer with it? If I set
the client area to be something > 0 of the non-client area I still get the
same results.
i.e.
I create a class that inherits Windows.Forms.
I create a new property ClientRectangle that is suppose to override the
original so I can set it.
I then set it to be something such as (20,40,100,100). Hence the menu
should, if this worked properly, paint itself in the client area and start
at 20,40 and not 0,0
What am I doing thats wrong? I just want to get the menu's location(the
upper right corner of the menu) to give me room to paint my title bar. But
I want to do this transparently and in the same fashion that windows does
it.
Thanks,
Jon
Hi Jon,
Now, I must admit I haven't used Windows for a while... but this is what I
can remember. The menu is part of the non-client area; because it's a
non-client feature. What you should be doing is leaving the Windows
title-bar in, but painting over it. For this, you need to capture the
WM_NCPAINT window message, and act on it accordingly. It's a non-trivial
process though, and you may want to look around the internet for examples
to do with painting in the non-client area.
Once you get your painting sorted out, IIRC there's a Windows API you can
use to adjust the size of the non-client area, which is certainly what
you'll need to use if your title-bar is not the same size as the standard
windows title-bar.
I did a bit of Googling, and found you this:
http://www.codeplex.com/Wiki/View.aspx?ProjectName=CustomerBorderForm
It may be a useful starting point.
Good Luck!
--
Hope this helps,
Tom Spink
Google first, ask later.
.
- Follow-Ups:
- Re: Modifying windows layout(title bar)
- From: Jon Slaughter
- Re: Modifying windows layout(title bar)
- References:
- Modifying windows layout(title bar)
- From: Jon Slaughter
- Modifying windows layout(title bar)
- Prev by Date: Re: Eventhandlers, C#, VS2005
- Next by Date: Re: Installing a Windows Service programmatically
- Previous by thread: Modifying windows layout(title bar)
- Next by thread: Re: Modifying windows layout(title bar)
- Index(es):
Relevant Pages
|