Jump to content

Some interesting menu estetics


sandin
 Share

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/
#endregion

#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
Next

#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]
#endregion

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)
#endregion

#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)
#endregion

    _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

GUIRegisterMsg(0xF,"MY_PAINT")

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
            Exit
        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)
    EndSwitch
    #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)
    EndIf
    #endregion
WEnd

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)
                    EndIf
                    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)
                    EndIf
                    if ($HelpState <> 1) AND ($HelpMenu <> $i_MenuItem) Then
                        $HelpState = 1
                        _Draw_Menu_ex($HelpGUI, 'Help', $menuFontSize, $shine3, 0x000000)
                    EndIf
                    if ($DownState <> 1) AND ($DownMenu <> $i_MenuItem) Then
                        $DownState = 1
                        _Draw_Menu_ex($DownGUI, ChrW(9660), $menuFontSize-Round(Sqrt($menuFontSize)), $shine3, 0x555555)
                    EndIf
                    if ($ImageState <> 1) AND ($HoverImage <> $i_MenuItem) Then
                        $ImageState = 1
                        GUISetState(@SW_HIDE, $Mask)
                    EndIf
                    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)
                    Else
                        _Draw_Menu_ex($WinHWND, $i_Label, $menuFontSize, $shine1, 0x000099) ;clicked File menu state, drawing average glow, and red color
                    EndIf
                    ShowMenu($WinHWND, $i_MenuItem, $i_ContextMenu) ;showing context menu for File
                EndIf
            Else
                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)
                    Else
                        _Draw_Menu_ex($WinHWND, $i_Label, $menuFontSize, $shine2, 0x000000) ;high glow, black color
                    EndIf
                EndIf
            EndIf
        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)
                Else
                    _Draw_Menu_ex($WinHWND, $i_Label, $menuFontSize, $shine3, 0x000000) ;spread glow so there aren't any, black color
                EndIf
            EndIf
    EndSwitch
EndFunc

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
    EndIf
    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.
    EndIf
EndFunc

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)
        GUISetBkColor($bColor)
        $Ret = DllCall("dwmapi.dll", "long", "DwmExtendFrameIntoClientArea", "hwnd", $hWnd, "long*", DllStructGetPtr($Struct))
        If @error Then
            Return 0
            SetError(1)
        Else
            Return $Ret
        EndIf
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
            Else
                Return $Ret
            EndIf
        Else
            MsgBox(16, "_Vista_ApplyGlassArea", "Area specified is not an array!")
        EndIf
EndFunc ;==>_Vista_ApplyGlassArea
#endregion

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)
EndFunc

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, _
        $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'SegoeUI')
    _DrawGlowingText($hDC, $sText, $tClientRect, $iShine, $hFont, $iColor)
    _WinAPI_DeleteObject($hFont)
    _WinAPI_ReleaseDC($WinHandle, $hDC)
EndFunc

#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
    Local $iFlags = BitOR($DTT_GLOWSIZE, $DTT_COMPOSITED)

    $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)
    EndIf


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

    _WinAPI_DrawThemeTextEx($hTheme, $hCDC, 0, 0, $sText, _
        BitOR($DT_SINGLELINE, $DT_CENTER, $DT_VCENTER, $DT_NOPREFIX), $tRc, $tDTO)

    _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)
    _WinAPI_DeleteObject($hDIBBmp)
    _WinAPI_DeleteDC($hCDC)
EndFunc

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])
EndFunc

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)
EndFunc

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])
EndFunc

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)
EndFunc
#endregion

Func MY_PAINT($hWnd, $Msg, $wParam, $lParam)
    _Draw_menus()
    Return $GUI_RUNDEFMSG
EndFunc

Func _Create_7Image() ;drawn by myself xP
    _GDIPlus_Startup()
    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)
    #endregion

    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)
        Next
        $StartNum += 1
        If $StartNum > 3 then $StartNum = 1
    Next
    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
        Else
            _GDIPlus_GraphicsDrawStringEx ($backbuffer, $Letter, $hFont, $tLayout, $hFormat, $hBrushB) ;creating character depth
        EndIf
    Next

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

    _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_GraphicsDispose($backbuffer)
    _GDIPlus_GraphicsDispose($GC)
    _GDIPlus_GraphicsDispose($newGC)
    _GDIPlus_BitmapDispose($newBmp)
    _GDIPlus_BrushDispose($hBrushLin2)
    _GDIPlus_BrushDispose($hbrush)
    _GDIPlus_BrushDispose($hbrushB)
    _GDIPlus_BrushDispose($hbrush2)
    _GDIPlus_BrushDispose($hbrush3)
    _GDIPlus_PenDispose ($hPen)
    _GDIPlus_FontDispose ($hFont)
    _GDIPlus_FontFamilyDispose ($hFamily)
    _GDIPlus_StringFormatDispose ($hFormat)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_ImageDispose($temp_image)
    _GDIPlus_Shutdown()
EndFunc

#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)
    Next
    $tPositions = DllStructCreate("float[" & $iCount & "]")
    $pPositions = DllStructGetPtr($tPositions)
    For $iI = 0 To $iCount - 1
        DllStructSetData($tPositions, 1, $aPositions[$iI], $iI + 1)
    Next

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

Func _CleanUp()
    _WinAPI_CloseThemeData($hTheme)
    FileDelete($temp_image)
EndFunc
Edited by sandin
Link to comment
Share on other sites

So it's only for Vista+ :)

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

 

Spoiler

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

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

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
 
AutoIt_Icon_small.pngExamples: 
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 === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

  • 2 weeks later...

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.

EDIT

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.

EDIT 2

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