We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

changing the control box

Thread ID:

Created:

Updated:

Platform:

Replies:

1781 Nov 26,2002 07:49 AM UTC May 29,2006 09:30 AM UTC WinForms 4
loading
Tags: FAQ
Joe
Asked On November 26, 2002 07:49 AM UTC

hi 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 regards

UESTC
Replied On December 1, 2002 04:29 AM UTC

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...

Mikael Ericsson (PhD)
Replied On December 3, 2002 08:13 PM UTC

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)? Regards, M

Brian
Replied On May 11, 2006 05:57 PM UTC

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)? > > >Regards, >M

Joy K George [Syncfusion]
Replied On May 29, 2006 09:30 AM UTC

Hi Please try the following code snippet in a derived form. [System.Runtime.InteropServices.DllImport("user32.dll")] static extern IntPtr GetWindowDC(IntPtr hWnd); protected override void OnPaint(PaintEventArgs e) { base.OnPaint(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. Regards, Joy

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;