Draw on Title Bar

Friday Dec 17th 1999 by Istvan Moldovan

Illustrates technique for drawing on a Dialog's titlebar

Many people was asking how to change the title bar of a window. Here is a small sample, which draws a color gradient on the title bar.

First, we create a simple dialog box without system menu. Then, we have to intercept the WM_NCPAINT message and set up an own hanler, which draws the title bar of the window. To draw on the title bar, we must set up a CWindowDC device context, to draw on non-client area of the window. To draw the system buttons, we use the DrawFrameControl member.

That's all!! If you don't want system menu, close or minimize button. But if we want some of these, you need to set up handlers for mouse events. (WM_NCLBUTTONDOWN, WM_NCHITTEST, WM_NCLBUTTONUP)

The small sample project draws a gradient title bar for a dialog window, with close button. (I compiled with VisualC++ 5.0)


Download demo project - 17 Kb
Mobile Site | Full Site
Copyright 2017 © QuinStreet Inc. All Rights Reserved