Jump to content
Sign in to follow this  

Some interesting menu estetics

Recommended Posts


I've done nothing new, no new functions and similar, I've just wrapped all the functions people on this forum created to make interesting menu items (All the credits for the existed functions are posted in the top of the script). I have image menu-item (like the one you see on new AutoCad), and glass menu (similar to the one on firefox). This is not UDF, don't have time to make it :/ if anyone is willing to make an UDF for this, I'm more than willing to help as much as I can (and as much my time allows me to).

script is for vista+ OS (because of AERO environment)

Posted Image

p.s. top left image was drawn with GDI+

#region parts that are not my work:
;JamesBrooks for Vista glass functions: http://www.autoitscript.com/forum/topic/...lass-four-functions/page__hl__
;Authenticity and Yashied for glow txt on glass: http://www.autoitscript.com/forum/topic/...extex-to-get-glowing-text-on-a
;Malkey for GDI+ gradient: http://www.autoitscript.com/forum/topic/75792-a-gdiplus-gradient-line-brush/

#include <FontConstants.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>

OnAutoItExitRegister( "_CleanUp" )

Global $IconSize = 48
Global $width = 300
Global $height = 350
Global $shine1 = 5
Global $shine2 = 5
Global $shine3 = 125
Global $menuFontSize = 16
Global $title = 'Some cool menu'
Global $temp_image = @TempDir & '\my_seven_image.bmp'
Global $Win_Back_Color = 0x636363;0xC5C5C5;454545 <--- color of lower dark grey line
For $i = 1 to Int($IconSize/4.8) ;adding space in front of the title so that it doesn't overlap top left image
    $title = ' ' & $title

#region values requires for text shine on glass area
Global Const $DTT_TEXTCOLOR = 0x00000001
Global Const $DTT_GLOWSIZE = 0x00000800
Global Const $DTT_COMPOSITED = 0x00002000
If Not IsDeclared("tagDTTOPTS") Then Global Const $tagDTTOPTS = _
"uint Size;uint Flags;uint clrText;uint clrBorder;uint clrShadow;int TextShadowType;" & $tagPOINT & _
";int BorderSize;int FontPropId;int ColorPropId;int StateId;int ApplyOverlay;int GlowSize;ptr DrawTextCallback;int lParam;"
Global $Struct = DllStructCreate("int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight;")
Global $sStruct = DllStructCreate("dword;int;ptr;int")
Global $Area[4] = [0, 0, $IconSize-23, 0]

Global $Form1 = GUICreate($title, $width, $height, -1, -1, -1, -1)
Global $GlassArea = GUICtrlCreateLabel("", 0, 0, $width, $IconSize-23) ;area that will be filled with glass
GUICtrlSetBkColor(-1, 0x000000)
Global $DarkGreyArea = GUICtrlCreateGraphic(0, 0, $width, $height-45) ;work area (to add controls in)
GUICtrlSetBkColor(-1, 0xC5C5C5) ;with light grey area
Global $CloseButton = GUICtrlCreateButton("Close", $width-90, $height-35, 80, 25)
Global $hTheme = _WinAPI_OpenThemeData($Form1, "globals") ;required function for label shine in glass area
If (@OSVersion <> "WIN_VISTA") OR (@OSVersion <> "WIN_7") Then _Vista_ApplyGlassArea($Form1, $Area, $Win_Back_Color) ;applying glass area to main GUI (area where $GlassArea label is)

GUISetState(@SW_SHOW, $Form1)

    ;creating child GUI with top left image-menu-control
    Global $iX = 0, $iY = 0, $iWidth = $IconSize, $iHeight = $IconSize
    Global $controlGui, $HoverImage, $Mask, $FileGUI, $FileMenu, $EditGUI, $EditMenu, $HelpGUI, $HelpMenu, $DownGUI, $DownMenu

#region create fake GUIs with each holding a clickable control
    $ImageState = 1
    _CreateFakeGUI($controlGui, 'ControlGUI', 48, 48, -1, -23, 1, $HoverImage)
    $FileState = 1
    _CreateFakeGUI($FileGUI, 'FileGUI', 35, $menuFontSize*2-Round($menuFontSize/1.5), 52, 4, 2, $FileMenu)
    $EditState = 1
    _CreateFakeGUI($EditGUI, 'EditGUI', 35, $menuFontSize*2-Round($menuFontSize/1.5), 92, 4, 2, $EditMenu)
    $HelpState = 1
    _CreateFakeGUI($HelpGUI, 'HelpGUI', 45, $menuFontSize*2-Round($menuFontSize/1.5), 130, 4, 2, $HelpMenu)
    $DownState = 1
    _CreateFakeGUI($DownGUI, 'DownGUI', 20, $menuFontSize*2-Round($menuFontSize/1.5), $width-18, 4, 2, $DownMenu)

#region create context menus
    ;----------Image Menu------------------------
    $ImageDummy = GUICtrlCreateDummy()
    $ImageContext = GUICtrlCreateContextMenu($ImageDummy)
    $ImMinimize = GUICtrlCreateMenuItem("Minimize", $ImageContext)
    $ImMaximize = GUICtrlCreateMenuItem("Maximize", $ImageContext)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlCreateMenuItem("", $ImageContext)
    $imExit = GUICtrlCreateMenuItem("Exit", $ImageContext)
    ;----------File Menu------------------------
    $FileDummy = GUICtrlCreateDummy()
    $FileContext = GUICtrlCreateContextMenu($FileDummy)
    $FileNew = GUICtrlCreateMenu("New", $FileContext)
    $FileNewProject = GUICtrlCreateMenuItem("Project", $FileNew)
    $FileNewFile = GUICtrlCreateMenuItem("File", $FileNew)
    $FileOpen = GUICtrlCreateMenuItem("Open", $FileContext)
    $FileSave = GUICtrlCreateMenuItem("Save", $FileContext)
    $FileSaveAs = guictrlcreatemenuitem("Save As...", $FileContext)
    GUICtrlCreateMenuItem("", $FileContext)
    $FileExit = guictrlcreatemenuitem("Exit", $FileContext)
    ;----------Edit Menu------------------------
    $EditDummy = GUICtrlCreateDummy()
    $EditContext = GUICtrlCreateContextMenu($EditDummy)
    $EditUndo = GUICtrlCreateMenuItem("Undo", $EditContext)
    $EditRedo = GUICtrlCreateMenuItem("Redo", $EditContext)
    GUICtrlCreateMenuItem("", $EditContext)
    $EditCut = GUICtrlCreateMenuItem("Cut", $EditContext)
    $EditCopy = GUICtrlCreateMenuItem("Copy", $EditContext)
    $EditPaste = GUICtrlCreateMenuItem("Paste", $EditContext)
    GUICtrlCreateMenuItem("", $EditContext)
    $EditPref = GUICtrlCreateMenuItem("Preferences", $EditContext)
    ;----------Help Menu------------------------
    $HelpDummy = GUICtrlCreateDummy()
    $HelpContext = GUICtrlCreateContextMenu($HelpDummy)
    $HelpHelp = GUICtrlCreateMenuItem("Help", $HelpContext)
    GUICtrlCreateMenuItem("", $HelpContext)
    $HelpAbout = GUICtrlCreateMenuItem("About", $HelpContext)
    ;----------Down arrow Menu------------------------
    $DownDummy = GUICtrlCreateDummy()
    $DownContext = GUICtrlCreateContextMenu($DownDummy)
    $DownTab = GUICtrlCreateMenuItem("Tab Groups", $DownContext)
    $DownTabOther = GUICtrlCreateMenuItem("Tabs from other computers", $DownContext)
    GUICtrlCreateMenuItem("", $DownContext)
    $DownTabExample = GUICtrlCreateMenuItem("Example tab", $DownContext)

    _Draw_menus() ;drawing all menu items

    Global $Mask = GUICreate('Mask', $iWidth-2, $iHeight-2, 0, -22, $WS_POPUP, $WS_EX_MDICHILD, $Form1) ;another child window for shade and gloss when moving mouse over image-menu or clicking it
    GUISetBkColor(0xFFFFFF, $Mask)
    WinSetTrans($Mask, '', 40)
    GUISetState(@SW_DISABLE, $Mask) ;still not shown, only disabled


While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $HelpAbout
            MsgBox(48, 'About', 'Cool menus by... sandin' & @CRLF & @CRLF & '07.07.2011', -1, $Form1)
        Case $ImMinimize
            WinSetState($Form1, '', @SW_MINIMIZE)
        Case $GUI_EVENT_CLOSE, $imExit, $CloseButton, $FileExit
        Case $GlassArea ;moving window when holding glass area that isn't menu
            dllcall("user32.dll","int","SendMessage","hWnd", $Form1,"int",0xA1,"int", 2,"int", 0)
    #region detection clicks and hovering above menu items
    If WinActive($Form1) then ;<-- here's one problem, I need this in order for window not to detect any clicks if you click on another window that is above this one
        ;but then you can't click on any control even if the window is aside your currently active window.
        _MenuBehavior($FileGUI, $FileMenu, $FileState, 'File', $FileContext)
        _MenuBehavior($EditGUI, $EditMenu, $EditState, 'Edit', $EditContext)
        _MenuBehavior($HelpGUI, $HelpMenu, $HelpState, 'Help', $HelpContext)
        _MenuBehavior($DownGUI, $DownMenu, $DownState, ChrW(9660), $DownContext)
        _MenuBehavior($controlGui, $HoverImage, $ImageState, '', $ImageContext)

Func _MenuBehavior($WinHWND, $i_MenuItem, ByRef $i_MenuState, $i_Label, $i_ContextMenu);, $i_Shine1, $i_Shine2, $i_Shine3, $i_Color1, $i_Color2)
    Local $a = GUIGetCursorInfo($WinHWND)
    Switch $a[4]
        Case $i_MenuItem
            If $a[2] = 1 Then
                If $i_MenuState <> 3 Then
                    $i_MenuState = 3
                    if ($FileState <> 1) AND ($FileMenu <> $i_MenuItem) then
                        $FileState = 1
                        _Draw_Menu_ex($FileGUI, 'File', $menuFontSize, $shine3, 0x000000)
                    if ($EditState <> 1) AND ($EditMenu <> $i_MenuItem) then ;making sure that disable all other menu clicked state (if there are any)
                        $EditState = 1
                        _Draw_Menu_ex($EditGUI, 'Edit', $menuFontSize, $shine3, 0x000000)
                    if ($HelpState <> 1) AND ($HelpMenu <> $i_MenuItem) Then
                        $HelpState = 1
                        _Draw_Menu_ex($HelpGUI, 'Help', $menuFontSize, $shine3, 0x000000)
                    if ($DownState <> 1) AND ($DownMenu <> $i_MenuItem) Then
                        $DownState = 1
                        _Draw_Menu_ex($DownGUI, ChrW(9660), $menuFontSize-Round(Sqrt($menuFontSize)), $shine3, 0x555555)
                    if ($ImageState <> 1) AND ($HoverImage <> $i_MenuItem) Then
                        $ImageState = 1
                        GUISetState(@SW_HIDE, $Mask)
                    If $i_MenuItem = $DownMenu then
                        _Draw_Menu_ex($WinHWND, ChrW(9660), $menuFontSize-Round(Sqrt($menuFontSize)), $shine2+2, 0x000099)
                    ElseIf $i_MenuItem = $HoverImage Then
                        GUISetBkColor(0x000000, $Mask)
                        GUISetState(@SW_SHOWNOACTIVATE, $Mask)
                        _Draw_Menu_ex($WinHWND, $i_Label, $menuFontSize, $shine1, 0x000099) ;clicked File menu state, drawing average glow, and red color
                    ShowMenu($WinHWND, $i_MenuItem, $i_ContextMenu) ;showing context menu for File
                If $i_MenuState <> 2 Then
                    $i_MenuState = 2
                    If $i_MenuItem = $DownMenu Then
                        _Draw_Menu_ex($WinHWND, '| ' & ChrW(9660) & ' |', $menuFontSize-Round(Sqrt($menuFontSize)), $shine2, 0x555555)
                    ElseIf $i_MenuItem = $HoverImage Then
                        GUISetBkColor(0xFFFFFF, $Mask)
                        GUISetState(@SW_SHOWNOACTIVATE, $Mask)
                        _Draw_Menu_ex($WinHWND, $i_Label, $menuFontSize, $shine2, 0x000000) ;high glow, black color
        Case Else
            If $i_MenuState <> 1 Then
                $i_MenuState = 1
                If $i_MenuItem = $DownMenu Then
                    _Draw_Menu_ex($WinHWND, ChrW(9660), $menuFontSize-Round(Sqrt($menuFontSize)), $shine3, 0x555555)
                ElseIf $i_MenuItem = $HoverImage Then
                    GUISetState(@SW_HIDE, $Mask)
                    _Draw_Menu_ex($WinHWND, $i_Label, $menuFontSize, $shine3, 0x000000) ;spread glow so there aren't any, black color

Func _CreateFakeGUI(ByRef $WinHWND, $WinTitle, $WinWIdth, $WinHeight, $Win_X, $Win_Y, $AddCtrl, ByRef $CtrlHWND);, $LabelSize = 35)
    $WinHWND = GUICreate($WinTitle, $WinWIdth, $WinHeight, $Win_X, $Win_Y, $WS_POPUP, $WS_EX_MDICHILD, $Form1)
    If $AddCtrl = 1 then
        $CtrlHWND = GUICtrlCreatePic('', 0, 0, $iWidth, $iHeight) ;control to put image later on
    ElseIf $AddCtrl = 2 Then
        $CtrlHWND = GUICtrlCreateLabel('', 0, 0, $WinWIdth, $menuFontSize*2-Round($menuFontSize/1.5)) ;clickable area
        GUICtrlSetBkColor(-1, 0x000000)
        If (@OSVersion <> "WIN_VISTA") OR (@OSVersion <> "WIN_7") Then _Vista_ApplyGlass($WinHWND, $Win_Back_Color) ;apply glass on entire child window
    GUISetState(@SW_DISABLE, $WinHWND) ;disabling window so that it doesn't take focus from parent when you click on it
    GUISetState(@SW_SHOWNOACTIVATE, $WinHWND) ;show and doesn't focus
    If $AddCtrl = 1 Then
        _Create_7Image() ;creating image with 7 number on it (like win7)
        GUICtrlSetImage($CtrlHWND, $temp_image) ;setting image into control we created earlier.
        ;Why did I use this method and not redrew image 7 in MY_PAINT? because it would be very slow, this method is faster.

Func ShowMenu($hWnd, $CtrlID, $nContextID)
    Local $timez = TimerInit()
    Local $arPos, $x, $y
    Local $hMenu = GUICtrlGetHandle($nContextID)

    $arPos = ControlGetPos($hWnd, "", $CtrlID)

    $x = $arPos[0]
    $y = $arPos[1] + $arPos[3]

    ClientToScreen($hWnd, $x, $y)
    TrackPopupMenu($hWnd, $hMenu, $x, $y)

EndFunc   ;==>ShowMenu

Func ClientToScreen($hWnd, ByRef $x, ByRef $y)
    Local $stPoint = DllStructCreate("int;int")

    DllStructSetData($stPoint, 1, $x)
    DllStructSetData($stPoint, 2, $y)

    DllCall("user32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", DllStructGetPtr($stPoint))

    $x = DllStructGetData($stPoint, 1)
    $y = DllStructGetData($stPoint, 2)
    $stPoint = 0
EndFunc   ;==>ClientToScreen

Func TrackPopupMenu($hWnd, $hMenu, $x, $y)
    DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0)
EndFunc   ;==>TrackPopupMenu

#region glass functions for aero graphic environment (link at the top of the script)
Func _Vista_ApplyGlass($hWnd, $bColor = 0x000000)
        $Ret = DllCall("dwmapi.dll", "long", "DwmExtendFrameIntoClientArea", "hwnd", $hWnd, "long*", DllStructGetPtr($Struct))
        If @error Then
            Return 0
            Return $Ret
EndFunc ;==>_Vista_ApplyGlass

Func _Vista_ApplyGlassArea($hWnd, $Area, $bColor = 0x000000)
        If IsArray($Area) Then
            DllStructSetData($Struct, "cxLeftWidth", $Area[0])
            DllStructSetData($Struct, "cxRightWidth", $Area[1])
            DllStructSetData($Struct, "cyTopHeight", $Area[2])
            DllStructSetData($Struct, "cyBottomHeight", $Area[3])
            GUISetBkColor($bColor); Must be here!
            $Ret = DllCall("dwmapi.dll", "long*", "DwmExtendFrameIntoClientArea", "hwnd", $hWnd, "ptr", DllStructGetPtr($Struct))
            If @error Then
                Return 0
                Return $Ret
            MsgBox(16, "_Vista_ApplyGlassArea", "Area specified is not an array!")
EndFunc ;==>_Vista_ApplyGlassArea

Func _Draw_menus()
    _Draw_Menu_ex($FileGUI, 'File', $menuFontSize, $shine3, 0x000000)
    _Draw_Menu_ex($EditGUI, 'Edit', $menuFontSize, $shine3, 0x000000)
    _Draw_Menu_ex($HelpGUI, 'Help', $menuFontSize, $shine3, 0x000000)
    _Draw_Menu_ex($DownGUI, ChrW(9660), $menuFontSize-Round(Sqrt($menuFontSize)), $shine3, 0x555555)

Func _Draw_Menu_ex($WinHandle, $iCaption, $iSize, $iShine, $iColor)
    Local $hDC = _WinAPI_GetDC($WinHandle)
    Local $tClientRect = _WinAPI_GetClientRect($WinHandle)
    Local $sText = $iCaption
    Local $hFont = _WinAPI_CreateFont($iSize, $iSize/2-1, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _
    _DrawGlowingText($hDC, $sText, $tClientRect, $iShine, $hFont, $iColor)
    _WinAPI_ReleaseDC($WinHandle, $hDC)

#region making label shine in glass area (Link at the top of the script)
Func _DrawGlowingText($hDC, $sText, $tRc, $iGlowSize = 10, $hFont = 0, $iTextClr = -1)
    Local $hCDC
    Local $hBrush, $hOldBrush
    Local $tRcText
    Local $tBI, $tDTO
    Local $hDIBBmp, $hOldBmp
    Local $hOldFont
    Local $tST

    $hCDC = _WinAPI_CreateCompatibleDC($hDC)

    $tBI = DllStructCreate($tagBITMAPINFO)
    DllStructSetData($tBI, "Size", DllStructGetSize($tBI)-4)
    DllStructSetData($tBI, "Width", DllStructGetData($tRc, "Right")-DllStructGetData($tRc, "Left"))
    DllStructSetData($tBI, "Height", -(DllStructGetData($tRc, "Bottom")-DllStructGetData($tRc, "Top")))
    DllStructSetData($tBI, "Planes", 1)
    DllStructSetData($tBI, "BitCount", 32)
    DllStructSetData($tBI, "Compression", 0) ; BI_RGB

    $hDIBBmp = _WinAPI_CreateDIBSection($hDC, $tBI)
    $hOldBmp = _WinAPI_SelectObject($hCDC, $hDIBBmp)
    If $hFont Then $hOldFont = _WinAPI_SelectObject($hCDC, $hFont)

     $tDTO = DllStructCreate($tagDTTOPTS)
    DllStructSetData($tDTO, "Size", DllStructGetSize($tDTO))

    If $iTextClr <> -1 Then
        $iFlags = BitOR($iFlags, $DTT_TEXTCOLOR)
        DllStructSetData($tDTO, "clrText", $iTextClr)

    DllStructSetData($tDTO, "Flags", $iFlags)
    DllStructSetData($tDTO, "GlowSize", $iGlowSize)

    _WinAPI_DrawThemeTextEx($hTheme, $hCDC, 0, 0, $sText, _

    _WinAPI_BitBlt($hDC, DllStructGetData($tRc, "Left"), DllStructGetData($tRc, "Top"), _
        DllStructGetData($tRc, "Right")-DllStructGetData($tRc, "Left"), _
        DllStructGetData($tRc, "Bottom")-DllStructGetData($tRc, "Top"), $hCDC, 0, 0, 0xCC0020) ; SRCCOPY ;top+Sqrt($menuFontSize)

    _WinAPI_SelectObject($hCDC, $hOldBmp)
    If $hFont Then _WinAPI_SelectObject($hCDC, $hOldFont)

Func _WinAPI_CreateDIBSection($hDC, Const ByRef $tBmpInfo, $iUsage = 0, $pBits = 0, $hSecond = 0, $iOffset = 0)
    Local $aResult = DllCall("gdi32.dll", "hwnd", "CreateDIBSection", "hwnd", $hDC, "ptr", DllStructGetPtr($tBmpInfo), _
                        "uint", $iUsage, "ptr", $pBits, "hwnd", $hSecond, "uint", $iOffset)

    If @error Then Return SetError(@error, @extended, 0)
    If $aResult[0] = 87 Then Return SetError(1, 1, 0); 87 = ERROR_INVALID_PARAMETER
    If $aResult[0] = 0 Then Return SetError(1, 2, 0)
    Return SetError(0, 0, $aResult[0])

Func _WinAPI_DrawThemeTextEx($hTheme, $hDC, $iPartId, $iStateId, $sText, $iFlags, ByRef $tRect, Const ByRef $tDTTOPTS)
    Local $aResult = DllCall("uxtheme.dll", "int", "DrawThemeTextEx", "ptr", $hTheme, "hwnd", $hDC, "int", $iPartId, "int", $iStateId, _
                        "wstr", $sText, "int", -1, "uint", $iFlags, "ptr", DllStructGetPtr($tRect), "ptr", DllStructGetPtr($tDTTOPTS))

    If @error Then Return SetError(@error, @extended, 0)
    If $aResult[0] <> 0 Then Return SetError(1, 0, 0)
    Return SetError(0, 0, $aResult[0] = 0)

Func _WinAPI_OpenThemeData($hWnd, $sClassList)
    Local $aResult = DllCall("uxtheme.dll", "hwnd", "OpenThemeData", "hwnd", $hWnd, "wstr", $sClassList)

    If @error Then Return SetError(@error, @extended, 0)
    If $aResult[0] = 0 Then Return SetError(1, 0, 0)
    Return SetError(0, 0, $aResult[0])

Func _WinAPI_CloseThemeData($hTheme)
    Local $aResult = DllCall("uxtheme.dll", "int", "CloseThemeData", "hwnd", $hTheme)

    If @error Then Return SetError(@error, @extended, 0)
    Return SetError(0, 0, $aResult[0] = 0)

Func MY_PAINT($hWnd, $Msg, $wParam, $lParam)

Func _Create_7Image() ;drawn by myself xP
    Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($controlGui)
    Local $hbitmap = _GDIPlus_BitmapCreateFromGraphics($iwidth, $iheight, $hGraphic)
    Local $backbuffer = _GDIPlus_ImageGetGraphicsContext($hbitmap)
    Local $LetterSize = 36
    Local $Letter = '7'
    Local $hbrush = _GDIPlus_BrushCreateSolid(0xFF152a3d)
    Local $hbrushB = _GDIPlus_BrushCreateSolid(0xFF000000)
    Local $hbrush2 = _GDIPlus_BrushCreateSolid(0x3A152a3d)
    Local $hbrush3 = _GDIPlus_BrushCreateSolid(0x28FFFFFF)
    Local $hFormat = _GDIPlus_StringFormatCreate ()
    Local $hFamily = _GDIPlus_FontFamilyCreate ("Times New Roman")
    Local $hPen = _GDIPlus_PenCreate (0xFF454545)
    Local $hFont = _GDIPlus_FontCreate ($hFamily, $LetterSize, 1)
    Local $tLayout
    Local $tLayout2

    #region malkey's gradient example ;creating gradient
    Local $aFact[4]  = [0, 0.3, 0.6, 1.0]
    Local $aPosit[4] = [0.0, 0.3, 0.6, 1.0]
    Local $hBrushLin2 = gdiplus_CreateLineBrushFromRect($iX, $iY, $iWidth, $iHeight, $aFact, $aPosit, _
                                                            0xFF5078fb, 0xFF91e9ff, 0x00000002, 1)
    _GDIPlus_GraphicsFillRect($backbuffer, $iX, $iY, $iWidth, $iHeight, $hBrushLin2)

    Local $StartNum = 1 ;creating little pixels to add texture
    for $j = 1 to 48
        for $i = $StartNum to 48 step 3
            _GDIPlus_GraphicsFillRect($backbuffer, $i-1, $j-1, 1, 1, $hbrush2)
        $StartNum += 1
        If $StartNum > 3 then $StartNum = 1
    Local $3D_Depth = 3
    $tLayout2 = _GDIPlus_RectFCreate ($iX+7, $iY-1, $iWidth, $iHeight)
    _GDIPlus_GraphicsDrawStringEx ($backbuffer, $Letter, $hFont, $tLayout2, $hFormat, $hbrush2) ;creating shadow under character
    For $i = 1 to $3D_Depth
        $tLayout = _GDIPlus_RectFCreate ($iX+6-$i, $iY-$i-2, $iWidth-4, $iHeight+4)
        If $i = $3D_Depth then
            _GDIPlus_GraphicsDrawStringEx ($backbuffer, $Letter, $hFont, $tLayout, $hFormat, $hBrush) ;creating character
            _GDIPlus_GraphicsDrawStringEx ($backbuffer, $Letter, $hFont, $tLayout, $hFormat, $hBrushB) ;creating character depth

    Local $i_a = 48 ;ellipse points
    Local $i_b = 32
    For $j = 1 to 48
        For $i = 1 to 48
            if $i >= Sqrt($i_a^2-$i_a^2*$j^2/$i_b^2) then _GDIPlus_GraphicsFillRect($backbuffer, 48-$i, 48-$j, 1, 1, $hbrush3) ;creating gloss with ellipse equation

    _GDIPlus_GraphicsDrawRect($backbuffer, $iX, $iY, $iWidth-1, $iHeight-1, $hPen) ;boxing entire image with dark grey line

    Local $GC = _GDIPlus_ImageGetGraphicsContext($hbitmap)
    Local $newBmp = _GDIPlus_BitmapCreateFromGraphics($iwidth, $iheight, $GC)
    Local $newGC = _GDIPlus_ImageGetGraphicsContext($newBmp)
    _GDIPlus_GraphicsDrawImageRect($newGC, $hbitmap, 0, 0, $iwidth, $iheight)
    _GDIPlus_ImageSaveToFile($newBmp, $temp_image) ;saving created image - it's easier to show image and leave it there, than redrawing this entire thing
                                                    ;when GID+ gets disappeared
    _WinAPI_DeleteObject($hbitmap) ;disposing all the unneeded stuff
    _GDIPlus_PenDispose ($hPen)
    _GDIPlus_FontDispose ($hFont)
    _GDIPlus_FontFamilyDispose ($hFamily)
    _GDIPlus_StringFormatDispose ($hFormat)

#region drawing gradient by Malkey (link at the top of the script)
Func gdiplus_CreateLineBrushFromRect($iX, $iY, $iWidth, $iHeight, $aFactors, $aPositions, _
        $iArgb1 = 0xFF0000FF, $iArgb2 = 0xFFFF0000, $LinearGradientMode = 0x00000001, $WrapMode = 0)

    Local $tRect, $pRect, $aRet, $tFactors, $pFactors, $tPositions, $pPositions, $iCount

    If $iArgb1 = -1 Then $iArgb1 = 0xFF0000FF
    If $iArgb2 = -1 Then $iArgb2 = 0xFFFF0000
    If $LinearGradientMode = -1 Then $LinearGradientMode = 0x00000001
    If $WrapMode = -1 Then $WrapMode = 1

    $tRect = DllStructCreate("float X;float Y;float Width;float Height")
    $pRect = DllStructGetPtr($tRect)
    DllStructSetData($tRect, "X", $iX)
    DllStructSetData($tRect, "Y", $iY)
    DllStructSetData($tRect, "Width", $iWidth)
    DllStructSetData($tRect, "Height", $iHeight)

    ;Note: Withn _GDIPlus_Startup(), $ghGDIPDll is defined
    $aRet = DllCall($ghGDIPDll, "int", "GdipCreateLineBrushFromRect", "ptr", $pRect, "int", $iArgb1, _
            "int", $iArgb2, "int", $LinearGradientMode, "int", $WrapMode, "int*", 0)

    If IsArray($aFactors) = 0 Then Dim $aFactors[4] = [0.0, 0.4, 0.6, 1.0]
    If IsArray($aPositions) = 0 Then Dim $aPositions[4] = [0.0, 0.3, 0.7, 1.0]

    $iCount = UBound($aPositions)
    $tFactors = DllStructCreate("float[" & $iCount & "]")
    $pFactors = DllStructGetPtr($tFactors)
    For $iI = 0 To $iCount - 1
        DllStructSetData($tFactors, 1, $aFactors[$iI], $iI + 1)
    $tPositions = DllStructCreate("float[" & $iCount & "]")
    $pPositions = DllStructGetPtr($tPositions)
    For $iI = 0 To $iCount - 1
        DllStructSetData($tPositions, 1, $aPositions[$iI], $iI + 1)

    $hStatus = DllCall($ghGDIPDll, "int", "GdipSetLineBlend", "hwnd", $aRet[6], _
            "ptr", $pFactors, "ptr", $pPositions, "int", $iCount)
    Return $aRet[6] ; Handle of Line Brush
EndFunc   ;==>Gdiplus_CreateLineBrushFromRect

Func _CleanUp()
Edited by sandin

Share this post

Link to post
Share on other sites

So it's only for Vista+ :)

Btw, when exits after Vista message, there is syntax error (undeclared $hTheme).

  • Like 1



Using OS: Win 7 Professional, Using AutoIt Ver(s): /

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...


AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *





AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post

Link to post
Share on other sites

Pretty good.

The only thing I could think to add to make it better would be a gradient similar to the one found above the ribbon in office 2010.


Ok, so I had a little bit of a play around with the script, and it is pretty good. For the extended glass, did you use winAPI? I know there is a way to do the extended glass with winAPI, but I cannot remember the command for it.


Dont worry, I got it working now... quite interesting, that... Now to integrate the ribbon, the blur, and I will have a MSOffice 2010 ribbon like interface.

Edited by Mikeman27294

Share this post

Link to post
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
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.