Modifying windows layout(title bar)

J

Jon Slaughter

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
 
T

Tom Spink

Jon said:
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!
 
J

Jon Slaughter

Tom Spink said:
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.

I thoguht about that but then I thought that it would be a waste and my
non-client area generated from the title bar would be fixed to what ever the
size of the title bar is.
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.

Why not just use that API without the form having at title bar? If the menu
is working in the NC area then there must be a way to move it because this
is exactly what windows does behind the scenes anyways.
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.

Thanks, looks like it might contain what I need
Jon
 
T

Tom Spink

Jon said:
I thoguht about that but then I thought that it would be a waste and my
non-client area generated from the title bar would be fixed to what ever
the size of the title bar is.


Why not just use that API without the form having at title bar? If the
menu is working in the NC area then there must be a way to move it because
this is exactly what windows does behind the scenes anyways.


Thanks, looks like it might contain what I need
Jon

Hi Jon,
Why not just use that API without the form having at title bar? If the
menu is working in the NC area then there must be a way to move it because
this is exactly what windows does behind the scenes anyways.

You may be absolutely right... I can't try it out, so if you do, let us know
how it turns out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top