18

I'm using Delphi XE2, and I like glass effects, and I want to "cut" glass as in Windows 7 tablet tools. If you also know how cut a button I'll be happy if you tell me how.

enter image description here

Thanks

Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
Astervista
  • 211
  • 1
  • 4
  • Yes, @Lama, this is what I want to do. Do you know how? – Astervista Jan 23 '12 at 16:11
  • @Astervista, no but I'll try to find it out because it's interesting question and it's already in my favorites :) OT, [`here's`](http://weblogs.asp.net/kennykerr/archive/2006/08/10/Windows-Vista-for-Developers-_1320_-Part-3-_1320_-The-Desktop-Window-Manager.aspx) one interesting reading about Desktop Window Manager and some of its functions, but I don't think there's an answer to your question there (that's why OT :) – TLama Jan 23 '12 at 16:18
  • I cannot open the link, @TLama. Why? – Astervista Jan 23 '12 at 17:06
  • Sorry, I have a bad day for posting links. This one has been modified when I've posted it as a comment link (don't know why, but you can try it by your own :) So here it is through [`TinyURL`](http://tinyurl.com/DesktopWindowManager). – TLama Jan 23 '12 at 17:12
  • It happens to have a bad link day (BLD). – Astervista Jan 23 '12 at 17:46
  • It doesn't explain how to "Cut" glass, but there are some interesting things. If you find how cut glass, post the link. – Astervista Jan 23 '12 at 17:55
  • @Astervista, I know; that's why I've marked it as off topic ;) But I've been also looking around ([`here`](http://stackoverflow.com/q/6438076/960757) or [`here`](http://stackoverflow.com/q/7813797/960757) or [`there`](http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/7835d493-5967-4372-b347-32ad46622250/)) but I found no solution for it. I'm pretty sure there would be an example in some C language at least on [`CodeProject`](http://www.codeproject.com/), but nothing I can find. Maybe I'm missing something or it's undocumented feature; hard to say, but I don't want to give it up. – TLama Jan 23 '12 at 18:53

2 Answers2

5

Drawing in the top area is simply a matter of using a glass frame and painting in the non-client area, or alternatively, using the DwmExtendFrameIntoClientArea API.

The best code sample I have seen for this is the VCL "Ribbon" control, which provides a "QAT" (quick Access toolbar) area, painted in the "non client area".

Note that the author has to think not only about how to render when Vista/Win7 systems which have Glass ON, but also has to decide how to render on WinXp, Win7 and Vista when the Themes engine is off. There is quite a bit of logic in the Vcl.Ribbon.pas (or just Ribbon.pas if you're in XE or earlier) unit dedicated to that.

Look at procedure TCustomRibbonQuickAccessPopupToolbar.NCPaint(DC: HDC); in the Vcl Ribbon sources.

Drawing a non-rectangular "extended area" that protrudes from the bottom is probably a matter of applying a custom window clipping region.

Warren P
  • 65,725
  • 40
  • 181
  • 316
  • But then you would have to draw the glowing edge by your own, don't you ? And if so, the question is then how ? – TLama Jan 24 '12 at 11:46
  • 1
    Not if you follow the modern techniques. I believe daven's answer links you to that part of it, see the comments here about SetWindowRgn and transparent color values: http://stackoverflow.com/questions/3572342/irregularly-shaped-forms – Warren P Jan 24 '12 at 14:02
  • Any example would explain more than thousand of words. Sorry I'm quite lame at this and have no clue how to do it. You mean to use [`UpdateLayeredWindow`](http://msdn.microsoft.com/en-us/library/windows/desktop/ms633556%28v=vs.85%29.aspx) ? Will this really do the trick ? – TLama Jan 24 '12 at 14:09
  • OP asked more than one question, as such, there is no one code example that's going to help you. Your individual questions are basically duplicates. No point for me working on such a limited-use question, when there are already links from this question to exactly those examples. Non-client-paint code is so painfully difficult that I can only suggest studying Ribbon.pas, which is closed-source commercial code that comes with Delphi and cannot be legally posted anywhere. – Warren P Jan 24 '12 at 17:18
0

Did you mean you want shaped forms? If so

Irregularly shaped forms

could help. I imagine this will work on Windows 7 (note Remy's comment in the answer).

hth

Community
  • 1
  • 1
daven11
  • 2,905
  • 3
  • 26
  • 43