« New Standard Keyboards? You gotta be kiddin' me!DDD 4 feedback wanted »

Custom handling of the non-client area

07/12/06

Permalink 11:58:16 am
Categories: General, Programming, .NET

Custom handling of the non-client area

I recently saw a post in an MS newsgroup and as I had an example that I wrote earlier, I just thought I’d make it available. What this does is simple: it implements custom handling of the non-client area of a window. The non-client area is, normally, the area of a window that is not part of the client area (duh!), like that used for adornments, window buttons, borders, that kind of thing.

While the user moves the mouse over a window’s area, Windows sends messages to figure out which part of the window is currently underneath the mouse cursor, and if it finds certain areas, it handles the corresponding functionality itself. By overriding the default behaviour and returning the right values for these messages, it’s therefore easy to have Windows activate the resize behaviour of the right border, for instance, although the mouse cursor is actually not over the right border at that moment (or even if there isn’t any right border at all).

My sample program draws some rects on its client area that “pose” as the borders of the window, as well as the title bar and the resize rect in the lower right hand corner. Looks like this:

CustomNCHandling

Here’s the download, which includes source code as well as a compiled version of the application, in case you just want to try it quickly.

CustomNCHandling.zip (15 KB)

2 comments

Comment from: Carlos Simões
This was very helpful.
Thank you.
03/29/07 @ 14:37
Comment from: Juctor
Thank you Oliver, this short article helped me to handle easily any mouse event -coming from the client area or not- in the OnMouseDown/Up/Move methods.
05/28/09 @ 09:02

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
Please complete the song title below. Hint: enter 'h', 'e', 'a', 'v', 'e', 'n'
antispam test

Enter your email address:

Search

Oliver
MVP logo
March 2010
Sun Mon Tue Wed Thu Fri Sat
 << <   > >>
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31