Click here to Skip to main content
15,884,628 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to customize my window. I want to paint title bar, window borders and close, minimize buttons myself. I searched through internet looking for a tutorial or a sample application that does the job, but nothing was found.

I know that i have to handle WM_NCPAINT, WM_NCCALCSIZE ,... messages myself. Even MSDN does not have a tutorial about handling a window's nonclient area.

I just need a sample application, some source code, a tutorial or anything that teaches how to handle the non client area of a window (mainly painting). It does not matter for me if it's MFC or Win32 as long as it does the job.

Cheers !
Posted
Comments
Sergey Alexandrovich Kryukov 19-Oct-13 1:54am    
Why do you think you need a tutorial on each simple topic. What's wrong with just reading the original documentation?
—SA
Codexzy 19-Oct-13 1:57am    
Documentation about Nonclient area is not so informative. It doesn't help much, really. :)
Sergey Alexandrovich Kryukov 19-Oct-13 18:35pm    
Frankly, I did not touch those areas for a long time, but I remember that when I did, everything worked according to documentation, from the first attempt. This part of API closely resembles the one for client area...
—SA

You will find lots of examples in so-called skinning libraries. For example:
A picture based skin system and MPEG decoder[^]
Just search under "skin" in CodeProject and you will find lots of example code.

But as Sergey already pointed out: Why do you look for tutorials and examples if the documentation of the Windows API already tells the whole story. Just study the API documentation, particularly the part about the update region.
 
Share this answer
 
Comments
pasztorpisti 19-Oct-13 10:53am    
+5
nv3 19-Oct-13 11:42am    
Thanks!
Sergey Alexandrovich Kryukov 19-Oct-13 18:37pm    
Should be useful. Skin software is the field where non-client imagine is retouched on a regular basis. My 5.
—SA
nv3 20-Oct-13 5:51am    
Thank you, Sergey.
 
Share this answer
 
Comments
pasztorpisti 19-Oct-13 10:54am    
5.
Captain Price 19-Oct-13 22:21pm    
thanks pasztorpisti.
Sergey Alexandrovich Kryukov 19-Oct-13 18:37pm    
Looks interesting enough, should be useful, a 5.
—SA
Captain Price 19-Oct-13 22:21pm    
thanks Sergey.
Managing the nonclient area yourself is indeed a not too well documented and messy topic and there are a lot of pitfalls like you have to hide the borders when the window is maximized... If all you want is a custom drawn window (like that of a typical fancy media player) then I recommend you the following: Often its much easier to create a window without a single pixel of nonclient area, just create the window with WM_POPUP style without caption and border/frame (optionally with system menus to be able to bring up right click menus on the taskbar) and draw/handle everything yourself. A borderless captionless WM_POPUP window is just a rectangle and every single pixel of this rectangle is part of the client area.

In some scenarios where the location of the nonclient area matters this technique isn't a good solution but in many cases it is a quite viable option. Of course with a client-area-only window you have to handle every system functionality yourself (like drawing a title bar [somewhere] and moving the window when the title bar is grabbed, example to a grabbing window move operation by grabbing the client area: Using SetCapture() and ReleaseCapture() correctly (usually during a drag n' drop operation).[^]) and optional window resize or maximize features...
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 19-Oct-13 18:40pm    
Good points. I also used to recommend to go that way, without showing non-client areas at all. There is one benefit of this approach: more flexibility, less compatibility problems, in particular, complete abstraction from OS UI styles and hence, independence of them. My 5.
—SA
pasztorpisti 20-Oct-13 11:01am    
Thank you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900