i would like to replace the close button on the
titlebar with a picture box how do i do this
If i try and set the location.Y value of the picturebox to 0 the picturebox is placed below the titlebar, and if i give it a negative value the titlebar is drawn over it
how do i do this
thanks in advance
here is a way:
first: you need to set the window as none_border
style, so the window won't have the titlebar.
second: you can make a container object like panel docking on the top of the window to replace the titlebar.
third: process windows message to response the drag,click message to make your "titlebar" can action just like a real titlebar.
Now, you can put your "image button" onto the panel to replace the real close-button, etc...
MEMikael Ericsson (PhD)December 3, 2002 03:13 PM
What is the best way to add new buttons to the title bar of a window, given that you do want them to have the same look & feel as the standard ones (and preferaby comply with Themes)?
BRBrianMay 11, 2006 12:57 PM
I have been searching everywhere for an answer to this question and have only found others with the same question. Can anyone point us in the right direction? I want to add a button to the nonclient titlebar space of a form while still letting Windows paint the rest of the titlebar.
>What is the best way to add new buttons to the title bar of a window, given that you do want them to have the same look & feel as the standard ones (and preferaby comply with Themes)?
JKJoy K George Syncfusion Team May 29, 2006 04:30 AM
Please try the following code snippet in a derived form.
static extern IntPtr GetWindowDC(IntPtr hWnd);
protected override void OnPaint(PaintEventArgs e)
IntPtr hDC = GetWindowDC(this.Handle);
Graphics g = Graphics.FromHdc(hDC);
Brush b = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(5, 5, this.Width, 30), Color.Red, Color.Green, 45);
g.FillRectangle(b, new Rectangle(5, 5, this.Width, 30));
Using the Graphics object g you could do(paint) whatever you want in the title bar.If you want to add button use the method ControlPaint.DrawButton since, we cant place buttons directly in the title bar.