The header is implemented as a simple WTL header window. The WTL protocol for headers and footers is quite simple: the frame window sends an empty WM_SIZE message (both width and height are set to zero) to the header and footer signaling these to position themselves in the main frame client rectangle. The remaining space will be occupied by the child view window.
Implementing this protocol is quite simple: handle the WM_SIZE message and reposition the header at the top of the main frame:
void CTouchHeader::OnSize(UINT nType, CSize size)
if(size.cx == 0 && size.cy == 0)
rc.bottom = rc.top + m_cyHeader;
The m_cyHeader variable contains the height in pixels of the header. Now, you just need to paint the header with your favorite gradient. Painting the text with the embossed look is also a simple task: you just need to paint it twice in different colors, offsetting the second painting by one or two pixels down. You get the best effect by painting first with a darker color.
As of this implementation, you don't get a very smart header control: it just paints the text it is given. However, we can make this text change according to some application context just like when you switch views. In the sample code below, the header is always present between view switches and the CChildViewManager merely asks each CChildView that is brought into view to update the header text through the virtual SetupTouchHeader function.
Now that this is in place, we can add more features to the header and make it more useful for the whole UI...
Sample code: CrypSafe07.zip (345 Kb)