0

Does anyone know which API that Windows uses to draw the window title in Win 7(Aero theme) and Win 8? I've tried to check with API Monitor tool, but don't see any API to draw the title.

Please advise.

Thanks.

duongkha
  • 71
  • 6

1 Answers1

4

It's been a long time since I did these things, but just googling it (three search phrase attempts) I ended up at DrawFrameControl.

Disclaimer: haven't tested.


Update: as noted in the comments DrawFrameControl won't do the job. And simple testing indicates that neither will DrawCaption. Apparently one has to use the theme functionlity, for which I found an example of drawing a window caption at (http://msdn.microsoft.com/en-us/library/windows/desktop/bb688195%28v=vs.85%29.aspx#appendixb). Essentially this code uses GetThemeSysFont to obtain the caption font and then DrawThemeTextEx to draw the caption.

New disclaimer: haven't tested the GetThemeSysFont plus DrawThemeTextEx combo, since this turned into quite a bit of work!

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Cheers and hth. - Alf
  • 142,714
  • 15
  • 209
  • 331
  • 1
    I'm guessing the insta-downvote was for lack of research; I popped a flag for the same reason. A quick search comes up with results like [this SO topic](http://stackoverflow.com/questions/7673040/winapi-create-resizable-window-without-title-bar-but-with-minimize-maximize-cl), which mentions `DrawFrameControl`, or [this topic](http://stackoverflow.com/questions/3822609/documentation-and-api-samples-for-drawing-on-windows-aero-glass-dwm-gdi-gdi) which is all about DWM resources. +1 for you because I still agree with the general principle of not downvoting what you don't understand. – cf- Mar 25 '14 at 14:49
  • How can you tell that Windows uses that API in the setting outlined in the Q? – David Heffernan Mar 25 '14 at 19:06
  • @DavidHeffernan: There's no reason to believe that Windows uses its public APIs to do internal stuff. Rather the public API probably calls an internal API that's also used internally. The difference, though, is mostly academic: it doesn't affect what API to use yourself. – Cheers and hth. - Alf Mar 25 '14 at 19:17
  • *Disclaimer: haven't tested.* Well you should. Because `DrawFrameControl` is well wide of the mark. You cannot get `DrawFrameControl` to draw anything that looks like the Windows 7 or 8 caption bar. – David Heffernan Mar 25 '14 at 19:56
  • @DavidHeffernan: oh, thanks. what do you use then? – Cheers and hth. - Alf Mar 25 '14 at 19:59
  • I don't know. I don't think there are public APIs for that anymore. Not since Windows went themed. You can use DrawFrameControl for Win95 style drawing. – David Heffernan Mar 25 '14 at 20:02
  • @DavidHeffernan: argh. okay i'll check. – Cheers and hth. - Alf Mar 25 '14 at 20:11
  • Hm, I've checked out `DrawCaption`, and that's not it either. :( – Cheers and hth. - Alf Mar 25 '14 at 21:02
  • As I know DrawThemeTextEx maybe the API used to draw the window titlte, but I use Rohitab API Monitor to check and do not see this API called. Simply check with Notepad in Win 7 and 8. – duongkha Mar 26 '14 at 03:26