By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,107 Members | 1,216 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,107 IT Pros & Developers. It's quick & easy.

How do you paint the titlebar of a form?

P: n/a
What would be the easiest way of painting a titlebar in a form?

Setting the background property of a derived System.Windows.Forms.Form only
paints the client area. I need to paint the frame as well but when I tried

this.ParentForm=System.Drawing.Color.Crimson;

I get an error: Property or Indexer cannot be assigned to -- it is read
only.
So is there a way to override this read only property for a forms frame?
Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Gregory,

If you want to paint the titlebar (or paint on it), you need to handle
the WM_NCPAINT message in the WndProc method on your form. This message is
sent when the frame of a window needs to be painted.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Gregory Hawke" <ab****@hotmail.com> wrote in message
news:ei**************@TK2MSFTNGP11.phx.gbl...
What would be the easiest way of painting a titlebar in a form?

Setting the background property of a derived System.Windows.Forms.Form only paints the client area. I need to paint the frame as well but when I tried
this.ParentForm=System.Drawing.Color.Crimson;

I get an error: Property or Indexer cannot be assigned to -- it is read
only.
So is there a way to override this read only property for a forms frame?

Nov 15 '05 #2

P: n/a
Are you from a C++ background?

The Titlebar colors are determined by system settings or themes. They apply
to all windows and cannot easily be manipulated. You would have to draw
directly to the frame during NC paint events or replace the titlebar with a
custom control and implement the windowing functionality yourself. Painting
in the non-client area would be easiest, when you remove the frame from a
window it strips a lot of Windows functionality away with it.

I implemented a custom titlebar control in VB6, but have not yet ported it
to .NET.

HTH;
Eric Cadwell
http://www.origincontrols.com
Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.