38

Now Im customizing title bar of my application. My aim is to add one extra button on title bar. Im my previous question people have adviced me the way I can customize non client area. Thats works perfectly except one small thing - glowing! I can draw glowing in nonclient area but I cannot make it spreads out of the window. I also cant find any resource about this subj.

I looked into this sample and made my own test app for investigating non client drawing facilities. Screen shot of my app's window:

my app's window

So you can see that system button glows out of the windows when my is clipped by borderframe.

For example, Skype's window have four custom buttons in title bar and they can "glow" out of the window frame:

Skype's window

Can anybody advise me to find out the way to draw button's glowing out of the window?
Thanks in advance!

[EDIT]
Thank you everybody for answers!

Community
  • 1
  • 1
Anton Semenov
  • 6,227
  • 5
  • 41
  • 69
  • 2
    For all that nauseating UI, the Skype window's non-client area leaves me with an unusually positive impression. – BoltClock Apr 12 '11 at 13:18
  • @BoltClock: I was inspired to customize my app's window exactly by Skype – Anton Semenov Apr 12 '11 at 13:39
  • @Anton: I should play with the NC area in my app too :) – BoltClock Apr 12 '11 at 14:16
  • "For example, Skype's window have four custom buttons in title bar" Is it possible that Skype is therefore drawing the whole UI, (including the shadows) rather than just the buttons? – Random832 Apr 13 '11 at 13:29
  • @Random832: Hmmm, I did not thought about this from that point of view. I have vague suppositions that this very likely. Thank you! Do you know the way to check this? – Anton Semenov Apr 13 '11 at 13:46
  • 1
    Some things are harder than they look. For example a long time ago I had to go through tons of articles and codes to draw a string with glow effect (like in the title bar) on the glass. I'm sure there's a way to do this but I don't think it would be that easy since it has to be working with WDM - Maybe contacting the Skype team would help you better. – Alireza Noori Apr 13 '11 at 23:55
  • @Anton: Did you actually manage to accomplish this "outside the window glow effect" based on the answers you got? I'd really like to see some working code for this, if you have any. :-) – Alex May 26 '11 at 09:10
  • @Alex: No, unfortunately no. Now I think that's not possible in standard way. May be the solution might be found after look inside `dwmapi.dll` but it's not legal way, so I didn't try it – Anton Semenov May 26 '11 at 09:21
  • 2
    Btw Chromium now does this (it adds a "sign in" button) – paulm Dec 13 '14 at 02:01
  • @paulm any ideas how Chromium is doing this? – Misiu Jan 28 '15 at 08:44
  • No idea, you'd have to have a dig around in the code or maybe ask on the dev blog – paulm Jan 29 '15 at 00:52

3 Answers3

14

Skype cheats it, and has a little sliver along the top of their window; where they can draw it.

You can see it with Process Explorer to SpyXX:

enter image description here

See also

MSDN: Custom Window Frame Using DWM

Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
  • Yeah, I had some suppositions about such approach but I have been doubting till now. Thank you! – Anton Semenov Apr 21 '11 at 06:56
  • Hmmm, i noticed today that Chrome has the full-sized, actual themed buttons. Skype, on the other hand, has some custom buttons that aren't exactly the same as the theme. And Spyxx doesn't show a border above Chrome (or Office 2007, that also draws in the NC area). So there is a solution out there. i tried browsing the Chromium source, but i couldn't a WM_NCPAINT handler. – Ian Boyd May 29 '11 at 01:52
  • @Ian: Those buttons are system drawn. Such interface was created by customizing window's frame. You can read more about it here http://msdn.microsoft.com/en-us/library/bb688195.aspx – Anton Semenov May 29 '11 at 10:15
  • @Anton Semenov That's quite...undocumented. DWM just *happens* to draw system buttons - even though i never asked it to? No wonder that makes no sense - it makes no sense! – Ian Boyd Jun 01 '11 at 17:48
  • @Ian: `"even though i never asked it to"` This is not absolutely true. You have asked system about drawing system button through window styles http://msdn.microsoft.com/en-us/library/ms632600%28VS.85%29.aspx. – Anton Semenov Jun 02 '11 at 19:45
  • @Anton Semenov: A window having certain styles will cause the DWM to draw a Minimize, Maximize, or Close box in my client area? (as opposed to the the non-client area) – Ian Boyd Jun 03 '11 at 14:55
  • @Ian: This is confusion moment. Theese buttons are always drawn in nonclient area or in that place where nonclient area was before you have extend your client area. You can "Removе the Standard Frame" (as decribed in `Custom Window Frame Using DWM` article) but buttons would be still drawn, in this case you would be able to draw anything you like aroud system buttons, but system buttons would be still **drawn**. So you if you have window frame you can force WDM to draw systems buttons and in this case it does not matter have you control nonclient painting or not – Anton Semenov Jun 03 '11 at 15:51
5

I don't think it's possible to draw beyond your NC area, and I kind of doubt they are drawing the whole UI to exactly match DWM Aero effects.

Given how this looks, I wonder if they did some tricks with either the help or restore button of a CustomBorderForm, which would then get the DWM blur highlight effect "for free".

Here's the most relevant article I could find to this: http://geekswithblogs.net/kobush/articles/CustomBorderForms3.aspx

Followup - I think this custom chrome thread has more pointers to the same techniques (although different goal): Custom titlebars/chrome in a WinForms app

Community
  • 1
  • 1
holtavolt
  • 4,378
  • 1
  • 26
  • 40
3

AFAIK, this is not possible, because the area outside your window's border simply does not belong to you.

The Skype screenshot is from a custom-drawn frame that most likely extends a bit beyond the visible borders, not from an Aero Glass frame. You can tell the difference if you look carefully.

user541686
  • 205,094
  • 128
  • 528
  • 886
  • Actually, you can. It's an advanced technique, and since that area will be drawn differently in Windows 8, Windows 9, Windows 10, etc... It's opening a can of worms, and asking for lots and lots of future pain. While you can draw in the non-client area, it's not always possible to determine exactly what is there, and what the combined look of what you custom drew will look like, as years go by, and Windows-operating-systems change. – Warren P Oct 17 '11 at 15:54
  • This is perfectly possible, but fiendishly difficult. – David Heffernan Oct 16 '12 at 08:13
  • @DavidHeffernan: Would you like to share how? – user541686 Oct 16 '12 at 09:21
  • 2
    My answer here: http://stackoverflow.com/questions/8056846/how-to-draw-a-custom-caption-bar-like-the-yahoo-messenger-11 links to a couple of posts that give sample Delphi code. – David Heffernan Oct 16 '12 at 09:23
  • @DavidHeffernan: Thanks for the links. I'm taking a look at them, but from what I can tell they only tell you how to draw *in* the nonclient area (which is easy enough, just call `GetWindowDC`), not how to draw *outside* it (which is what the OP was asking for, for the shadow/glow). Am I misreading the articles? – user541686 Oct 16 '12 at 14:32
  • You have to extend the client frame into the non-client area with [`DwmExtendFrameIntoClientArea `](http://msdn.microsoft.com/en-us/library/windows/desktop/aa969512.aspx) as I understand things. – David Heffernan Oct 16 '12 at 14:33
  • @DavidHeffernan: That gets you Aero glass in the nonclient area, like in Windows Media Player and like at the bottom of that window they draw. But that doesn't have to do anything with the shadow, or with anything *outside* the window... – user541686 Oct 16 '12 at 14:38
  • 1
    *"the area outside your window's border **simply does not belong to you**"* - That's not really accurate. The area outside the window belongs to the same DirectX surface that backs your window. It may not be (easily) accessible, and doesn't belong to you, as far as ownership is concerned. But it's still there, and an inseparable part of your window. – IInspectable Sep 05 '16 at 18:29