> Windows API
> Manually drawing a window’s caption bar
Manually drawing a window’s caption bar
Ever thought of drawing a window’s caption by using an API call. You might have a custom window and you would like to draw it’s caption like window’s would do!
So for this purpose use DrawCaption.
BOOL DrawCaption( HWND hwnd, // handle to window
HDC hdc, // handle to device context
LPCRECT lprc, // rectangle to draw into
UINT uFlags // drawing options );
Following flags specifies how the caption bar is to be drawn. This is real cool, we can really draw a real caption. 😉
||The function uses the colors that denote an active caption.
||Windows XP: If set, the function draws the buttons in the caption bar (to minimize, restore, or close an application).
||Windows 98/Me, Windows 2000/XP: When this flag is set, the function uses COLOR_GRADIENTACTIVECAPTION (if the DC_ACTIVE flag was set) or COLOR_GRADIENTINACTIVECAPTION for the title-bar color.If this flag is not set, the function uses COLOR_ACTIVECAPTION or COLOR_INACTIVECAPTION for both colors.
||The function draws the icon when drawing the caption text.
||The function draws the caption as a button.
||The function draws a small caption, using the current small caption font.
||The function draws the caption text when drawing the caption.
This is just a copy paste from MSDN. Take a look at DC_BUTTONS, DC_ICON, DC_TEXT, DC_ACTIVE, DC_GRADIENT flags. You should be now knowing how to draw inactive caption bars, caption bars with buttons, gradient caption, caption with text etc.
Drawing caption using themes requires a different approach. We’ve got to use DrawThemeBackground API. Part ids for e.g. can be WP_CAPTION etc. If there is a better way tell me. 🙂