Custom Caption Painting

Actually, what I am most interested in, is custom caption buttons.  What I need to know, is how to implement a button which is functionally equivalent to the close, minimize, and maximize buttons, but which has a different bitmap associated with it.  I know the standard caption buttons are drawn with the DrawFrameControl function, but I see no provisions in this function for a user drawn button.  Also, how does one deal with the fact that the size of the title bar can be changed.  Does this rule out using a bitmap to paint the button?  What I would like to have, is an up or down arrow which would allow the user to roll up the client area to 0 in the case of the up arrow, or roll it back to its previous state in the case of the down arrow.  I believe I have seen this functionality in some of Corel Draw's tool bars.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dereklAuthor Commented:
Edited text of question.
First, leave the close, max, and min buttons alone. These are standard and you will only confuse users by altering their appearance.

See :

If you read thru there, you'll never consider changing Windows standard features again! LOL

Re the arrow to roll the client area up and down. Neat idea. Why not put these on a toolbar?
At the handler for the new button, use SendMessage to send WM_SYSCOMMAND to the window.  Use the following for wParam:

SC_CLOSE for Close
SC_MAXIMIZE for Maximize
SC_MINIMIZE for Minimize
SC_RESTORE for Restore

The lParam in this case is not used.

Hope it helps!


(I wish the email notification check mark in this box would remain checked as default, I always forget to check the checkbox)

Paul DiLascia wrote a CCaptionPainter class that makes painting your own title bar a snap (you only worry on painting, not anything else). It appeared in the June 1997 issue of MSJ.

You can download the code from or read the article in MSDN.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.