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

Control in non-client area of form

P: 9
How do I put a control on the non-client area of a form?

Can a component be painted onto the non-client area? (Bounds)
Dec 27 '08 #1
Share this Question
Share on Google+
10 Replies

Expert 2.5K+
P: 3,525
Google is your friend:

This looks like what I think you are wanting.
Dec 27 '08 #2

P: 9
They put it onto the non-client area of the form, and nothing looks wrong different with microsoft office (word, excel, powerpoint) or the codejock sample I got. So how did they put the control onto the non-client area of the form?
Dec 27 '08 #3

Expert 2.5K+
P: 3,525
Was the answer to your question first time you asked not what you were looking for?

You really should keep to one thread per question.
Dec 28 '08 #4

P: 9
It works, but when I put text box onto the control and type into it, anything's thats colored black will become transparent. And maximizing / restoring the window messes it up (although I'll try to solve that). So how do I not let the black color on the controls turn transparent?
Dec 28 '08 #5

Expert 2.5K+
P: 3,525

Set the text color to something other than black?

Use the resize (SizeChanged, SizeChangedComplete, etc) events to relocate the text box.
Dec 29 '08 #6

Expert 5K+
P: 7,872
Please don't double post.

You want a textbox in the title bar? Interesting.
I would have just turned off the border/titlebar and made my own at that point i think.
Is there a picture/screenshot of what you are trying to do, that link only showed a colored titlebar,which i have also never seen really.
Dec 29 '08 #7

P: 9
Here are some examples of what I'm trying to do:


and This.

Only Windows Vista can paint those windows, but somehow they got the orb and the toolbar onto the title bar. Tlhintoq, your link was what I was looking for, except for the problem I described previously. I'll do some more searching.
Dec 29 '08 #8

Expert 5K+
P: 7,872
Oh so its a vista thing, no wonder i had never seen it
Dec 29 '08 #9

P: 9
I read in this article that:

Office completely removes the non-client area, and renders everything in its client area, so it doesn't have a caption (except a fake one).

Notice how the glow and the text are different, it's because they're not rendered by the DWM.
I compared the pixels on the top left corner of Word and a program (same location, same size, same background) and it was a bit different.

If I set the text to a different color the text will still appear transparent :(
Dec 29 '08 #10

P: 9
I got it! Using the link you gave me, I overrid the WndProc property like this:

Expand|Select|Wrap|Line Numbers
  1. protected override void WndProc(ref Message m)
  2.         {
  3.             if (m.Msg == 0x83)
  4.             {
  5.                 Point point = new Point(m.LParam.ToInt32());
  6.                 m.Result = new IntPtr(-1);
  7.                 return;
  8.             }
  10.             Graphics g = Graphics.FromHwnd(Handle);
  11.             g.DrawString("String",
  12.                 new Font("Lucida Console", 10f),
  13.                 new SolidBrush(Color.Black),
  14.                 PointF.Empty);
  16.             base.WndProc(ref m);
  17.         }
Now all I have to do is to remake the buttons and resizing.
Thanks for your help. :)
Dec 30 '08 #11

Post your reply

Sign in to post your reply or Sign up for a free account.