[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.vb.general.discussion

Aero Glass Control Text Problem

F*CK

9/8/2010 8:50:00 PM

Hi Everyone.

I am using Vista, 7 Aero glass in my app. I am able to apply it using the
DwmExtendFrameIntoClientArea API, but there is a minor problem, the text on
controls appears transparent. someone suggested me that I should use

SetLayeredWindowAttributes Me.hWnd, 0, 0, LWA_COLORKEY

it works, now the text is no longer transparent but this creates another
problem. I can no longer click on the form, the mouse events gets passed
through.

anyone have a fix for this?

Thanks in advance.


' here is the code.
' a form with a command button and this code
Option Explicit

Private Const LWA_COLORKEY As Long = &H1
Private Const GWL_EXSTYLE As Long = (-20)
Private Const WS_EX_LAYERED As Long = &H80000
Private Const WS_EX_TRANSPARENT As Long = &H20&
Private Const LWA_ALPHA As Long = &H2&

Private Type tRect
m_Left As Long
m_Right As Long
m_Top As Long
m_Buttom As Long
End Type

Private Declare Function apiApplyGlass Lib "dwmapi.dll" Alias _
"DwmExtendFrameIntoClientArea" (ByVal hWnd As Long, rect As tRect) As
Long

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long) As Long

Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As
Long

Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd
As _
Long, ByVal crey As Byte, ByVal bAlpha As Byte, ByVal dwflags As Long)
As Long

Public Sub ApplyTransparency()
Dim lOldStyle As Long

lOldStyle = GetWindowLong(hWnd, GWL_EXSTYLE)
SetWindowLong hWnd, GWL_EXSTYLE, lOldStyle Or WS_EX_LAYERED
SetLayeredWindowAttributes Me.hWnd, 0, 0, LWA_COLORKEY
End Sub

Private Sub ApplyAero()
Dim GRect As tRect
Dim lngReturn As Long

GRect.m_Buttom = -1
GRect.m_Left = -1
GRect.m_Right = -1
GRect.m_Top = -1

lngReturn = apiApplyGlass(Me.hWnd, GRect)
End Sub

Private Sub Command1_Click()
Me.BackColor = vbBlack
Call ApplyTransparency
Call ApplyAero
End Sub


61 Answers

Karl E. Peterson

9/8/2010 9:33:00 PM

0

Abhishek was thinking very hard :
> I am using Vista, 7 Aero glass in my app. I am able to apply it using the
> DwmExtendFrameIntoClientArea API, but there is a minor problem, the text on
> controls appears transparent. someone suggested me that I should use
>
> SetLayeredWindowAttributes Me.hWnd, 0, 0, LWA_COLORKEY
>
> it works, now the text is no longer transparent

Yes, it is, actually. If the text is black.

> but this creates another
> problem. I can no longer click on the form, the mouse events gets passed
> through.
>
> anyone have a fix for this?

Well, I don't have that issue if use LWA_ALPHA instead.

--
..NET: It's About Trust!
http://vfre...


F*CK

9/8/2010 9:56:00 PM

0

If I use
SetLayeredWindowAttributes Me.hWnd, 0, 0, LWA_COLORKEY Or LWA_ALPHA

The whole form goes invisible.

The problem is I cant click anywhere on the form, on any control it is ok
but not on form. the mouse events pass though and instead the click goes to
the desktop or any windows behind the form. I hope you are getting what I am
trying to say.

the effect is same as described here http://support.microsoft.com...
for making translucent window.


"Karl E. Peterson" <karl@exmvps.org> wrote in message
news:i68vf1$dok$1@news.eternal-september.org...

|
| Well, I don't have that issue if use LWA_ALPHA instead.
|
| --
| .NET: It's About Trust!
| http://vfre...
|
|


Karl E. Peterson

9/8/2010 11:16:00 PM

0

Abhishek brought next idea :
> If I use
> SetLayeredWindowAttributes Me.hWnd, 0, 0, LWA_COLORKEY Or LWA_ALPHA
>
> The whole form goes invisible.
>
> The problem is I cant click anywhere on the form, on any control it is ok
> but not on form. the mouse events pass though and instead the click goes to
> the desktop or any windows behind the form. I hope you are getting what I am
> trying to say.
>
> the effect is same as described here http://support.microsoft.com...
> for making translucent window.

Yeah, I get it. Not sure what the answer is, though. What's the
purpose of having a "sheet of glass" for a form and it's controls,
anyway? To me, that'd be something you'd toggle on if you wanted to go
into some sort of stealth mode. IOW, it seems like it's working as
intended. I'd definitely have to read more about this function to have
any good suggestions. Sorry...

--
..NET: It's About Trust!
http://vfre...


F*CK

9/8/2010 11:42:00 PM

0

What's the
| purpose of having a "sheet of glass" for a form and it's controls,

To make my app look good, nothing more. but as of now I am forced to use my
own controls instead of other controls.

my aim is to use aero glass which causes problem with Control Text.


| To me, that'd be something you'd toggle on if you wanted to go
| into some sort of stealth mode. IOW, it seems like it's working as
| intended.

the events should only pass though when we use

SetWindowLong Me.hwnd, GWL_EXSTYLE, lOldStyle Or WS_EX_LAYERED Or
WS_EX_TRANSPARENT

Instead of

SetWindowLong Me.hwnd, GWL_EXSTYLE, lOldStyle Or WS_EX_LAYERED

but I didn't use WS_EX_TRANSPARENT, then why its happening.



Karl E. Peterson

9/8/2010 11:54:00 PM

0

Abhishek pretended :
> What's the
>> purpose of having a "sheet of glass" for a form and it's controls,
>
> To make my app look good, nothing more. but as of now I am forced to use my
> own controls instead of other controls.
>
> my aim is to use aero glass which causes problem with Control Text.

Have you seen other apps take this approach?

--
..NET: It's About Trust!
http://vfre...


F*CK

9/9/2010 12:27:00 AM

0

I have made my own here is it.
http://img188.imageshack.us/img188/7540/screen...

DwmExtendFrameIntoClientArea is simple, we pass a rect and it will make it
glass, if we pass -1 in rect then whole window will be glass.


"Karl E. Peterson" <karl@exmvps.org> wrote in message
news:i697nk$i37$1@news.eternal-september.org...
|
| Have you seen other apps take this approach?
|
| --
| .NET: It's About Trust!
| http://vfre...
|
|


Karl E. Peterson

9/9/2010 12:42:00 AM

0

Abhishek explained on 9/8/2010 :
>> Have you seen other apps take this approach?
>
> I have made my own here is it.
> http://img188.imageshack.us/img188/7540/screen...
>
> DwmExtendFrameIntoClientArea is simple, we pass a rect and it will make it
> glass, if we pass -1 in rect then whole window will be glass.

I didn't ask because I didn't think it was possible. I tried your
code, and it "worked", more or less. I asked because I wonder if it's
intended to *really* work, all the way? I've never seen another app do
this, so I was wondering if you were just experimenting. IOW, are you
trying to replicate something you feel ought to work, or something
you've actually *seen* working?

--
..NET: It's About Trust!
http://vfre...


F*CK

9/9/2010 1:09:00 AM

0

The only app I have seen using aero is Windows Media Player 11 in Vista. I
have this flv player in which the whole form is glassed (throughout its
runtime :D) and on it I placed all the controls. I want to use some VB
controls *but* the text appears transparent so I cant. so I am looking for a
fix for that transparent text problem.

Want to try out the app?


"Karl E. Peterson" <karl@exmvps.org> wrote in message
news:i69ag1$c38$1@news.eternal-september.org...
|
| I didn't ask because I didn't think it was possible. I tried your
| code, and it "worked", more or less. I asked because I wonder if it's
| intended to *really* work, all the way? I've never seen another app do
| this, so I was wondering if you were just experimenting. IOW, are you
| trying to replicate something you feel ought to work, or something
| you've actually *seen* working?
|
| --
| .NET: It's About Trust!
| http://vfre...
|
|


Kevin Provance

9/9/2010 2:13:00 AM

0


"Abhishek" <user@server.com> wrote in message
news:i69c3u$u2r$1@speranza.aioe.org...
: The only app I have seen using aero is Windows Media Player 11 in Vista. I
: have this flv player in which the whole form is glassed (throughout its
: runtime :D) and on it I placed all the controls. I want to use some VB
: controls *but* the text appears transparent so I cant. so I am looking for
a
: fix for that transparent text problem.
:
: Want to try out the app?
:

I have some code in another language that might work. It's documentation
says the following:

"FIrst of all, any call to a glass function must only happen if the desktop
composition is enabled. The DWM API to query this is
DwmIsCompositionEnabled, and of course this call can only be made if the DWM
is present.

One of the great glass features is the ability to extend the effect beyond
the nonclient area and into the main area of your form. To achieve this,
first call the SwmExtendFrameIntoClientArea telling it how far you would
like the margins brought in, then make sure that when you pain t the
background of your form you draw a black region behind the glass areas.

There isn't much point in bringing the glass into your form unless you're
also going to put something ont op fo it. Luckily GDI+ is fully
alpha-channel aware so you can draw a high quality image onto your form
surface and all its alpha information will be respected. Text, however is a
little more complicated. To draw text you should use the DrawTextThemeEx
API which is a little tricky and requires that you use a memory DC with a
top-down DIB section."

Post not spell checked. <g>

Mike Williams

9/9/2010 12:37:00 PM

0

"Abhishek" <user@server.com> wrote in message
news:i68su1$2gu$1@speranza.aioe.org...
> I am able to apply (full Form Aroglass] using the
> DwmExtendFrameIntoClientArea API, but the text
> on controls appears transparent. someone suggested
> me that I should use
> SetLayeredWindowAttributes Me.hWnd, 0, 0, LWA_COLORKEY
> it works, now the text is no longer transparent but this
> creates another problem. I can no longer click on the form,
> the mouse events gets passed through.

Actually when I run your code at this end I get the Aeorglass effect over
the entire Form when I comment out the SetLayeredWindowAttributes line, but
when I include that line the entire client area of the Form goes solid black
and is also click through. I've tried various modifications and I cannot get
the effect you are after (at least the effect I think you are after). You
obviously already know that you can exclude a specific rectangle of your
Form from the Aeroglass effect because you have already mentioned the
Margins structure that is associated with DwmExtendFrameIntoClientArea, but
of course that allows just one rectangle to be excluded, whereas I assume
you want more than one rectangle to be excluded so that those rectangles can
contain various controls. Also, I'm not sure whether you want the various
Controls on your Form to themselves be "Aeroglass" and only their text shown
solid. If that is the case then I have not been able to come up with
anything that will do it. However if you want the entire Form to be
Aeroglass and some or all of the various VB controls (Command Buttons,
TextBoxes etc) on the Form to be totally solid (the control and its text
solid, with the Aeroglass Form client area around it) then I can think of a
way of achieving that effect. It's a bit of a "kludge", but it should
definitely work okay. It's pointless posting details at the moment though
because it might not actually be the effect you are after, but post again if
it might be suitable for your needs.

Mike