3
votes

I'm trying to figure out how to draw a custom button on the caption bar of windows when using the Aero theme in Vista or Win7. I need to apply this to a number of different applications without changing the original code, so this will be in a hook procedure. Since I can't change the original code, I can't use DwmExtendFrameIntoClientArea.

I'm pretty sure this can be done, or at least faked really well, because I've seen an app that can do this. I've taken a pretty close look at various windows while this other app is running, and I don't believe they're altering the window style or extending the frame into the client area.

As a test, I tried to use the WM_NCPAINT message to paint something onto the caption bar. When the Aero theme is active, nothing I paint will appear. If I get a DC for the entire screen instead of just the window, then I can "paint" onto the caption bar, but of course, it's really being painted to the screen. There are all kinds of problems with that approach, so that doesn't work. If anyone has any good ideas, or even good hints, I'd really appreciate the help!

1

1 Answers

0
votes

Since you can't extend the client area, one technique is to create a floating WS_EX_LAYERED child window, with the owner set to the top level window so it stays above just that window.

You can hook the WndProc of the target window for WM_MOVE and WM_SIZE messages.