Delphi cutting glass
Asked Answered
P

2

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

Proudhon answered 23/1, 2012 at 13:56 Comment(7)
Yes, @Lama, this is what I want to do. Do you know how?Proudhon
@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 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 :)Ugh
I cannot open the link, @TLama. Why?Proudhon
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.Ugh
It happens to have a bad link day (BLD).Proudhon
It doesn't explain how to "Cut" glass, but there are some interesting things. If you find how cut glass, post the link.Proudhon
@Astervista, I know; that's why I've marked it as off topic ;) But I've been also looking around (here or here or there) but I found no solution for it. I'm pretty sure there would be an example in some C language at least on CodeProject, 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.Ugh
F
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.

Formenti answered 23/1, 2012 at 18:36 Comment(4)
But then you would have to draw the glowing edge by your own, don't you ? And if so, the question is then how ?Ugh
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: https://mcmap.net/q/742406/-irregularly-shaped-formsFormenti
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 ? Will this really do the trick ?Ugh
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.Formenti
S
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

Sofia answered 24/1, 2012 at 4:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.