How to place a control on "title bar"

Don't overlook the obvious!!! Set the form border style to NONE so there is no title bar and "fake" your own title bar drawn at the top of the client area. The code may be intensive such as drag routines, etc. but that's the simple way of doing it without getting into advanced sub-classing, etc.
 
Neal said:
Don't overlook the obvious!!! Set the form border style to NONE so there is no title bar and "fake" your own title bar drawn at the top of the client area. The code may be intensive such as drag routines, etc. but that's the simple way of doing it without getting into advanced sub-classing, etc.

It says we think exactly the same, except i don't explained the idea/concept ;)

Cheers ;)
 
Thank you for your answers. I actually have mad a custom title bar, the problem is that the user have a choice to change the color of the application to mach the windows color. In addition I would not know what kind of windows the user will use, so it is hard to design different title bars with different colors. My application has small interface with a textbox and 3 buttons which sits on the title bars of different applications. If you insall the attach file (.exe) you will see what I mean. Again thanks a lot for time. :)
 
First, it is poor form to attach an executable file anyway. You may be trust-worthy but we don't know that.

Second, you can get the colors used for various aspects of windows using the SystemColors class. For instance, the current color of the title bar can be accessed via SystemColors.ActiveCaption. The members of SystemColors can be used as colours so if you are using a Label to represent your title bar you simply use

titleBarLabel.BackColor = SystemColors.ActiveCaption

Note that this is for the active window. There is an InactiveCaption colour too, as there is an ActiveCaptionText colour and an InactiveCaptionText colour. It can get complex if you want to do it properly this way.

As a further point of extreme interest, if you set the BorderStyle of a form to None, your window is not resizable and you lose all border. I read, and tested, recently that if you set the ControlBox property to False and the Text property to an empty string, you lose the title bar and the coloured border but you can still have a 3D border and your form can be resizable, depending on the BorderStyle property.
 
PLH said:
so it is hard to design different title bars with different colors

As you could see i'm dealing with pictureBox control. So, you can put/load any custom title bar (read picture) within. With little effort and using of Photoshop you'll have many title bars with different colors. Or you can change the color of picturebox as user changes backcolor respectively.

Cheers ;)
 
Back
Top