Change the height of a specified window’s caption bar

captionmfc

I want to self-draw the caption bar of my application's window, so I decided to override OnNcPaint() methods. But I don't know how to set a different height of the caption bar. Everytime I use GetSystemMetrics(SM_CYCAPTION), it retruns the same value.

Can anyone tell me how to do it? Thank you!

Best Solution

You can't change the size of a normal Windows-drawn caption bar. That's determined by the user settings and the theme. If you're drawing things yourself, then you also define the caption dimensions yourself. You can paint whatever you want wherever you want, so you can paint your caption bar over what would normally be considered the client area. To make that extra region behave as though it's really the caption bar, handle the wm_NCHitTest message and return htCaption.

Note that GetSystemMetrics does not accept a window handle as one of its parameters. That means that it cannot return window-specific metrics. As its name suggests, it gives you system-wide metrics.

Related Question