Jump to content

Real Vista Aero Glass - Four functions


James
 Share

Recommended Posts

That is because @OS_TYPE returns the windows family the user is running, not the current version of windows.

Try @OS_Version instead muttley

Someone punch me! Thanks!

I have recreated this in VB6 and I know why the control does not appear correctly after "glassification". In the VB6 version, I can create the tRect which covers and inside area which does not get the glass effect. Anything inside that area is left alone, thus keeping the controls how they should be.

Link to comment
Share on other sites

You should check out the msdn page, it tells you just about everything.

http://msdn.microsoft.com/en-us/library/aa969512(VS.85).aspx

I have done, but another read won't harm me, it might be really useful!

Edit: Nope, because I don't know how to create a MARGINS structure.

Edited by JamesBrooks
Link to comment
Share on other sites

I have done, but another read won't harm me, it might be really useful!

Edit: Nope, because I don't know how to create a MARGINS structure.

This is how:

$struct=DllStructCreate("int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight;")

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Ok, so I can just change the values to the $Area array?

Edit: Just some code:

$Area[4] = [50, 50, 50, 50]

Func _Vista_ApplyGlassArea($hWnd, $Area, $bColor = 0x000000)
    If @OSVersion <> "WIN_VISTA" Then
        MsgBox(16, "_Vista_ApplyGlass", "You are not running Vista!")
        Exit
    Else
        If IsArray($Area) Then
            GUISetBkColor($bColor); Must be here!
            Return DllCall("dwmapi.dll", "long*", "DwmExtendFrameIntoClientArea", "hwnd", $hWnd, "long*", $Area[0])
        Else
            MsgBox(16, "_Vista_ApplyGlassArea", "Area specified is not an array!")
        EndIf
    EndIf
EndFunc  ;==>_Vista_ApplyGlassArea

If you test it, you will only get the left hand side with the glass effect. How do I use the code from above to create the margins?

Edited by JamesBrooks
Link to comment
Share on other sites

No, no, no, you've got this all mixed up.

Here's how you should do it:

$hwnd=GUICreate("sample",300,300)
GUISetState()

$struct=DllStructCreate("int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight;")
DllStructSetData($struct,"cxLeftWidth",130)
DllStructSetData($struct,"cxRightWidth",3)
DllStructSetData($struct,"cyTopHeight",0)
DllStructSetData($struct,"cyBottomHeight",25)
GUISetBkColor(0x000000)
DllCall("dwmapi.dll", "int", "DwmExtendFrameIntoClientArea", "hwnd", $hWnd, "ptr", DllStructGetPtr($struct))

Do
    $msg=GUIGetMsg()
    
Until $msg=-3

Now play with the values in the struct until you understand what they mean muttley

Edited by monoceres

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Ahh! Thanks Mono! I shall have lots of fun today muttley

It works. By the way, you made a little error in the code:

DllStructSetData($struct,"cxTopHeight",0)

Should be:

DllStructSetData($struct,"cyTopHeight",0)

I am starting to understand Structures now, I think!

Edited by JamesBrooks
Link to comment
Share on other sites

Just use this and you'll have a full red glass window

#include <StructureConstants.au3>
#include <GUIConstants.au3>

$GUI = GUICreate("Windows Vista DWM", 243, 243)
$Apply = GUICtrlCreateButton("Apply", 80, 104, 83, 25, 0)
GUISetState(@SW_SHOW)

While 1
     $iMsg = GUIGetMsg()
     Switch $iMsg
         Case $GUI_EVENT_CLOSE
             Exit
         Case $Apply
                 $Ret = ApplyGlass($GUI,243,243,243,243,0xFF0000); produces full glass window, the glass is red colored
     EndSwitch
WEnd

Func ApplyGlass($hWnd,$leftw,$rightw,$toph,$bottomh,$glasscolor = "0x000000")
$struct=DllStructCreate("int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight;")
DllStructSetData($struct,"cxLeftWidth",$leftw)
DllStructSetData($struct,"cxRightWidth",$rightw)
DllStructSetData($struct,"cyTopHeight",$toph)
DllStructSetData($struct,"cyBottomHeight",$bottomh)
GUISetBkColor($glasscolor)
Return DllCall("dwmapi.dll", "int", "DwmExtendFrameIntoClientArea", "hwnd", $hWnd, "ptr", DllStructGetPtr($struct))
EndFunc
Edited by LIMITER
Link to comment
Share on other sites

Wow this is amazing! My Dad thinks this is great! Did you people know you can use a different windows handle like Notepad? ACE!

[center][font="Arial"]If practise makes perfect and no-ones perfect whats the point of practise?[/font]Sorry for my rude attitude when I started here.[/center]

Link to comment
Share on other sites

Just one more thing, $tagMargins is the exact same thing as the struct I created so you can replace my DllStructCreate("int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight;") with DllStructCreate($tagMargins)

muttley

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Monoceres, that means no need for StructureConstants.au3?

If you like, I'm just saying that you don't need to use both DllStructCreate("int cxLeftWidth;int cxRightWidth;int cyTopHeight;int yBottomHeight;") and DllStructCreate($tagMargin)

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Note: If you want only a little bit of the GUI such as the bottom to be effected then here is an example showing you how:

#include <GUIConstants.au3>
#include <Vista.au3>

Global $Area[4] = [0, 0, 0, 76]

$GUI = GUICreate("GUI", 408, 181)
GUICtrlCreateLabel("I shall not be affected by the Glass!", 112, 64, 170, 17)
GUICtrlCreateLabel("", 0, 105, 408, 76)
GUICtrlSetBkColor(-1, 0x000000)
_Vista_ApplyGlassArea($GUI, $Area, 0xE2E2E2)

GUISetState(@SW_SHOW)

While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Have fun!

Edit: Here is a screenshot!

Posted Image

I have fixed the little white line seen in the screenshot!

Edited by JamesBrooks
Link to comment
Share on other sites

WinGetHandle()

Yeah! I know, I was just saying muttley

Note: If you want only a little bit of the GUI such as the bottom to be effected then here is an example showing you how:

#include <GUIConstants.au3>
#include <Vista.au3>

Global $Area[4] = [0, 0, 0, 77]

$GUI = GUICreate("GUI", 408, 181)
GUICtrlCreateLabel("I shall not be affected by the Glass!", 112, 64, 170, 17)
GUICtrlCreateLabel("", 0, 104, 408, 76)
GUICtrlSetBkColor(-1, 0x000000)
_Vista_ApplyGlassArea($GUI, $Area, 0xE2E2E2)

GUISetState(@SW_SHOW)

While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

If you created the label at the bottom of the GUI then you need to edit the last $Area co-ordinate and + 1 to it so it will cover it properly.

Have fun!

Neat example James. I see you have also updated System Properties Wrapper with the GUI nice! 5 stars for both scripts!

[center][font="Arial"]If practise makes perfect and no-ones perfect whats the point of practise?[/font]Sorry for my rude attitude when I started here.[/center]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...