Aero Glass Control Text Problem

  • Follow


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 


0
Reply Abhishek 9/8/2010 8:50:14 PM

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://vfred.mvps.org


0
Reply Karl 9/8/2010 9:33:17 PM


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/kb/249341 
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://vfred.mvps.org
|
| 


0
Reply Abhishek 9/8/2010 9:56:11 PM

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/kb/249341 
> 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://vfred.mvps.org


0
Reply Karl 9/8/2010 11:15:48 PM

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.



0
Reply Abhishek 9/8/2010 11:42:16 PM

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://vfred.mvps.org


0
Reply Karl 9/8/2010 11:54:26 PM

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

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://vfred.mvps.org
|
| 


0
Reply Abhishek 9/9/2010 12:26:52 AM

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/screenshotgo.jpg
>
> 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://vfred.mvps.org


0
Reply Karl 9/9/2010 12:41:34 AM

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://vfred.mvps.org
|
| 


0
Reply Abhishek 9/9/2010 1:09:15 AM

"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> 

0
Reply Kevin 9/9/2010 2:13:05 AM

"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



0
Reply Mike 9/9/2010 12:36:31 PM

On 08/09/2010 21:50, Abhishek wrote:
> 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?

Other answers have alluded to this, but to get controls/text to draw 
correctly to a glass area, you need to use GDI+ (or another fully alpha 
aware library).
Plain GDI (As used by VB and most Win32 controls) does not support the 
alpha.

When I last read up on it, black is treated as fully transparent (due to 
the 0 value) and so shows up as clear on the glass.

There are various detailed articles on this if you have a look around 
online (don't look for VB6 specific stuff)

-- 
Dee Earley (dee.earley@icode.co.uk)
i-Catcher Development Team

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)
0
Reply Dee 9/9/2010 1:08:10 PM

*What I want*
Apply aero to my form (without messing up text on control)

*What I don't want*
when I use aero on my form, text on controls becomes transparent. I want 
text on controls like command button, textboxes to be black (opaque not 
transparent) not only vb control but all other controls having 'black' as 
text.

*How it Works*
We pass a rect to the aero DwmExtendFrameIntoClientArea, and set the 
background color to black and it will make any black area into glass, 
passing -1 will make the whole form glass.

Someone suggested me that I should use SetLayeredWindowAttributes Me.hWnd, 
0, 0, LWA_COLORKEY to not messup the control text. but it creates another 
problem that I cant click on the form.

thanks,



"Mike Williams" <Mike@WhiskyAndCoke.com> wrote in message 
news:i6akc1$e9h$1@speranza.aioe.org...
| "Abhishek" <user@server.com> wrote in message


0
Reply Abhishek 9/9/2010 1:28:01 PM

"Abhishek" <user@server.com> wrote in message 
news:i6ancv$kda$1@speranza.aioe.org...

> *How it Works* We pass a rect to the aero
> DwmExtendFrameIntoClientArea, and set the
> background color to black and it will make any
> black area into glass

That's not quite how I see it on my own system. According to the 
documentation, the DwmExtendFrameIntoClientArea function actually uses a 
MARGINS structure, rather than a RECT structure, with the values in the 
MARGINS structure representing how far the four Aero glass Form borders 
extend into the Form's client area, rather than the actual coordinates of a 
rectangle. For example, if I specify 100 for each of the four entries in the 
MARGINS structure then the Aero effect extends 100 pixels all around into 
the client area, with whatever is left in the centre being a solid 
rectangle. I suppose it amounts to almost the same thing though, and 
certainly it appears possible to have only one solid rectangle on the Form, 
whatever its size, which is not affected by the AeroGlass effect.

> passing -1 will make the whole form glass.

Yep. I get the same at this end. If all four border values are -1 and if the 
whole Form is black then the whole Form will be true glass, but that's not 
the same as saying "stuff on the Form that is not black will not be glass", 
if that is what you are suggesting? I haven't used the Aero stuff before 
but, on testing it on my own machine, any colour in the "glass" area that is 
not black is simply treated as a "different shade of glass", depending on 
its colour. So that means a TextBox background for example will be treated 
as one shade of glass (depending on its background colour) and any text it 
contains will also be treated as a different shade of glass, depending on 
its text colour. From what I can see, every colour other than pure white is 
treated as a particular shade and thickness of glass, with only pure white 
being truly solid. In other words, regardless of the colours you choose for 
the BackColor and ForeColor of a TextBox (for example) the text it contains 
may become difficult or impossible to read depending on the colours of the 
background your Form currently happens to be over.

> *What I don't want*
> when I use aero on my form, text on controls becomes
> transparent. I want text on controls like command button,
> textboxes to be black (opaque not transparent) not only
> vb control but all other controls having 'black' as text.

If you're asking what I think you are asking (a "glass" control on a "glass" 
Form with some solid black text on the glass control) then I'm afraid I 
don't know how to do it (except for a really bad kludge which would in any 
case only partially solve the problem and only for static controls and which 
really isn't worth doing), but I can think of a way (also a kludge really, 
but it works) of having some Controls on an otherwise fully glass Form where 
in each case BOTH the control AND the text it contains is totally solid and 
opaque (not glass at all). That's the question I asked you in my previous 
reponse (will a totally solid control with some totally solid text on it be 
okay?), but you never answered it.

Mike



0
Reply Mike 9/9/2010 3:44:29 PM

Yeah, did you even read what I wrote?


"Abhishek" <user@server.com> wrote in message 
news:i6ancv$kda$1@speranza.aioe.org...
: *What I want*
: Apply aero to my form (without messing up text on control)
:
: *What I don't want*
: when I use aero on my form, text on controls becomes transparent. I want
: text on controls like command button, textboxes to be black (opaque not
: transparent) not only vb control but all other controls having 'black' as
: text.
:
: *How it Works*
: We pass a rect to the aero DwmExtendFrameIntoClientArea, and set the
: background color to black and it will make any black area into glass,
: passing -1 will make the whole form glass.
:
: Someone suggested me that I should use SetLayeredWindowAttributes Me.hWnd,
: 0, 0, LWA_COLORKEY to not messup the control text. but it creates another
: problem that I cant click on the form.
:
: thanks,
:
:
:
: "Mike Williams" <Mike@WhiskyAndCoke.com> wrote in message
: news:i6akc1$e9h$1@speranza.aioe.org...
: | "Abhishek" <user@server.com> wrote in message
:
: 

0
Reply Kevin 9/9/2010 5:44:10 PM

read what wrote, I am already aware of that and doing exactly. thanks 
anyways.

"Kevin Provance" <k@p.c> wrote in message 
news:i6b6d8$esq$1@news.eternal-september.org...
| Yeah, did you even read what I wrote?
|
|
| "Abhishek" <user@server.com> wrote in message
| news:i6ancv$kda$1@speranza.aioe.org...
| : *What I want*
| : Apply aero to my form (without messing up text on control)
| :
| : *What I don't want*
| : when I use aero on my form, text on controls becomes transparent. I want
| : text on controls like command button, textboxes to be black (opaque not
| : transparent) not only vb control but all other controls having 'black' 
as
| : text.
| :
| : *How it Works*
| : We pass a rect to the aero DwmExtendFrameIntoClientArea, and set the
| : background color to black and it will make any black area into glass,
| : passing -1 will make the whole form glass.
| :
| : Someone suggested me that I should use SetLayeredWindowAttributes 
Me.hWnd,
| : 0, 0, LWA_COLORKEY to not messup the control text. but it creates 
another
| : problem that I cant click on the form.
| :
| : thanks,
| :
| :
| :
| : "Mike Williams" <Mike@WhiskyAndCoke.com> wrote in message
| : news:i6akc1$e9h$1@speranza.aioe.org...
| : | "Abhishek" <user@server.com> wrote in message
| :
| :
| 


0
Reply Abhishek 9/9/2010 6:00:14 PM

Abhishek brought next idea :
> *What I want*
> Apply aero to my form (without messing up text on control)
>
> *What I don't want*
> when I use aero on my form, text on controls becomes transparent. I want 
> text on controls like command button, textboxes to be black (opaque not 
> transparent) not only vb control but all other controls having 'black' as 
> text.

Probably the only way your going to reliably get that using your 
platform is to use owner drawn controls - you will have to do the 
drawing using GDI+.  VB6's form's engine is based on GDI - which as 
been said a thousand times already in this thread is not alpha channel 
aware.

-- 
Tom Shelton


0
Reply Tom 9/9/2010 6:12:00 PM

"Abhishek" <user@server.com> wrote in message 
news:i6b7bb$nsi$1@speranza.aioe.org...
: read what wrote, I am already aware of that and doing exactly. thanks
: anyways.
:

Really?  Are you really using GDI+ to paint your text?  If so, let's see the 
code you are using.  I have dozens of GDI+ projects that simulate glass, and 
tons of others things standard GDI could never do...so I do know it works. 

0
Reply Kevin 9/9/2010 7:47:02 PM

Abhishek used his keyboard to write :
> read what wrote, I am already aware of that and doing exactly. thanks 
> anyways.
>

You are not using GDI+ to draw your text or you wouldn't have this 
issue.  I hate to say, it - but for once Kevin is 100% correct.

If your going to draw on glass - forget about GDI.

-- 
Tom Shelton


0
Reply Tom 9/9/2010 7:56:34 PM

"Tom Shelton" <tom_shelton@comcast.invalid> wrote in message 
news:i6be5v$hor$1@news.eternal-september.org...
> Abhishek used his keyboard to write :
>> read what wrote, I am already aware of that and doing exactly.
>> thanks anyways.
>
> You are not using GDI+ to draw your text or you wouldn't
> have this issue.  I hate to say, it - but for once Kevin is
> 100% correct.

Why do you hate to say it, Shelton? If it is true, which it is, then you 
should be pleased to say it. Why do you hate the truth? You are in fact just 
as power drunk and just as obnoxious and just as biased and just as 
disgusting as your deranged and lunatic Micro$oft puppet masters.

Mike


0
Reply Mike 9/9/2010 8:18:07 PM

Well im not doing any text drawing on form, I know we can draw a text using 
drawthemetext apis. but I dont really want it. I just want controls to 
appear as they appear on a non-glass form. I tried with Delphi and 
powerbasic so its not a vb problem, basically all standard windows controls 
like buttons etc having the same problem.

now I can only think of two things
1. I am doing something wrong while applying glass
 or
2. if I want glass I will have to make my own controls in GDI+.


"Tom Shelton" <tom_shelton@comcast.invalid> wrote in message 
news:i6be5v$hor$1@news.eternal-september.org...
| Abhishek used his keyboard to write :
| > read what wrote, I am already aware of that and doing exactly. thanks
| > anyways.
| >
|
| You are not using GDI+ to draw your text or you wouldn't have this
| issue.  I hate to say, it - but for once Kevin is 100% correct.
|
| If your going to draw on glass - forget about GDI.
|
| -- 
| Tom Shelton
|
| 


0
Reply Abhishek 9/9/2010 8:19:09 PM

Abhishek pretended :
> Well im not doing any text drawing on form, I know we can draw a text using 
> drawthemetext apis. but I dont really want it. I just want controls to 
> appear as they appear on a non-glass form. I tried with Delphi and 
> powerbasic so its not a vb problem, basically all standard windows controls 
> like buttons etc having the same problem.
>
> now I can only think of two things
> 1. I am doing something wrong while applying glass
>  or

Nope.

> 2. if I want glass I will have to make my own controls in GDI+.

Bingo.  And this is only a problem on platforms that use GDI for their 
drawing.

-- 
Tom Shelton


0
Reply Tom 9/9/2010 8:33:21 PM

"Abhishek" <user@server.com> wrote in message 
news:i6bffq$9rg$1@speranza.aioe.org...

> Well im not doing any text drawing on form, I know we can
> draw a text using drawthemetext apis. but I dont really want
> it. I just want controls to appear as they appear on a
> non-glass form.

Well that's the question I asked you, at least twice, and which you have 
STILL not answered. The question, for the third time, was do you want a 
Control (or a number of Controls) to appear on your glass Form as they 
appear on a non glass Form, so both the Control and the text on it is solid. 
I'm still waiting for the answer.

Mike



0
Reply Mike 9/9/2010 8:34:37 PM

Mike Williams submitted this idea :
> "Abhishek" <user@server.com> wrote in message 
> news:i6bffq$9rg$1@speranza.aioe.org...
>
>> Well im not doing any text drawing on form, I know we can
>> draw a text using drawthemetext apis. but I dont really want
>> it. I just want controls to appear as they appear on a
>> non-glass form.
>
> Well that's the question I asked you, at least twice, and which you have 
> STILL not answered. The question, for the third time, was do you want a 
> Control (or a number of Controls) to appear on your glass Form as they appear 
> on a non glass Form, so both the Control and the text on it is solid. I'm 
> still waiting for the answer.
>
> Mike

I think that's what he wants...  A standard control that just works.

I'm wondering if you could use gdi+ to just draw a alpha aware bitmap 
behind your controls?  What do you think, Mike?

-- 
Tom Shelton


0
Reply Tom 9/9/2010 8:38:28 PM

Mike Williams presented the following explanation :
> "Abhishek" <user@server.com> wrote in message 
> news:i6bffq$9rg$1@speranza.aioe.org...
>
>> Well im not doing any text drawing on form, I know we can
>> draw a text using drawthemetext apis. but I dont really want
>> it. I just want controls to appear as they appear on a
>> non-glass form.
>
> Well that's the question I asked you, at least twice, and which you have 
> STILL not answered. The question, for the third time, was do you want a 
> Control (or a number of Controls) to appear on your glass Form as they appear 
> on a non glass Form, so both the Control and the text on it is solid. I'm 
> still waiting for the answer.
>
> Mike

Let me clarify my thinking here a bit....

If he is properly doing glass, then he needs to be handling the WM_DW* 
messages - which means he's already subclassing the form.  I'm just 
wondering if he could use that to draw an alpha aware bitmap on to the 
client area under where his controls are...

Does taht make sense?  I'm not much of a graphics, guy so I defer to 
your greater skill in that area.

-- 
Tom Shelton


0
Reply Tom 9/9/2010 8:49:19 PM

"Abhishek" <user@server.com> wrote in message 
news:i6bffq$9rg$1@speranza.aioe.org...
: Well im not doing any text drawing on form, I know we can draw a text 
using
: drawthemetext apis. but I dont really want it. I just want controls to
: appear as they appear on a non-glass form. I tried with Delphi and
: powerbasic so its not a vb problem, basically all standard windows 
controls
: like buttons etc having the same problem.

Here is code that will make your form transparent while not affecting 
whatever controls are on it.  You'll have to look up the APIs used. and 
compensate for any word wrapping in this post.

Public Function ChangeAppearance()

    Dim sngWidth As Single, sngHeight As Single, sngLeft As Single, sngTop 
As Single
    Dim varLeft As Variant, varTop As Variant
    Dim intPos As Integer, lngNew As Long, lngIn As Long, lngOut As Long

    'Set Form Height And Width To ScaleHeight And ScaleWidth
    sngWidth = frmTrans.ScaleX(frmTrans.Width, vbTwips, vbPixels)
    sngHeight = frmTrans.ScaleY(frmTrans.Height, vbTwips, vbPixels)

    'Set default region
    lngRegion = CreateRectRgn(0, 0, 0, 0)

    'Measure our frame edges
    sngLeft = (sngWidth - frmTrans.ScaleWidth) / 2
    sngTop = sngHeight - sngLeft - frmTrans.ScaleHeight
    lngOut = CreateRectRgn(0, 0, sngWidth, sngHeight)

    'Get our frame, because we want to show a frame with this one
    lngIn = CreateRectRgn(sngLeft, sngTop, sngWidth - sngLeft, sngHeight - 
sngLeft)
    'Combine our frame edge region with our frame region
    CombineRgn lngRegion, lngOut, lngIn, RGN_DIFF

    'Add our controls
    For intPos = 0 To frmTrans.Controls.Count - 1
        varLeft = frmTrans.ScaleX(frmTrans.Controls(intPos).Left, 
frmTrans.ScaleMode, vbPixels) + sngLeft
        varTop = frmTrans.ScaleX(frmTrans.Controls(intPos).Top, 
frmTrans.ScaleMode, vbPixels) + sngTop
        lngNew = CreateRectRgn(varLeft, varTop, varLeft + 
frmTrans.ScaleX(frmTrans.Controls(intPos).Width, _
        frmTrans.ScaleMode, vbPixels), _
        varTop + frmTrans.ScaleY(frmTrans.Controls(intPos).Height, 
frmTrans.ScaleMode, vbPixels))
        CombineRgn lngRegion, lngNew, lngRegion, RGN_OR
    Next

    'Redraw the window
    SetWindowRgn frmTrans.hwnd, lngRegion, True

End Function


0
Reply Kevin 9/10/2010 12:00:55 AM

"Tom Shelton" <tom_shelton@comcast.invalid> wrote in message 
news:i6bgkg$t11$1@news.eternal-september.org...
>> Mike Williams submitted this idea :
>> Well that's the question I asked you, at least twice, and which
>> you have STILL not answered. The question, for the third time,
>> was do you want a Control (or a number of Controls) to appear
>> on your glass Form as they appear on a non glass Form, so both
>> the Control and the text on it is solid. I'm still waiting for the 
>> answer.
>
> I think that's what he wants...  A standard control that just works.

Yep. That's what I thought as well, but he didn't answer my question and so 
I didn't bother to post anything else.

> I'm wondering if you could use gdi+ to just draw a alpha aware
> bitmap behind your controls?  What do you think, Mike?

Well to be perfectly honest, and as I have already indicated, you could 
write everything I know about GDI+ on the back of a postage stamp! I just 
don't use the stuff (although one day I think I'm going to have to look into 
it, since it is apparently so useful). I don't know how he is handling his 
glass effect other than the code he actually posted which uses a call to 
DwmExtendFrameIntoClientArea specifying -1 for all four border extensions 
which effectively turns the entire Form into what appears to be a sheet of 
glass, and the problem he is having is that all the standard VB controls on 
it, including any text they contain, are also rendered in a glass fashion, 
which is apparently something he does not want.

As I said in my earlier responses, because of my lack of knowledge of GDI+ 
the only thing I can come up with out of my own head is a sort of "kludge" 
in which his main Form is rendered as a solid sheet of glass (as he is 
currently doing according to his posted code) but to not have any controls 
on it at all. Then add a second Form and place all his desired controls on 
that second Form, making the second Form totally transparent apart from the 
specific areas in which the controls are situated. If he does this using 
SetLayeredWindowAttributes with a COLORKEY then he will be able to easily 
accommodate standard rectangular controls and also any other controls that 
might have an irregular shape. He can then show the second Form with the 
main Form as its owner and position it over the top of the main Form. A bit 
of subclassing can then cause the second Form to exactly follow the main 
Form whenever the user moves it, and a little more subclassing can send the 
main Form a WM_NCACTIVATE True message whenever the user clicks into a 
Control on the second Form, so as to prevent the main Form being drawn in 
its "lost focus" colour. Like I said, its all a "kludge" really, but its the 
only idea I can come up with at the moment which will not require me to read 
a few manuals on GDI+ which is something I currently know nothing at all 
about :-)

This is what I have got so far. It's all quite roughly coded, with many 
Public variables etc in the module and with certain things not done in the 
most efficient way, but that's because it is just a trial run to see if it 
produces an effect anything at all like the effect the OP wants. There are 
also a few things that need further attention (for example the fact that I 
haven't yet added code to take into account the fact that the user might 
reduce the size of the main Form, currently leaving one or more controls 
"floating") but it does sort of do what I think the OP might want. There are 
also other things that might need to be added. For example, I have not yet 
included any code to allow the user to move the Form by clicking anywhere 
other than in its caption bar area, which I think the OP might also want.

As I said, it's definitely a "kludge", but even if you don't like it you can 
still have a lot of fun digging holes in it ;-)  You need to create a 
standard VB project with Form1 the startup object in the normal way and then 
add a second Form and a Module. Place one Command Button and one TextBox on 
Form2 and set Form2's Caption to empty and BorderStyle to None and 
ShowInTaskBar to False. Then paste the following blocks of code into Form1 
and into the Module (there is no code in Form2).

' *** START OF FORM1 CODE ***
Option Explicit
Private Declare Function apiApplyGlass Lib "dwmapi.dll" _
  Alias "DwmExtendFrameIntoClientArea" (ByVal hwnd As Long, _
  pMarInset As MARGINS) 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 Long, _
  ByVal bAlpha As Byte, ByVal dwflags As Long) As Long
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 Const GWL_HWNDPARENT As Long = (-8&)
Private Type MARGINS
  cxLeftWidth As Long
  cxRightWidth As Long
  cyTopHeight As Long
  cyBottomHeight As Long
End Type

Public Sub ApplyTransparency()
Dim lOldStyle As Long
lOldStyle = GetWindowLong(hwnd, GWL_EXSTYLE)
SetWindowLong hwnd, GWL_EXSTYLE, lOldStyle Or WS_EX_LAYERED
End Sub

Private Sub ApplyAero()
Dim GlassMargins As MARGINS
GlassMargins.cxLeftWidth = -1
GlassMargins.cxRightWidth = -1
GlassMargins.cyTopHeight = -1
GlassMargins.cyBottomHeight = -1
apiApplyGlass Me.hwnd, GlassMargins
End Sub

Private Sub Form_Load()
Dim nStyle As Long
With Me
  .BackColor = vbBlack
  .Show
  ApplyTransparency
  ApplyAero
  .Hide
End With
With Form2
  xOff = 120: yOff = 390 ' temporary, calculate properly later
  .Move Me.Left + xOff, Me.Top + yOff, Me.Width, Me.Height
  .BackColor = RGB(1, 1, 1)
  nStyle = GetWindowLong(.hwnd, GWL_EXSTYLE) Or _
     WS_EX_LAYERED
  SetWindowLong .hwnd, GWL_EXSTYLE, nStyle
  SetLayeredWindowAttributes .hwnd, .BackColor, 0&, LWA_COLORKEY
  .Show , Me
End With
Me.Show
Me.SetFocus
oldWindowProcMain = SetWindowLongA(Me.hwnd, _
    GWL_WindowProc, AddressOf WindowProcMain)
oldWindowProc1 = SetWindowLongA(Form2.Text1.hwnd, _
    GWL_WindowProc, AddressOf WindowProc1)
oldWindowProc2 = SetWindowLongA(Form2.Command1.hwnd, _
    GWL_WindowProc, AddressOf WindowProc2)
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, _
  UnloadMode As Integer)
SetWindowLongA Me.hwnd, GWL_WindowProc, oldWindowProcMain
SetWindowLongA Form2.Text1.hwnd, GWL_WindowProc, oldWindowProc1
SetWindowLongA Form2.Command1.hwnd, GWL_WindowProc, oldWindowProc2
End Sub

Private Sub Form_Unload(Cancel As Integer)
Unload Form2
End Sub
' *** END OF FORM1 CODE ***
'
'
' *** START OF MODULE1 CODE ***
Option Explicit
Public oldWindowProcMain As Long
Public oldWindowProc1 As Long
Public oldWindowProc2 As Long
Private Const WM_MOVE = &H3
Private Const WM_SIZE = &H5
Public Const GWL_WindowProc = (-4)
Public xOff As Long, yOff As Long
Public Declare Function SetWindowLongA Lib "user32.dll" _
  (ByVal hwnd As Long, ByVal nIndex As Long, _
  ByVal dwNewLong As Long) As Long
Private Declare Function CallWindowProcA Lib "user32.dll" _
  (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, _
  ByVal Msg As Long, ByVal wParam As Long, _
  ByVal lParam As Long) As Long
Public Declare Function SendMessage Lib "user32" _
  Alias "SendMessageA" (ByVal hwnd As Long, _
  ByVal wMsg As Long, ByVal wParam As Long, _
  lParam As Any) As Long
Public Const WM_NCACTIVATE = &H86
Public Const WM_LBUTTONDOWN = &H201

Public Function WindowProcMain(ByVal hwnd As Long, ByVal Msg As _
  Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If Msg = WM_MOVE Then
  Form2.Move Form1.Left + xOff, Form1.Top + yOff
End If
WindowProcMain = CallWindowProcA(oldWindowProcMain, hwnd, Msg, _
    wParam, lParam)
End Function

Public Function WindowProc1(ByVal hwnd As Long, ByVal Msg As _
  Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If Msg = WM_LBUTTONDOWN Then
  SendMessage Form1.hwnd, WM_NCACTIVATE, -1&, ByVal 0&
End If
WindowProc1 = CallWindowProcA(oldWindowProc1, hwnd, Msg, _
    wParam, lParam)
End Function

Public Function WindowProc2(ByVal hwnd As Long, ByVal Msg As _
  Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If Msg = WM_LBUTTONDOWN Then
  SendMessage Form1.hwnd, WM_NCACTIVATE, -1&, ByVal 0&
End If
WindowProc2 = CallWindowProcA(oldWindowProc2, hwnd, Msg, _
    wParam, lParam)
End Function
' *** END OF MODULE1 CODE ***


0
Reply Mike 9/10/2010 6:37:28 AM

On 09/09/2010 21:49, Tom Shelton wrote:
> Mike Williams presented the following explanation :
>> "Abhishek" <user@server.com> wrote in message
>> news:i6bffq$9rg$1@speranza.aioe.org...
>>
>>> Well im not doing any text drawing on form, I know we can
>>> draw a text using drawthemetext apis. but I dont really want
>>> it. I just want controls to appear as they appear on a
>>> non-glass form.
>>
>> Well that's the question I asked you, at least twice, and which you
>> have STILL not answered. The question, for the third time, was do you
>> want a Control (or a number of Controls) to appear on your glass Form
>> as they appear on a non glass Form, so both the Control and the text
>> on it is solid. I'm still waiting for the answer.
>>
>> Mike
>
> Let me clarify my thinking here a bit....
>
> If he is properly doing glass, then he needs to be handling the WM_DW*
> messages - which means he's already subclassing the form. I'm just
> wondering if he could use that to draw an alpha aware bitmap on to the
> client area under where his controls are...
>
> Does taht make sense? I'm not much of a graphics, guy so I defer to your
> greater skill in that area.

I think they'd be subject to the clipping area of the DC as they aren't 
visible (maybe the CLIPCONTROLS window styel will help here?)

-- 
Dee Earley (dee.earley@icode.co.uk)
i-Catcher Development Team

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)
0
Reply Dee 9/10/2010 8:00:46 AM

"Mike Williams" <Mike@WhiskyAndCoke.com> wrote in message 
news:i6cjms$n0s$1@speranza.aioe.org...

> This is what I have got so far. It's a kludge, and is all
> quite roughly coded, with many Public variables . . .

By the way, apart from the stuff I have deliberately not yet accounted for 
in the code I posted there is one thing that I did mean to account for but 
which I just forgot about, and that's the check for the mousedown on the 
other buttons. I've checked only for the left button and so you'll need to 
include checks for the right and middle buttons as well.

Mike


0
Reply Mike 9/10/2010 8:29:10 AM

Dee Earley formulated the question :
> On 09/09/2010 21:49, Tom Shelton wrote:
>> Mike Williams presented the following explanation :
>>> "Abhishek" <user@server.com> wrote in message
>>> news:i6bffq$9rg$1@speranza.aioe.org...
>>>
>>>> Well im not doing any text drawing on form, I know we can
>>>> draw a text using drawthemetext apis. but I dont really want
>>>> it. I just want controls to appear as they appear on a
>>>> non-glass form.
>>>
>>> Well that's the question I asked you, at least twice, and which you
>>> have STILL not answered. The question, for the third time, was do you
>>> want a Control (or a number of Controls) to appear on your glass Form
>>> as they appear on a non glass Form, so both the Control and the text
>>> on it is solid. I'm still waiting for the answer.
>>>
>>> Mike
>>
>> Let me clarify my thinking here a bit....
>>
>> If he is properly doing glass, then he needs to be handling the WM_DW*
>> messages - which means he's already subclassing the form. I'm just
>> wondering if he could use that to draw an alpha aware bitmap on to the
>> client area under where his controls are...
>>
>> Does taht make sense? I'm not much of a graphics, guy so I defer to your
>> greater skill in that area.
>
> I think they'd be subject to the clipping area of the DC as they aren't 
> visible (maybe the CLIPCONTROLS window styel will help here?)

I think your right...

Actually, nobody's said it - but I think Kevin's use of a region is the 
best way.  Basically, a region the shape of the client with holes cut 
out for the controls and then filled with the transparent color.

Aside from owner drawing the controls...

-- 
Tom Shelton


0
Reply Tom 9/10/2010 12:41:20 PM

"Tom Shelton" <tom_shelton@comcast.invalid> wrote in message 
news:i6d91p$ujo$1@news.eternal-september.org...

> Actually, nobody's said it - but I think Kevin's use of a region
> is the best way.  Basically, a region the shape of the client with
> holes cut out for the controls and then filled with the transparent
> color. Aside from owner drawing the controls...

As far as I know, a Form with a GDI32 window region assigned to it 
automatically displays itself as a sort of XP style Form, without any 
Aeroglass effect, and so unless that problem was tackled the OP would not in 
that way be able to achieve his desired "full sheet of Aeroglass with solid 
Controls on it" effect. Unless of course there is a way of forcing a Form 
with a GDI32 window region to display itself as an Aeroglass Form? Perhaps 
it needs the equivalent of a GDI+ region, or perhaps there is some other way 
of forcing Aero onto a Form with a GDI32 window region? I would be 
interested in any answer you might be able to supply if you know how to do 
any of those things? I did also try punching holes into a Form using the 
alternative method of SetLayeredWindowAttributes with a COLORKEY (the same 
method I used in the example I posted recently in which I made everything 
but the "holes" transparent in Form2), and whilst that method of punching 
holes in the Form did actually still allow the Form to be displayed with its 
normal AeroGlass borders, it also produced similar problems to the problems 
the OP was originally experiencing. Up to now the only method I've been able 
to come up that works to achieve solid controls on a sheet of Aeroglass Form 
(although it is admittedly a kludge, and an unfinished kludge at that!) is 
the method I recently posted. If you come up with any other code that works 
though then I'd appreciate it if you would post your solution.

Mike




0
Reply Mike 9/10/2010 6:02:24 PM

Mike Williams used his keyboard to write :
> "Tom Shelton" <tom_shelton@comcast.invalid> wrote in message 
> news:i6d91p$ujo$1@news.eternal-september.org...
>
>> Actually, nobody's said it - but I think Kevin's use of a region
>> is the best way.  Basically, a region the shape of the client with
>> holes cut out for the controls and then filled with the transparent
>> color. Aside from owner drawing the controls...
>
> As far as I know, a Form with a GDI32 window region assigned to it 
> automatically displays itself as a sort of XP style Form, without any 
> Aeroglass effect, and so unless that problem was tackled the OP would not in 
> that way be able to achieve his desired "full sheet of Aeroglass with solid 
> Controls on it" effect. Unless of course there is a way of forcing a Form 
> with a GDI32 window region to display itself as an Aeroglass Form? Perhaps it 
> needs the equivalent of a GDI+ region, or perhaps there is some other way of 
> forcing Aero onto a Form with a GDI32 window region? I would be interested in 
> any answer you might be able to supply if you know how to do any of those 
> things? I did also try punching holes into a Form using the alternative 
> method of SetLayeredWindowAttributes with a COLORKEY (the same method I used 
> in the example I posted recently in which I made everything but the "holes" 
> transparent in Form2), and whilst that method of punching holes in the Form 
> did actually still allow the Form to be displayed with its normal AeroGlass 
> borders, it also produced similar problems to the problems the OP was 
> originally experiencing. Up to now the only method I've been able to come up 
> that works to achieve solid controls on a sheet of Aeroglass Form (although 
> it is admittedly a kludge, and an unfinished kludge at that!) is the method I 
> recently posted. If you come up with any other code that works though then 
> I'd appreciate it if you would post your solution.
>
> Mike

I wasn't suggesting a gdi32 region - I was assuming using GDI+.  I have 
sample code for a different langauge on a different platfrom that uses 
gdi+ for all it's rendering. And, to be honest I dont' want to go 
through the pain of trying to convert it to use the gdi+ api in vb.

Kevin posted an example, which I admitedly hadn't tried or more then 
skimmed - just to get a basic idea of it's function.  I assumed he had 
tried it, and based on his comments about having lots of experience 
with gdi+ I assumed he was using the GDI+ api (which to be honest I've 
never had to look at) - because it seemed to be following the basic 
theme of the example I have in a different language.

I'm not knocking your suggestion at all - I admit that your knowledge 
in this area is vastly superior to mine.  And, it certainly is easier 
then writting a bunch of owner drawn controls (though, that may 
actually be the best long term solution since you can just reuse the 
controls in other projects).  I was simply trying to spark ideas - 
based on the little experience I do have with glass on another 
platform, and my past experience with VB.CLASSIC.

-- 
Tom Shelton


0
Reply Tom 9/10/2010 6:23:06 PM

"Tom Shelton" <tom_shelton@comcast.invalid> wrote in message 
news:i6dt2l$5f7$1@news.eternal-september.org...
:
: Kevin posted an example, which I admitedly hadn't tried or more then
: skimmed - just to get a basic idea of it's function.  I assumed he had
: tried it, and based on his comments about having lots of experience
: with gdi+ I assumed he was using the GDI+ api (which to be honest I've
: never had to look at) - because it seemed to be following the basic
: theme of the example I have in a different language.

The sample I posted was just basic region clipping, using the standard GDI. 
My experience with GDI+ is for my own apps where I needed more powerful 
redrawing involving alpha channels.  It also deals with animated gifs and 
reading images from resource files (internal and DLL) with transparency. 
I've not yet attempted the kind of clipping in my example with GDI+...but 
it's an interesting challange.  I'd like to say I have the time to mess with 
it at present, but I don't.

That said, there is a guy who uses the handle LaVolpe on 
planetsourcecode.com whose done some impressive things with GDI+.  I would 
suggest the OP look those example up and see if there is anything in there 
he might find useful.  He also has a GDI+ usage and sample section on 
vbforums.  I've not looked at it (yet), but might be another direction for 
the OP: http://www.vbforums.com/showthread.php?p=3699398

0
Reply Kevin 9/10/2010 6:38:02 PM

Mike Williams formulated the question :
> "Tom Shelton" <tom_shelton@comcast.invalid> wrote in message 
> news:i6d91p$ujo$1@news.eternal-september.org...
>
>> Actually, nobody's said it - but I think Kevin's use of a region
>> is the best way.  Basically, a region the shape of the client with
>> holes cut out for the controls and then filled with the transparent
>> color. Aside from owner drawing the controls...
>
> As far as I know, a Form with a GDI32 window region assigned to it 
> automatically displays itself as a sort of XP style Form, without any 
> Aeroglass effect, and so unless that problem was tackled the OP would not in 
> that way be able to achieve his desired "full sheet of Aeroglass with solid 
> Controls on it" effect. Unless of course there is a way of forcing a Form 
> with a GDI32 window region to display itself as an Aeroglass Form? Perhaps it 
> needs the equivalent of a GDI+ region, or perhaps there is some other way of 
> forcing Aero onto a Form with a GDI32 window region? I would be interested in 
> any answer you might be able to supply if you know how to do any of those 
> things? I did also try punching holes into a Form using the alternative 
> method of SetLayeredWindowAttributes with a COLORKEY (the same method I used 
> in the example I posted recently in which I made everything but the "holes" 
> transparent in Form2), and whilst that method of punching holes in the Form 
> did actually still allow the Form to be displayed with its normal AeroGlass 
> borders, it also produced similar problems to the problems the OP was 
> originally experiencing. Up to now the only method I've been able to come up 
> that works to achieve solid controls on a sheet of Aeroglass Form (although 
> it is admittedly a kludge, and an unfinished kludge at that!) is the method I 
> recently posted. If you come up with any other code that works though then 
> I'd appreciate it if you would post your solution.
>
> Mike

Since I don't have a working install of VB6 on Vista or 7, I really 
can't try this - and it would I think require using the gdi+ api.  I 
understand there is a typelib out there for this in VB6...

But, the steps would look something like this based on the code I have 
in a different language:

1.  create a gdi+ region that is the client area minus your controls.
2.  call DwmExtendFraminIntoClientArea with the margins set all to 0
3.  call DwmEnableBlurBehindWindow with the following values set:
    dwFlags = DWM_BB_ENABLE Or DWM_BB_BLURREGION Or 
DWM_BB_TRANSITIONONMAXIMIZED
     fEnable = True
     hRegionBlur = region handle
     fTrasitionOnMaximized = false

Maybe?

-- 
Tom Shelton


0
Reply Tom 9/10/2010 6:50:47 PM

Kevin Provance submitted this idea :
> "Tom Shelton" <tom_shelton@comcast.invalid> wrote in message 
> news:i6dt2l$5f7$1@news.eternal-september.org...
>> 
>> Kevin posted an example, which I admitedly hadn't tried or more then
>> skimmed - just to get a basic idea of it's function.  I assumed he had
>> tried it, and based on his comments about having lots of experience
>> with gdi+ I assumed he was using the GDI+ api (which to be honest I've
>> never had to look at) - because it seemed to be following the basic
>> theme of the example I have in a different language.
>
> The sample I posted was just basic region clipping, using the standard GDI. 

Thanks... I had just gone back and looked and realized that was the the 
case.

> My experience with GDI+ is for my own apps where I needed more powerful 
> redrawing involving alpha channels.  It also deals with animated gifs and 
> reading images from resource files (internal and DLL) with transparency. 
> I've not yet attempted the kind of clipping in my example with GDI+...but 
> it's an interesting challange.  I'd like to say I have the time to mess with 
> it at present, but I don't.
>

That's cool.  I don't really either - as I don't really have a working 
vb6 install in vista or 7.  I could do it on the xp vm and transfer 
-but, it's too much work :)

But, I believe the basic idea is sound.

-- 
Tom Shelton


0
Reply Tom 9/10/2010 7:01:29 PM

"Tom Shelton" <tom_shelton@comcast.invalid> wrote in message 
news:i6dumi$m4h$1@news.eternal-september.org...

> Since I don't have a working install of VB6 on Vista or 7,
> I really can't try this - and it would I think require using the
> gdi+ api.  I understand there is a typelib out there for this
> in VB6... But, the steps would look something like this
> based on the code I have in a different language:
>
> 1.  create a gdi+ region that is the client area minus your controls.

Yep. That's pretty much what I would have expected, except of course (as I 
stated previously) I know almost nothing about GDI+ and so I have not yet 
tried that out.

> 2.  call DwmExtendFraminIntoClientArea
> with the margins set all to 0

Well, actually setting all the margins to zero would not have any effect at 
all as far as extending the Aeroglass borders into the client area of the 
Form is concerned. You would need to set the margins all to -1 in order to 
achieve a full Form sheet of Aeroglass as the OP requires.

> 3.  call DwmEnableBlurBehindWindow with the following
> values set:
> dwFlags = DWM_BB_ENABLE Or DWM_BB_BLURREGION
> Or DWM_BB_TRANSITIONONMAXIMIZED
> fEnable = True
> hRegionBlur = region handle
> fTrasitionOnMaximized = false

Sounds reasonable, except of course using that method you then need to 
actually draw all the controls. I was hoping that GDI+ might provide a 
simpler way? Probably it does.

> Maybe?

Well, yeah. Maybe. One day I'm going to have to look into this GDI+ 
business, if I ever get the time of course ;-)

I was actually going to ask what you thought of the effect that the code I 
posted myself achieved (the unfinished "kludge" using two forms) but since 
you have said you don't have a working version of VB6 installed on Vista or 
Win7 then I suppose you can't tell me. It does need some extra work to take 
care of certain problems, but I think it is a reasonable start for an at 
least workable solution that uses (mostly) straight GDI.

Mike



0
Reply Mike 9/10/2010 7:24:48 PM

Mike Williams explained :
> "Tom Shelton" <tom_shelton@comcast.invalid> wrote in message 
> news:i6dumi$m4h$1@news.eternal-september.org...
>
>> Since I don't have a working install of VB6 on Vista or 7,
>> I really can't try this - and it would I think require using the
>> gdi+ api.  I understand there is a typelib out there for this
>> in VB6... But, the steps would look something like this
>> based on the code I have in a different language:
>>
>> 1.  create a gdi+ region that is the client area minus your controls.
>
> Yep. That's pretty much what I would have expected, except of course (as I 
> stated previously) I know almost nothing about GDI+ and so I have not yet 
> tried that out.
>
>> 2.  call DwmExtendFraminIntoClientArea
>> with the margins set all to 0
>
> Well, actually setting all the margins to zero would not have any effect at 
> all as far as extending the Aeroglass borders into the client area of the 
> Form is concerned. You would need to set the margins all to -1 in order to 
> achieve a full Form sheet of Aeroglass as the OP requires.
>

I know normally, that's the case - but, the example I have is actually 
setting them to zero when using the region painting.

MARGINS(0, 0, 0, 0)

>> 3.  call DwmEnableBlurBehindWindow with the following
>> values set:
>> dwFlags = DWM_BB_ENABLE Or DWM_BB_BLURREGION
>> Or DWM_BB_TRANSITIONONMAXIMIZED
>> fEnable = True
>> hRegionBlur = region handle
>> fTrasitionOnMaximized = false
>
> Sounds reasonable, except of course using that method you then need to 
> actually draw all the controls. I was hoping that GDI+ might provide a 
> simpler way? Probably it does.
>

Why would you have to draw the controls?...

The fact is the OP has to be subclassing the window if they are really 
doing glass properly (looking for various WM_DWM* meessages)..  So, why 
couldn't they just do this when the main form gets a wm_paint message?  
Then let the the controls draw themselves?

Basically, this should leave the areas covered by the controls 
non-transparent, so you can't see through the text.

But like I said, this is not my area of expertise by anymeans - so, 
this is a sincere question.  The code I have draws a simple region, 
maybe I'll put a control on it and subrtact it out and see what 
happens...

-- 
Tom Shelton


0
Reply Tom 9/10/2010 7:36:39 PM

"Tom Shelton" <tom_shelton@comcast.invalid> wrote in message 
news:i6dt2l$5f7$1@news.eternal-september.org...
:
: I wasn't suggesting a gdi32 region - I was assuming using GDI+.  I have
: sample code for a different langauge on a different platfrom that uses
: gdi+ for all it's rendering. And, to be honest I dont' want to go
: through the pain of trying to convert it to use the gdi+ api in vb.
:
: Kevin posted an example, which I admitedly hadn't tried or more then
: skimmed - just to get a basic idea of it's function.  I assumed he had
: tried it, and based on his comments about having lots of experience
: with gdi+ I assumed he was using the GDI+ api (which to be honest I've
: never had to look at) - because it seemed to be following the basic
: theme of the example I have in a different language.
:

Well, out of curiosity I took a peek at my "master" GDI= module.  Turns out 
thre are all kind of region API for GDI+, way more than standard GDI.

Specifically:

GdipCreateRegion or GdipCreateRegionRect
GdipCombineRegionRect or GdipCombineRegionRegion (seriously)

There are also RECTI equivs where the RECT data type are single values, 
instead of longs.

I don't see a equivalent for SetWindowRgn, but that doesn't mean one isn't 
in there someplace.  All in all, I think with some work, the GDI example I 
posted could be rewowrked for a GDI+ scenario...or something close.

Well see.  If my plans fall through tonight, maybe ill mess with it.  <g> 

0
Reply Kevin 9/10/2010 7:52:50 PM

Kevin Provance was thinking very hard :
> "Tom Shelton" <tom_shelton@comcast.invalid> wrote in message 
> news:i6dt2l$5f7$1@news.eternal-september.org...
>> 
>> I wasn't suggesting a gdi32 region - I was assuming using GDI+.  I have
>> sample code for a different langauge on a different platfrom that uses
>> gdi+ for all it's rendering. And, to be honest I dont' want to go
>> through the pain of trying to convert it to use the gdi+ api in vb.
>> 
>> Kevin posted an example, which I admitedly hadn't tried or more then
>> skimmed - just to get a basic idea of it's function.  I assumed he had
>> tried it, and based on his comments about having lots of experience
>> with gdi+ I assumed he was using the GDI+ api (which to be honest I've
>> never had to look at) - because it seemed to be following the basic
>> theme of the example I have in a different language.
>> 
>
> Well, out of curiosity I took a peek at my "master" GDI= module.  Turns out 
> thre are all kind of region API for GDI+, way more than standard GDI.
>
> Specifically:
>
> GdipCreateRegion or GdipCreateRegionRect
> GdipCombineRegionRect or GdipCombineRegionRegion (seriously)
>
> There are also RECTI equivs where the RECT data type are single values, 
> instead of longs.
>
> I don't see a equivalent for SetWindowRgn, but that doesn't mean one isn't 
> in there someplace.  All in all, I think with some work, the GDI example I 
> posted could be rewowrked for a GDI+ scenario...or something close.
>
> Well see.  If my plans fall through tonight, maybe ill mess with it.  <g> 

The example I have doens't actually call anythign like setwindowregion 
- it passes the window hadnle and the region handle (via the 
hRegionBlur member of the DW_BLURBEHIND struct) to 
DwmEnableBlureBehindWindow....

-- 
Tom Shelton


0
Reply Tom 9/10/2010 8:10:16 PM

"Tom Shelton" <tom_shelton@comcast.invalid> wrote in message 
news:i6e1ci$hd5$1@news.eternal-september.org...
>> Mike Williams explained :
>> Well, actually setting all the margins to zero would not have
>> any effect at all as far as extending the Aeroglass borders into
>> the client area of the Form is concerned. You would need to
>> set the margins all to -1 in order to achieve a full Form sheet
>> of Aeroglass as the OP requires.
>
> I know normally, that's the case -

Really? It doesn't seem that you "know" it judging from your responses so 
far. In fact it seems as though (just like me) you know very little about 
GDI+

> but, the example I have is actually setting them to zero
> when using the region painting.

Right. So it's not your own code then. That's probably why you don't 
understand it.

> Why would you have to draw the controls?...

Well, from what you've explained so far when you said, and I quote, "1. 
create a gdi+ region that is the client area minus your controls" I assumed 
that you were creating a GDI+ region that excluded the control areas from 
your Form entirely (made them totally transparent), in the same way that a 
GDI32 "region of the Form with holes in it" would do. If that is the case 
then (as in GDI32) the Controls that live in those "holes" would not be 
drawn at all, because they are not included in the drawing region of the 
Form. Are you suggesting that GDI+ window regions behave differently in that 
respect, and that the Controls within them actually would be drawn, although 
not in Aeroglass, with the rest of the Form that is not "in the holes" being 
drawn in Aeroglass, or are you not sure what you are suggesting? Personally 
I don't know the answer to that one myself, as I have previously indicated, 
but it seems that you do. Are you actually sure about what you are saying? 
It's interesting stuff this, Tom, and I would appreciate your valuable help 
with it.

> But like I said, this is not my area of expertise by any means

So we're both in the same boat then as far as GDI+ is concerned?

> - so, this is a sincere question.  The code I have draws a
> simple region, maybe I'll put a control on it and subrtact it
> out and see what happens...

That's not a question. It is a statement. But it is a very interesting 
statement nonetheless. Maybe you would let me know what you discover. Sadly, 
you will not be able to do it in VB6 (which is what the OP is using and 
which is what he based his question on) because you have told me that you do 
not have a working version of VB6 installed on either a Vista or a Win7 
system. Are you now going to install one in order to perform your VB6 tests?

By the way, the original "bait" you slung, where you said to me, "I'm not 
much of a graphics guy so I defer to your greater skill in that area" was 
not very subtle. In fact it stood out a mile as soon as I read it. But the 
fact is that I had already told you I know almost nothing about GDI+ 
graphics (although I do know something about GDI32 graphics), and the 
(mostly) GDI32 code I wrote in an attempt to help the OP was a genuine 
attempt to perform the required task without using GDI+. If you don't like 
it (as I expect you won't because it was in response to the bait you slung) 
then that's fine, but there really is no need to go to all this trouble in 
your attempt to pull me into your net. Your methods are so transparent (pun 
intended) that they are totally laughable :-)

In fact, your grasp of the principles of Psychiatry is almost as tenuous as 
your grasp of the principles of GDI+

Mike



0
Reply Mike 9/10/2010 8:48:31 PM

"Kevin Provance" <k@p.c> wrote in message 
news:i6e2ae$sf4$1@news.eternal-september.org...

> Well see.  If my plans fall through tonight, maybe ill mess with it.  <g>

What plans? You're not going to mess with McCarthy or one of his 
dopplegangers again are you ;-)

Mike


0
Reply Mike 9/10/2010 8:51:32 PM

"Mike Williams" <Mike@WhiskyAndCoke.com> wrote in message 
news:i6e5og$pm7$1@speranza.aioe.org...
: "Kevin Provance" <k@p.c> wrote in message
: news:i6e2ae$sf4$1@news.eternal-september.org...
:
: What plans? You're not going to mess with McCarthy or one of his
: dopplegangers again are you ;-)

No, nothing so drab.  A girl I know who is a...special friend is in town. 
We're supposed to get together and....hang out.  She hasn't called yet, but 
her parent's are time hogs.  After 8 pm EST, then i'll be worried.  <g> 

0
Reply Kevin 9/10/2010 9:09:55 PM

Mike Williams used his keyboard to write :
> "Tom Shelton" <tom_shelton@comcast.invalid> wrote in message 
> news:i6e1ci$hd5$1@news.eternal-september.org...
>>> Mike Williams explained :
>>> Well, actually setting all the margins to zero would not have
>>> any effect at all as far as extending the Aeroglass borders into
>>> the client area of the Form is concerned. You would need to
>>> set the margins all to -1 in order to achieve a full Form sheet
>>> of Aeroglass as the OP requires.
>>
>> I know normally, that's the case -
>
> Really? It doesn't seem that you "know" it judging from your responses so 
> far. In fact it seems as though (just like me) you know very little about 
> GDI+
>

First of all, your correct, I don't know that much about gdi+ from an 
api standpoint - i've never used the api directly.  I've not had a 
need.

I know a little about gdi - but not much, it's just not ever been 
anything I've had to dive into in any real depth.

And what your are missing, is that I was trying to avoid the whole form 
sheet of glass.  The effect I was trying for, was to only fill the 
exposed client areas, and leave the areas covered by controls alone.

In other words, create a complex region that excluded the control area 
and then fill it with glass using the DwmEnableBlurBehindWindow api.  
That's why the margins are 0...


>> but, the example I have is actually setting them to zero
>> when using the region painting.
>
> Right. So it's not your own code then. That's probably why you don't 
> understand it.
>

I do understand it.  I was just wondering if it would work in VB6.  I 
was hoping that Kevin would be able to try it out.   But, if I can find 
the gdi+ typelib, I might have time to try it myself tomorrow.

>> Why would you have to draw the controls?...
>
> Well, from what you've explained so far when you said, and I quote, "1. 
> create a gdi+ region that is the client area minus your controls" I assumed 
> that you were creating a GDI+ region that excluded the control areas from 
> your Form entirely (made them totally transparent), in the same way that a 
> GDI32 "region of the Form with holes in it" would do. If that is the case 
> then (as in GDI32) the Controls that live in those "holes" would not be drawn 
> at all, because they are not included in the drawing region of the Form. Are 
> you suggesting that GDI+ window regions behave differently in that respect, 
> and that the Controls within them actually would be drawn, although not in 
> Aeroglass, with the rest of the Form that is not "in the holes" being drawn 
> in Aeroglass, or are you not sure what you are suggesting? Personally I don't 
> know the answer to that one myself, as I have previously indicated, but it 
> seems that you do. Are you actually sure about what you are saying? It's 
> interesting stuff this, Tom, and I would appreciate your valuable help with 
> it.
>

Yes I'm quite sure what I'm saying.  I think your the one that doesn't 
understand what I'm saying.

In fact, I just altered the sample to just what I was saying, and yes 
the control draws and still is clickable.

But, unfortunately, when I switch to gdi rendering for text - it's 
still transparent, of course now it is the color of the form 
background.  So, I have little hope that my theory will work in VB6.

I guess that makes sense thinking about it.  The whole thing is still 
being put together by the dwm as a composite image.

>> But like I said, this is not my area of expertise by any means
>
> So we're both in the same boat then as far as GDI+ is concerned?
>

From an an api perspective that is true.  But, I've done some work with 
GDI+ indirectly.  Not much, I've been playing around with a couple of 
basic games.

>> - so, this is a sincere question.  The code I have draws a
>> simple region, maybe I'll put a control on it and subrtact it
>> out and see what happens...
>
> That's not a question. It is a statement. But it is a very interesting 
> statement nonetheless. Maybe you would let me know what you discover. 

I have discovered that it doesn't work when gdi draws the text - as 
explained above.

> Sadly, 
> you will not be able to do it in VB6 (which is what the OP is using and which 
> is what he based his question on) because you have told me that you do not 
> have a working version of VB6 installed on either a Vista or a Win7 system. 
> Are you now going to install one in order to perform your VB6 tests?
>

No.  I could test it.  I just need the api typelib.  And I might if I 
get time.

> By the way, the original "bait" you slung, where you said to me, "I'm not 
> much of a graphics guy so I defer to your greater skill in that area" was not 
> very subtle. In fact it stood out a mile as soon as I read it. But the fact 
> is that I had already told you I know almost nothing about GDI+ graphics 
> (although I do know something about GDI32 graphics), and the (mostly) GDI32 
> code I wrote in an attempt to help the OP was a genuine attempt to perform 
> the required task without using GDI+. 

Ok...  I wasn't discounting your attempt at all.  And it maybe the only 
way now that I've been doing a little experimenting.  I was just 
wondering if it might not be easier to do it a different way - that yes 
involved a small amount of gdi+.  Something that is supposed to be 
useable from VB6...

> If you don't like it (as I expect you 
> won't because it was in response to the bait you slung) then that's fine, but 
> there really is no need to go to all this trouble in your attempt to pull me 
> into your net. Your methods are so transparent (pun intended) that they are 
> totally laughable :-)
>

You are completely wrong.  I have not attempted anything, Mike.  I was 
not trying to bring anything other the vb6.  for all you know is that 
the example was in C++.

We have had issues Mike, but I do admire your graphics abilities.  I 
meant what as I said as a sincere complement...

-- 
Tom Shelton


0
Reply Tom 9/10/2010 10:12:33 PM

"Tom Shelton" <tom_shelton@comcast.invalid> wrote in message 
news:i6eagt$coe$1@news.eternal-september.org...
: I do understand it.  I was just wondering if it would work in VB6.  I
: was hoping that Kevin would be able to try it out.   But, if I can find
: the gdi+ typelib, I might have time to try it myself tomorrow.

I'm use a module with all the GDI+ declares (well, I don't know if *all* of 
them are there, but it's comparable)

The typelib you are referring to, I think, is available at 
vbaccelerator.com? 

0
Reply Kevin 9/10/2010 10:34:02 PM

on 9/10/2010, Kevin Provance supposed :
> "Tom Shelton" <tom_shelton@comcast.invalid> wrote in message 
> news:i6eagt$coe$1@news.eternal-september.org...
>> I do understand it.  I was just wondering if it would work in VB6.  I
>> was hoping that Kevin would be able to try it out.   But, if I can find
>> the gdi+ typelib, I might have time to try it myself tomorrow.
>
> I'm use a module with all the GDI+ declares (well, I don't know if *all* of 
> them are there, but it's comparable)
>
> The typelib you are referring to, I think, is available at 
> vbaccelerator.com? 

I check it out...

-- 
Tom Shelton


0
Reply Tom 9/10/2010 10:49:41 PM

Kevin Provance submitted this idea :
> "Tom Shelton" <tom_shelton@comcast.invalid> wrote in message 
> news:i6eagt$coe$1@news.eternal-september.org...
>> I do understand it.  I was just wondering if it would work in VB6.  I
>> was hoping that Kevin would be able to try it out.   But, if I can find
>> the gdi+ typelib, I might have time to try it myself tomorrow.
>
> I'm use a module with all the GDI+ declares (well, I don't know if *all* of 
> them are there, but it's comparable)
>
> The typelib you are referring to, I think, is available at 
> vbaccelerator.com? 

found it.  bookmarked for retrieval if the wife lets me have anytime 
tomorrow :)

-- 
Tom Shelton


0
Reply Tom 9/10/2010 10:59:32 PM

"Tom Shelton" <tom_shelton@comcast.invalid> wrote in message 
news:i6eagt$coe$1@news.eternal-september.org...

> I was trying to avoid the whole form sheet of glass. The
> effect I was trying for, was to only fill the exposed client
> areas, and leave the areas covered by controls alone.

Right. I see what you were trying to do. That sort of thing of course is 
very easy in VB6 if you just want your Form's visible client area (either 
rectangular or irregularly shaped) to have a translucent background (either 
a sheet of translucency of one or more colours or a translucent image or 
something) and with your solidly drawn VB6 controls on top of it.  It is not 
so easy in VB6 though if you want a fancy Vista AeroGlass background, so 
that the caption bar and borders and the client area effectively become a 
single sheet of fancy semi animated Vista AeroGlass, and if you want solidly 
drawn VB6 Controls on it, at least not easy with my own currently severely 
limited amount of GDI+ knowledge ;-)  If you ever get that effect working in 
VB6 then let me know.

In fact that is why I went for the totally different approach (the kludge!) 
of creating a full Form (caption bar, borders and client area) sheet of 
fancy Vista AeroGlass with no controls on it at all, and then positioning an 
owned second Form on top of it, with the second Form being totally 
transparent except for the Control areas. It is very definitely a kludge, 
and there is probably a very much better way to do it using the various GDI+ 
functions, but it is all I could come up with, at least without using GDI+ 
in the process (because of my current almost total lack of knowledge of 
GDI+), and it does at least allow the OP to view the output and decide 
whether that is actually the effect he wants (since his various statements 
were sometimes not very clear and were sometimes at odds with each other).

Mike


 

0
Reply Mike 9/11/2010 2:30:58 AM

Mike Williams wrote on 9/10/2010 :
> "Tom Shelton" <tom_shelton@comcast.invalid> wrote in message 
> news:i6eagt$coe$1@news.eternal-september.org...
>
>> I was trying to avoid the whole form sheet of glass. The
>> effect I was trying for, was to only fill the exposed client
>> areas, and leave the areas covered by controls alone.
>
> Right. I see what you were trying to do. That sort of thing of course is very 
> easy in VB6 if you just want your Form's visible client area (either 
> rectangular or irregularly shaped) to have a translucent background (either a 
> sheet of translucency of one or more colours or a translucent image or 
> something) and with your solidly drawn VB6 controls on top of it.  It is not 
> so easy in VB6 though if you want a fancy Vista AeroGlass background, so that 
> the caption bar and borders and the client area effectively become a single 
> sheet of fancy semi animated Vista AeroGlass, and if you want solidly drawn 
> VB6 Controls on it, at least not easy with my own currently severely limited 
> amount of GDI+ knowledge ;-)  If you ever get that effect working in VB6 then 
> let me know.
>

If I have time, I do plan on trying it out latter.  But, as I said 
earlier, I don't think it's going to work anyway...

> In fact that is why I went for the totally different approach (the kludge!) 
> of creating a full Form (caption bar, borders and client area) sheet of fancy 
> Vista AeroGlass with no controls on it at all, and then positioning an owned 
> second Form on top of it, with the second Form being totally transparent 
> except for the Control areas. It is very definitely a kludge, and there is 
> probably a very much better way to do it using the various GDI+ functions, 
> but it is all I could come up with, at least without using GDI+ in the 
> process (because of my current almost total lack of knowledge of GDI+), and 
> it does at least allow the OP to view the output and decide whether that is 
> actually the effect he wants (since his various statements were sometimes not 
> very clear and were sometimes at odds with each other).

Your right - it is a kludge.  But, that doesn't make it bad - in fact 
it maybe the only viable solution for the OP to achieve the effect he 
wants, short of creating a set of owner drawn controls.  That would 
probably be a lot more work then your "kludge".  Sometimes, a kludge is 
the best answer.

My experiementation failed - even when using a glass filled region; the 
controls text became transparent when rendered using GDI (though, what 
was showing through was the form background).  Not only that to get the 
full effect, you have to make the form borderless - and of course make 
it draggable.

-- 
Tom Shelton


0
Reply Tom 9/11/2010 7:07:15 AM

47 Replies
1389 Views

(page loaded in 0.158 seconds)

12/15/2014 2:03:11 PM


Reply: