#include-once #AutoIt3Wrapper_AU3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 #include ; #INDEX# ======================================================================================================================= ; Title .........: Ribbons Bar ; UDF-Version....: 0.2.19 Beta ; UDF-History....: 20.05.09 - beginn Entwicklung v0.1 Beta ; 13.06.09 - erste Veröffentlichung v0.1 Beta ; 14.08.09 - beginn Entwicklung v0.2 Beta ; 15.10.09 - Veröffentlichung v0.2.19 Beta ; Autors.........: chrisatack ( autoit.de ) ; AutoIt Version : 3.3++ ; Language ......: Deutsch ; Description ...: Erstellt eine RibbonsBar wie in Office 2007. Es sind in der Grundversion alle 3 Farbstyles des Office 2007 ; verfügbar. ; Greetz.........: Großen Dank an autoit.de und besonders an MatthiasG. ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ; _RibbonsBar_ContextMenu_SetState ; _RibbonsBar_Create ; _RibbonsBar_Create_ContextMenu ; _RibbonsBar_Create_GrandButton ; _RibbonsBar_Create_SmallButton ; _RibbonsBar_Create_Tab ; _RibbonsBar_Create_TabItem ; _RibbonsBar_GetMsg ; _RibbonsBar_GrandButtons_SetState ; _RibbonsBar_SmallButtons_SetState ; _RibbonsBar_Tab_SetState ; _RibbonsBar_TabItems_SetState ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================ ; __RibbonsBar_CreateHandleCode ; __RibbonsBar_Array2DAdd ; __RibbonsBar_SetIconAlpha ; __RibbonsBar_ShellExtractIcons ; __RibbonsBar_IsPressed ; __RibbonsBar_SendMessage ; =============================================================================================================================== ; #ADD_THIS_TO(au3.api)#============================================================================================================ #cs _RibbonsBar_Create($hGui,$aX = 0,$aY = 0,$aWidth = 0 ,$Offset_Tabs_left = 0 , $Style = 'blue/black/silver' ) Erstellt den Barbereich und grenzt ihm mit einer Linie ab. _RibbonsBar_Create_Tab($hBar, $TabName) Erstellt einen Tab in der Bar. _RibbonsBar_Create_TabItem ( $hTab, $ItemName, $Width ) Erstellt ein TabItem mit Label in einem Tab. _RibbonsBar_TabItems_SetState($hTab ) Die TabItems eines Tabs werden angezeigt/versteckt. _RibbonsBar_GetMsg($hGui = 'auto' ) Ermittelt die Mousehovers und registriert die Klicks auf die einzelnen Tabs/Buttons in der Bar. Es wird auch das normale GUIGetMsg() vom Gui zurückgegeben. _RibbonsBar_Tab_SetState($hTab) Der Tab sammt TabItems und Buttons wird angezeigt/versteckt. _RibbonsBar_Create_GrandButton($hTabItem, $Icon_Path, $Icon_Nr, $ButtonName, $GB_Width = 52, $Arrow = False) Erstellt einen großen Button optional mit Pfeil für ein Kontextmenü. _RibbonsBar_GrandButtons_SetState($hTab) Die Buttons des Tabs werden angezeigt/versteckt. _RibbonsBar_ContextMenu_SetState($hContextMenue) Aktiviert ein Contextmenü an der linken unteren Ecke des GrandButton. _RibbonsBar_Create_ContextMenu($hGrandButton) Erstellt einen Handle für ein ContextMenü. _RibbonsBar_Create_SmallButton($hTabItem, $Icon_Path, $Icon_Nr, $RowPos = 1, $SButtonName = '',$Width =25) Erstellt einen SmallButton in einem TabItem. _RibbonsBar_SmallButtons_SetState($hTab) Die SmallButtons im Tab werden angezeigt/versteckt. #ce ; =============================================================================================================================== #include #include #include #Region Initalizing Opt("MouseCoordMode", 2) ; relative Koordinaten zum Anwendungsbereich des aktiven Fensters #cs Global $Bar_DLL = @ScriptDir&'\bar.dll' ; Pfad zur dll Datei mit den BarHG Icons Global $SmallIcons_DLL = @ScriptDir&'\SmallIcons.dll'; Pfad zur dll Datei mit allen SmallIcons Global $GrandIcons_DLL = @ScriptDir&'\grandIcons.dll'; Pfad zur dll Datei mit allen GrandIcons #ce #Region Changed autoBert 06.03.2023 avoiding multiple Icons.dll's Global $Bar_DLL = @CommonFilesDir & '\Ribbonsbar\bar.dll' ; Pfad zur dll Datei mit den BarHG Icons Global $SmallIcons_DLL = @CommonFilesDir & '\Ribbonsbar\SmallIcons.dll' ; Pfad zur dll Datei mit allen SmallIcons Global $GrandIcons_DLL = @CommonFilesDir & '\Ribbonsbar\grandIcons.dll' ; Pfad zur dll Datei mit allen GrandIcons #EndRegion Changed autoBert 06.03.2023 avoiding multiple Icons.dll's Global $aHeight = 120 ; Höhe für die Bar ( sollte auf 120 bleiben, da so alle Grafiken passen ) Global $Bar_Tab_was_Hover = 0 ; Tab Hover Speicher Global $Bar_GrandButton_was_Hover = 0 ; Grand Button Hover Speicher Global $Bar_SmallButton_was_Hover = 0 ; Small Button Hover Speicher Global $Bar_Context_was_Activ = 0 ; Context Menü Speicher Global $Bar_LastRowPos = 0 Global $Bar_HG_Color_Silver = 0xD0D4DD ; Color für den BarHG für des Styles silver Global $Bar_Bottom_Line_Color_Silve = 0xA9A9A9 ; Color für die BottomLine des Styles silver Global $Bar_TabItem_Label_Color_Silve = 0x4C535C ; Color für die TabItem Labels Global $Bar_Tab_Label_Color_Silve = 0x4C535C ; Color für die TAB Labels des Styles silver Global $Bar_Tab_Label_HoverColor_Silve = 0x4C535C ; Color für die Lables beim hover des Styles silver Global $Bar_HG_Color_Black = 0x535353 ; ... Global $Bar_Bottom_Line_Color_Black = 0x767676 ; Global $Bar_TabItem_Label_Color_Black = 0x000000 ; Global $Bar_Tab_Label_Color_Black = 0xffffff ; Global $Bar_Tab_Label_HoverColor_Black = 0x000000 ; Global $Bar_HG_Color_Blue = 0xBFDBFF ; Global $Bar_Bottom_Line_Color_Blue = 0x5585BA ; Global $Bar_TabItem_Label_Color_Blue = 0x15428B ; Global $Bar_Tab_Label_Color_Blue = 0x15428B ; Global $Bar_Tab_Label_HoverColor_Blue = 0x15428B ; Global $Bar_MainGuiHandle ; Gui in dem die Bar erstellt wird ( benötigt für _RibbonsBar_GetMsg() ) Global $Bar_Msg ; Messages, die die Bar zurückgibt Global $Style ; der augewählte Style ( silver,blue,black ) wie in Office Global $Bar_HG_Color ; Hintergrundfarbe der Bar ( je nach Style ) Global $Bar_Bottom_Line_Color ; Farbe der unteren Abschlusslinie ( je nach Style ) Global $Bar_TabItem_Label_Color ; Farbe der Item Labels ( je nach Style ) Global $Bar_Tab_Label_Color ; Farbe der Tab Labels ( je nach Style ) Global $Bar_Tab_Label_HoverColor ; Farbe der Tab Labels beim hover ( je nach Style ) Global $Bar_just_was_hover ; Speichert den Zeitstempel nach dem hover (verringert flackern der Buttons) Global $Bar_Create_Array[1][14] ; Hintergrund und erste Fläche für die Bar $Bar_Create_Array[0][0] = 'Handle' $Bar_Create_Array[0][1] = 'hGui' $Bar_Create_Array[0][2] = 'X' $Bar_Create_Array[0][3] = 'Y' $Bar_Create_Array[0][4] = 'Width' $Bar_Create_Array[0][5] = 'Height' $Bar_Create_Array[0][6] = 'Tab abstand links' $Bar_Create_Array[0][7] = 'Style' $Bar_Create_Array[0][8] = 'hLabel BarHG' $Bar_Create_Array[0][9] = 'hLabel BottomLine' $Bar_Create_Array[0][10] = 'hIcon Left' $Bar_Create_Array[0][11] = 'hIcon Center' $Bar_Create_Array[0][12] = 'hIcon Right' $Bar_Create_Array[0][13] = 'Offset Tabs links ( addiert )' Global $Bar_CreateTab_Array[1][18] ; einzelnen Tabs $Bar_CreateTab_Array[0][0] = 'Handle' $Bar_CreateTab_Array[0][1] = 'Handle Bar' $Bar_CreateTab_Array[0][2] = 'Name' $Bar_CreateTab_Array[0][3] = 'hIcon_Tab_Left' $Bar_CreateTab_Array[0][4] = 'hIcon_Tab_Center' $Bar_CreateTab_Array[0][5] = 'hIcon_Tab_Right' $Bar_CreateTab_Array[0][6] = 'hIcon_Tab_Left_hover' $Bar_CreateTab_Array[0][7] = 'hIcon_Tab_Center_hover' $Bar_CreateTab_Array[0][8] = 'hIcon_Tab_Right_hover' $Bar_CreateTab_Array[0][9] = 'hLable' $Bar_CreateTab_Array[0][10] = 'xStart' $Bar_CreateTab_Array[0][11] = 'yStart' $Bar_CreateTab_Array[0][12] = 'Width' $Bar_CreateTab_Array[0][13] = 'Height' $Bar_CreateTab_Array[0][14] = 'Visible' $Bar_CreateTab_Array[0][15] = 'Offset TabItems links ( addiert )' $Bar_CreateTab_Array[0][16] = 'Bar Style' $Bar_CreateTab_Array[0][17] = 'Handle Gui' Global $Bar_CreateTabItem_Array[1][14] ; die einzelnen Felder(Items) in den Tabs $Bar_CreateTabItem_Array[0][0] = 'Handle' $Bar_CreateTabItem_Array[0][1] = 'hTab' $Bar_CreateTabItem_Array[0][2] = 'Name' $Bar_CreateTabItem_Array[0][3] = 'Width' $Bar_CreateTabItem_Array[0][4] = 'hIcon_Item_Left' $Bar_CreateTabItem_Array[0][5] = 'hIcon_Item_Center' $Bar_CreateTabItem_Array[0][6] = 'hIcon_Item_Right' $Bar_CreateTabItem_Array[0][7] = 'hLabel' $Bar_CreateTabItem_Array[0][8] = 'Visible' $Bar_CreateTabItem_Array[0][9] = 'Offset Buttons links ( addiert )' $Bar_CreateTabItem_Array[0][10] = 'Bar Style' $Bar_CreateTabItem_Array[0][11] = 'Item X Start' $Bar_CreateTabItem_Array[0][12] = 'Item Y Start' $Bar_CreateTabItem_Array[0][13] = 'Handle Gui' Global $Bar_CreateGrandButton_Array[1][15] ;Große Buttons in den Tab Feldern(Items) $Bar_CreateGrandButton_Array[0][0] = 'Handle' $Bar_CreateGrandButton_Array[0][1] = 'hTabItem' $Bar_CreateGrandButton_Array[0][2] = 'hIcon Hover links' $Bar_CreateGrandButton_Array[0][3] = 'hIcon Hover mitte' $Bar_CreateGrandButton_Array[0][4] = 'hIcon Hover rechts' $Bar_CreateGrandButton_Array[0][5] = 'hLabel Arrow' $Bar_CreateGrandButton_Array[0][6] = 'hLabel ButtonBezeichnung' $Bar_CreateGrandButton_Array[0][7] = 'Button X Start' $Bar_CreateGrandButton_Array[0][8] = 'Button Y Start' $Bar_CreateGrandButton_Array[0][9] = 'Button Breite' $Bar_CreateGrandButton_Array[0][10] = 'Visible' $Bar_CreateGrandButton_Array[0][11] = 'hIcon Button' $Bar_CreateGrandButton_Array[0][12] = 'hTab' $Bar_CreateGrandButton_Array[0][13] = 'Handle Gui' $Bar_CreateGrandButton_Array[0][14] = 'Arrow True/False' Global $Bar_CreateContextMenue_Array[1][5] ;Contextmenü der Grand Buttons $Bar_CreateContextMenue_Array[0][0] = 'h Context' $Bar_CreateContextMenue_Array[0][1] = 'Context X Start' $Bar_CreateContextMenue_Array[0][2] = 'Context Y Start' $Bar_CreateContextMenue_Array[0][3] = 'Handle Gui' $Bar_CreateContextMenue_Array[0][4] = 'Control handle' Global $Bar_CreateSmallButton_Array[1][13] ;Small Buttons in den Tab Feldern(Items) $Bar_CreateSmallButton_Array[0][0] = 'Handle' $Bar_CreateSmallButton_Array[0][1] = 'hTabItem' $Bar_CreateSmallButton_Array[0][2] = 'hIcon Hover links' $Bar_CreateSmallButton_Array[0][3] = 'hIcon Hover mitte' $Bar_CreateSmallButton_Array[0][4] = 'hIcon Hover rechts' $Bar_CreateSmallButton_Array[0][5] = 'hLabel ButtonBezeichnung' $Bar_CreateSmallButton_Array[0][6] = 'Button X Start' $Bar_CreateSmallButton_Array[0][7] = 'Button Y Start' $Bar_CreateSmallButton_Array[0][8] = 'Button Breite' $Bar_CreateSmallButton_Array[0][9] = 'Visible' $Bar_CreateSmallButton_Array[0][10] = 'hIcon Button' $Bar_CreateSmallButton_Array[0][11] = 'hTab' $Bar_CreateSmallButton_Array[0][12] = 'Handle Gui' ;~ Global $i_hover_GButton #EndRegion Initalizing ; #FUNCTION# ==================================================================================================================== ; Name...........: _RibbonsBar_SmallButtons_SetState() ; Description ...: Die SmallButtons im Tab werden angezeigt/versteckt ; Parameters ....: $hTab - Handel des Tabs in dem die SmallButtons liegen ; Return values .: Erfolg - Die SmallButtons werden angezeigt/versteckt ; Fehler - @error 1 = Handle des Tabs konnte nicht gefunden werden ; Author ........: chrisatack ( autoit.de ) ; Remarks .......: Durchschnittiche Laufzeit ~ 0,1 ms ( Win7 2 x 2,5 GHz 3GB Ram ) ; =============================================================================================================================== Func _RibbonsBar_SmallButtons_SetState($hTab) ;ConsoleWrite('_RibbonsBar_SmallButtons_SetState ...' & @CRLF) Local $Button_found = False For $i = 1 To UBound($Bar_CreateSmallButton_Array) - 1 If $Bar_CreateSmallButton_Array[$i][9] == $GUI_SHOW Then GUICtrlSetState($Bar_CreateSmallButton_Array[$i][5], $GUI_HIDE) GUICtrlSetState($Bar_CreateSmallButton_Array[$i][10], $GUI_HIDE) $Bar_CreateSmallButton_Array[$i][9] = $GUI_HIDE EndIf If $Bar_CreateSmallButton_Array[$i][11] == $hTab And $Bar_CreateSmallButton_Array[$i][9] = $GUI_HIDE Then GUICtrlSetState($Bar_CreateSmallButton_Array[$i][5], $GUI_SHOW) GUICtrlSetState($Bar_CreateSmallButton_Array[$i][10], $GUI_SHOW) $Bar_CreateSmallButton_Array[$i][9] = $GUI_SHOW $Button_found = True EndIf Next If Not $Button_found Then SetError(1) Return 0 EndIf EndFunc ;==>_RibbonsBar_SmallButtons_SetState Func _RibbonsBar_SmallButtons_Enable($Smallbutton_handle, $State) ;ConsoleWrite('_RibbonsBar_SmallButtons_Enable ...' & @CRLF) For $i = 1 To UBound($Bar_CreateSmallButton_Array) - 1 If $Bar_CreateSmallButton_Array[$i][0] == $Smallbutton_handle Then If $State = 1 Then GUICtrlSetState($Bar_CreateSmallButton_Array[$i][5], $GUI_ENABLE) ElseIf $State = 0 Then GUICtrlSetState($Bar_CreateSmallButton_Array[$i][5], $GUI_DISABLE) EndIf ExitLoop EndIf Next EndFunc ;==>_RibbonsBar_SmallButtons_Enable Func _RibbonsBar_SmallButtons_GetState($Smallbutton_handle) ;ConsoleWrite('_RibbonsBar_SmallButtons_GetState ...' & @CRLF) For $i = 1 To UBound($Bar_CreateSmallButton_Array) - 1 If $Bar_CreateSmallButton_Array[$i][0] == $Smallbutton_handle Then If GUICtrlGetState($Bar_CreateSmallButton_Array[$i][5]) = 80 Then Return 1 Else Return 0 EndIf ExitLoop EndIf Next EndFunc ;==>_RibbonsBar_SmallButtons_GetState Func _RibbonsBar_GrandButtons_Enable($Grandbutton_handle, $State) ;ConsoleWrite('_RibbonsBar_GrandButtons_Enable ...' & @CRLF) For $i = 1 To UBound($Bar_CreateGrandButton_Array) - 1 If $Bar_CreateGrandButton_Array[$i][0] == $Grandbutton_handle Then If $State = 1 Then GUICtrlSetState($Bar_CreateGrandButton_Array[$i][5], $GUI_ENABLE) GUICtrlSetState($Bar_CreateGrandButton_Array[$i][6], $GUI_ENABLE) ElseIf $State = 0 Then GUICtrlSetState($Bar_CreateGrandButton_Array[$i][5], $GUI_DISABLE) GUICtrlSetState($Bar_CreateGrandButton_Array[$i][6], $GUI_DISABLE) EndIf ExitLoop EndIf Next EndFunc ;==>_RibbonsBar_GrandButtons_Enable Func _RibbonsBar_GrandButtons_GetState($Grandbutton_handle) ;ConsoleWrite('_RibbonsBar_GrandButtons_GetState ...' & @CRLF) For $i = 1 To UBound($Bar_CreateGrandButton_Array) - 1 If $Bar_CreateGrandButton_Array[$i][0] == $Grandbutton_handle Then If GUICtrlGetState($Bar_CreateGrandButton_Array[$i][6]) = 80 Then Return 1 Else Return 0 EndIf ExitLoop EndIf Next EndFunc ;==>_RibbonsBar_GrandButtons_GetState ; #FUNCTION# ==================================================================================================================== ; Name...........: _RibbonsBar_Create_SmallButton() ; Description ...: Erstellt einen SmallButton in einem TabItem ; Parameters ....: $hTabItem - Handel des TabItem in dem der SmallTab erstellt werden soll ; $Icon_Path - Pfad zum Icon (Wenn leer gelassen wird die Standart SmallButton.dll verwendet) ; $Icon_Nr - Wenn Standart SmallButton.dll verwendet wird hier IconNr bestimmen ansonsten leer lassen ; [$RowPos] - Zeile im TabItem ( 3 Zeilen möglich [ 1,2,3]) ; [$ButtonName] - Bezeichnung des SmallButton ; [$Width] - Breite des SButtons ; Return values .: Erfolg - Erstellt einen SmallButton in einem TabItem ; Fehler - @error 1 = Fehler in Parametereingabe ; - @error 2 = keine Icon Nr übergeben ( nur wenn $IconPath leer ist ) ; - @error 3 = Handle des TabItems nicht gefunden ; Author ........: chrisatack ( autoit.de ) ; Remarks .......: ; =============================================================================================================================== Func _RibbonsBar_Create_SmallButton($hTabItem, $Icon_Path, $Icon_Nr, $RowPos = 1, $SButtonName = '', $Width = 25) ;ConsoleWrite('_RibbonsBar_Create_SmallButton ...' & @CRLF) Local $AboveSmallButton_Y, $SButton_X_Start, $SButton_Y_Start, $hIcon_Button_hover_left, $hIcon_Button_hover_center, $hIcon_Button_hover_right Local $hIcon_SButton, $hLabel_Button, $Handle If $RowPos < 1 Or $RowPos > 3 Then SetError(1) Return 0 EndIf If Not $Icon_Path <> '' Then $Icon_Path = $SmallIcons_DLL If Not $Icon_Nr <> '' Then SetError(2) Return 0 EndIf EndIf If $RowPos == 1 Then $AboveSmallButton_Y = 0 ElseIf $RowPos == 2 Then $AboveSmallButton_Y = 22 ElseIf $RowPos == 3 Then $AboveSmallButton_Y = 44 EndIf For $i = 1 To UBound($Bar_CreateTabItem_Array) - 1 If $Bar_CreateTabItem_Array[$i][0] == $hTabItem Then If $Bar_LastRowPos >= $RowPos Then $Bar_CreateTabItem_Array[$i][9] += $Width - 4 EndIf $SButton_X_Start = $Bar_CreateTabItem_Array[$i][11] + $Bar_CreateTabItem_Array[$i][9] $SButton_Y_Start = $Bar_CreateTabItem_Array[$i][12] + 5 + $AboveSmallButton_Y $hIcon_Button_hover_left = GUICtrlCreateIcon($Bar_DLL, $Bar_CreateTabItem_Array[$i][10] & '16', $SButton_X_Start, $SButton_Y_Start - 3, 3, 22, 0) GUICtrlSetState(-1, $GUI_HIDE) $hIcon_Button_hover_center = GUICtrlCreateIcon($Bar_DLL, $Bar_CreateTabItem_Array[$i][10] & '17', $SButton_X_Start + 3, $SButton_Y_Start - 3, $Width - 6, 22, 0) GUICtrlSetState(-1, $GUI_HIDE) $hIcon_Button_hover_right = GUICtrlCreateIcon($Bar_DLL, $Bar_CreateTabItem_Array[$i][10] & '18', $SButton_X_Start + $Width - 6, $SButton_Y_Start - 3, 3, 22, 0) GUICtrlSetState(-1, $GUI_HIDE) $hIcon_SButton = GUICtrlCreatePic('', $SButton_X_Start + 3, $SButton_Y_Start, 16, 16) __RibbonsBar_SetIconAlpha($hIcon_SButton, $SmallIcons_DLL, $Icon_Nr - 1, 16, 16) GUICtrlSetState(-1, $GUI_HIDE) $hLabel_Button = GUICtrlCreateLabel($SButtonName, $SButton_X_Start + 23, $SButton_Y_Start + 1, $Width, 14) GUICtrlSetFont(-1, 8.9) GUICtrlSetColor(-1, $Bar_TabItem_Label_Color) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetState(-1, $GUI_HIDE) $Handle = __RibbonsBar_CreateHandleCode() $Bar_LastRowPos = $RowPos __RibbonsBar_Array2DAdd($Bar_CreateSmallButton_Array, $Handle & '|' _ ; 0 Handle des GandButton & $Bar_CreateTabItem_Array[$i][0] & '|' _ ; 1 Handle des TabItems & $hIcon_Button_hover_left & '|' _ ; 2 hIcon Hover links & $hIcon_Button_hover_center & '|' _ ; 3 hIcon Hover mitte & $hIcon_Button_hover_right & '|' _ ; 4 hIcon Hover rechts & $hLabel_Button & '|' _ ; 5 hLabel ButtonBezeichnung & $SButton_X_Start & '|' _ ; 6 Button X Start & $SButton_Y_Start & '|' _ ; 7 Button Y Start & $Width & '|' _ ; 8 Button Breite & $GUI_HIDE & '|' _ ; 9 Visible & $hIcon_SButton & '|' _ ; 10 hIcon Button & $Bar_CreateTabItem_Array[$i][1] & '|' _ ; 11 hTab & $Bar_CreateTabItem_Array[$i][13]) ; 12 Handle Gui Return $Handle EndIf Next SetError(3) Return 0 EndFunc ;==>_RibbonsBar_Create_SmallButton ; #FUNCTION# ==================================================================================================================== ; Name...........: _RibbonsBar_Create_ContextMenu() ; Description ...: Erstellt einen Handle für ein ContextMenü ; Parameters ....: $hGandButton - Handle des GrandButton unter dem das Contextmenü erstellt wird ; Return values .: Erfolg - Erstellt einen Handle für ein ContextMenü ; Fehler - @error 1 = GrandButton Handle nicht gefunden ; Author ........: chrisatack ( autoit.de ) ; Remarks .......: ; =============================================================================================================================== Func _RibbonsBar_Create_ContextMenu($hGrandButton) Local $Handle ;ConsoleWrite('_RibbonsBar_Create_ContextMenu ...' & @CRLF) For $i = 1 To UBound($Bar_CreateGrandButton_Array) - 1 If $Bar_CreateGrandButton_Array[$i][0] == $hGrandButton Then $Handle = GUICtrlCreateContextMenu(GUICtrlCreateDummy()) _SetMenuSelectBkColor(15788267) _SetMenuIconBkColor(0xffffff) __RibbonsBar_Array2DAdd($Bar_CreateContextMenue_Array, $Handle & '|' _ ; 0 Handle Context & $Bar_CreateGrandButton_Array[$i][7] & '|' _ ; 1 X Start & $Bar_CreateGrandButton_Array[$i][8] + 66 & '|' _ ; 2 Y Start & $Bar_CreateGrandButton_Array[$i][13] & '|' _ ; 3 hGui & $Bar_CreateGrandButton_Array[$i][0]) ; 4 handle Return $Handle EndIf Next SetError(1) Return 0 EndFunc ;==>_RibbonsBar_Create_ContextMenu ; #FUNCTION# ==================================================================================================================== ; Name...........: _RibbonsBar_SubMenu_SetState() ; Description ...: Aktiviert ein Contextmenü an der linken unteren Ecke des GrandButton ; Parameters ....: $hWnd - Handle des Guis ; Return values .: Erfolg - Aktiviert ein Contextmenü an der stelle der $x und $y Koardinaten ; Fehler - @error 1 = Context Handle nicht gefunden ; Author ........: funkey( autoit.de ) modified by chrisatack ( autoit.de ) ; Remarks .......: n/a ; =============================================================================================================================== Func _RibbonsBar_ContextMenu_SetState($hContextMenue) ;ConsoleWrite('_RibbonsBar_ContextMenu_SetState ...' & @CRLF) Local $x, $y, $hWnd, $hMenu, $stPoint For $i = 1 To UBound($Bar_CreateContextMenue_Array) - 1 If $Bar_CreateContextMenue_Array[$i][0] == $hContextMenue Then If $Bar_CreateGrandButton_Array[$Bar_GrandButton_was_Hover][0] == $Bar_CreateContextMenue_Array[$i][4] And _RibbonsBar_GrandButtons_GetState($Bar_CreateGrandButton_Array[$Bar_GrandButton_was_Hover][0]) <> 0 Then $x = $Bar_CreateContextMenue_Array[$i][1] $y = $Bar_CreateContextMenue_Array[$i][2] $hWnd = $Bar_CreateContextMenue_Array[$i][3] $hMenu = GUICtrlGetHandle($hContextMenue) $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) DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0) $Bar_Context_was_Activ = 1 Return 1 Else If _RibbonsBar_GrandButtons_GetState($Bar_CreateGrandButton_Array[$Bar_GrandButton_was_Hover][0]) <> 0 Then $Bar_Context_was_Activ = 0 GUICtrlSetState($Bar_CreateGrandButton_Array[$Bar_GrandButton_was_Hover][2], $GUI_HIDE) GUICtrlSetState($Bar_CreateGrandButton_Array[$Bar_GrandButton_was_Hover][3], $GUI_HIDE) GUICtrlSetState($Bar_CreateGrandButton_Array[$Bar_GrandButton_was_Hover][4], $GUI_HIDE) $Bar_GrandButton_was_Hover = 0 EndIf EndIf EndIf Next SetError(1) Return 0 EndFunc ;==>_RibbonsBar_ContextMenu_SetState ; #FUNCTION# ==================================================================================================================== ; Name...........: _RibbonsBar_GrandButtons_SetState() ; Description ...: Die Buttons des Tabs werden angezeigt/versteckt ; Parameters ....: $hTab - Handel des Tabs in dem die Buttons liegen ; Return values .: Erfolg - Die Buttons werden angezeigt/versteckt ; Fehler - @error 1 = Handle des Tabs konnte nicht gefunden werden ; Author ........: chrisatack ( autoit.de ) ; Remarks .......: Durchschnittiche Laufzeit ~ 0,1 ms ( Win7 2 x 2,5 GHz 3GB Ram ) ; =============================================================================================================================== Func _RibbonsBar_GrandButtons_SetState($hTab) ;ConsoleWrite('_RibbonsBar_GrandButtons_SetState ...' & @CRLF) Local $Button_found = False For $i = 1 To UBound($Bar_CreateGrandButton_Array) - 1 If $Bar_CreateGrandButton_Array[$i][10] == $GUI_SHOW Then GUICtrlSetState($Bar_CreateGrandButton_Array[$i][5], $GUI_HIDE) GUICtrlSetState($Bar_CreateGrandButton_Array[$i][6], $GUI_HIDE) GUICtrlSetState($Bar_CreateGrandButton_Array[$i][11], $GUI_HIDE) $Bar_CreateGrandButton_Array[$i][10] = $GUI_HIDE EndIf If $Bar_CreateGrandButton_Array[$i][12] == $hTab And $Bar_CreateGrandButton_Array[$i][10] = $GUI_HIDE Then GUICtrlSetState($Bar_CreateGrandButton_Array[$i][5], $GUI_SHOW) GUICtrlSetState($Bar_CreateGrandButton_Array[$i][6], $GUI_SHOW) GUICtrlSetState($Bar_CreateGrandButton_Array[$i][11], $GUI_SHOW) $Bar_CreateGrandButton_Array[$i][10] = $GUI_SHOW $Button_found = True EndIf Next If Not $Button_found Then SetError(1) Return 0 EndIf EndFunc ;==>_RibbonsBar_GrandButtons_SetState ; #FUNCTION# ==================================================================================================================== ; Name...........: _RibbonsBar_Create_GrandButton() ; Description ...: Erstellt einen großen Button optional mit Pfeil für ein Kontextmenü ; Parameters ....: $hTabItem - Handle des Tabitems in dem der Buton erstellt werden soll ; $Icon_Path - Pfad zu dem Icon des Button ( muss 35x35 pixel haben ) ; $ButtonName - Bezeichnung des Buttons ; [$With] - Breite des Buttons ; [$Arrow] - Pfeil zum öffnen des Kontextmenü ( True oder False ) ; Return values .: Erfolg - Erstellt einen GrandButton ; Fehler - @error 1 = Fehler in Parametereingabe ; - @error 2 = keine Icon Nr übergeben ( nur wenn $IconPath leer ist ) ; - @error 3 = Findet TabItem Handle nicht ; Author ........: chrisatack ( autoit.de ) ; Remarks .......: Durchschnittiche Laufzeit ~ 5,8 ms ( Win7 2 x 2,5 GHz 3GB Ram ) ; =============================================================================================================================== Func _RibbonsBar_Create_GrandButton($hTabItem, $Icon_Path, $Icon_Nr, $ButtonName, $GB_Width = 52, $Arrow = False) ;ConsoleWrite('_RibbonsBar_Create_GrandButton ...' & @CRLF) Local $bar_ico_l, $bar_ico_m, $bar_ico_r, $Button_X_Start, $Button_Y_Start, $hIcon_Button_hover_left, $hIcon_Button_hover_center, $hIcon_Button_hover_right Local $hIcon_Button, $hLabel_Button_Arrow, $hLabel_Button, $Handle If Not FileExists($Icon_Path) And Not $ButtonName <> '' Then SetError(1) Return 0 EndIf If Not $Icon_Path <> '' Then $Icon_Path = $GrandIcons_DLL If Not $Icon_Nr <> '' Then SetError(2) Return 0 EndIf EndIf If Not $GB_Width <> '' Then $GB_Width = 52 EndIf For $i = 1 To UBound($Bar_CreateTabItem_Array) - 1 If $Arrow Then $bar_ico_l = '13' $bar_ico_m = '14' $bar_ico_r = '15' Else $bar_ico_l = '19' $bar_ico_m = '20' $bar_ico_r = '21' EndIf If $Bar_CreateTabItem_Array[$i][0] == $hTabItem Then $Button_X_Start = $Bar_CreateTabItem_Array[$i][11] + $Bar_CreateTabItem_Array[$i][9] $Button_Y_Start = $Bar_CreateTabItem_Array[$i][12] + 2 $hIcon_Button_hover_left = GUICtrlCreateIcon($Bar_DLL, $Bar_CreateTabItem_Array[$i][10] & $bar_ico_l, $Button_X_Start, $Button_Y_Start, 3, 66, 0) GUICtrlSetState(-1, $GUI_HIDE) $hIcon_Button_hover_center = GUICtrlCreateIcon($Bar_DLL, $Bar_CreateTabItem_Array[$i][10] & $bar_ico_m, $Button_X_Start + 3, $Button_Y_Start, $GB_Width - 6, 66, 0) GUICtrlSetState(-1, $GUI_HIDE) $hIcon_Button_hover_right = GUICtrlCreateIcon($Bar_DLL, $Bar_CreateTabItem_Array[$i][10] & $bar_ico_r, $Button_X_Start + $GB_Width - 3, $Button_Y_Start, 3, 66, 0) GUICtrlSetState(-1, $GUI_HIDE) $hIcon_Button = GUICtrlCreatePic('', $Button_X_Start + ($GB_Width / 2) - (32 / 2), $Button_Y_Start + 2, 32, 32) __RibbonsBar_SetIconAlpha($hIcon_Button, $Icon_Path, $Icon_Nr - 1, 32, 32) GUICtrlSetState(-1, $GUI_HIDE) If $Arrow Then $hLabel_Button_Arrow = GUICtrlCreateLabel('q', $Button_X_Start, $Button_Y_Start + 54, $GB_Width, 8, $SS_CENTER + $SS_CENTERIMAGE) GUICtrlSetFont(-1, 5, 400, 0, 'Wingdings 3') GUICtrlSetColor(-1, $Bar_TabItem_Label_Color) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetState(-1, $GUI_HIDE) Else $hLabel_Button_Arrow = False EndIf $hLabel_Button = GUICtrlCreateLabel($ButtonName, $Button_X_Start + 1, $Button_Y_Start + 37, $GB_Width, 27, $SS_CENTER) ;, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 8.9) GUICtrlSetColor(-1, $Bar_TabItem_Label_Color) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetState(-1, $GUI_HIDE) $Bar_CreateTabItem_Array[$i][9] += $GB_Width $Handle = __RibbonsBar_CreateHandleCode() __RibbonsBar_Array2DAdd($Bar_CreateGrandButton_Array, $Handle & '|' _ ; 0 Handle des GandButton & $hTabItem & '|' _ ; 1 Handle des TabItems & $hIcon_Button_hover_left & '|' _ ; 2 Handle des Hover Icons links & $hIcon_Button_hover_center & '|' _ ; 3 Handle des Hover Icons mitte & $hIcon_Button_hover_right & '|' _ ; 4 Handle des Hover Icons rechts & $hLabel_Button_Arrow & '|' _ ; 5 Handle des Pfeil Labels & $hLabel_Button & '|' _ ; 6 Handle des Button bezeichnenden Labels & $Button_X_Start & '|' _ ; 7 Button X Start & $Button_Y_Start & '|' _ ; 8 Button Y Start & $GB_Width & '|' _ ; 9 Button Breite & $GUI_HIDE & '|' _ ; 10 Visible & $hIcon_Button & '|' _ ; 11 Handle des ButtonIcons & $Bar_CreateTabItem_Array[$i][1] & '|' _ ; 12 Handle des überliegenden Tabs & $Bar_CreateTabItem_Array[$i][13] & '|' _ ; 13 Handle Gui & $Arrow) ; 14 Arrow True/False Return $Handle EndIf Next SetError(3) Return 0 EndFunc ;==>_RibbonsBar_Create_GrandButton ; #FUNCTION# ==================================================================================================================== ; Name...........: _RibbonsBar_Tab_SetState ; Description ...: Der Tab sammt TabItems und Buttons wird angezeigt/versteckt ; Parameters ....: $hTab - Handle des Tab Items ; Return values .: Erfolg - Der Tab sammt TabItems wird angezeigt/versteckt ; Fehler - @error 1 = Der TabHandle wurde nicht gefunden ; Author ........: chrisatack ( autoit.de ) ; Remarks .......: Durchschnittiche Laufzeit ~ 0,33 ms ( Win7 2 x 2,5 GHz 3GB Ram ) ; =============================================================================================================================== Func _RibbonsBar_Tab_SetState($hTab) ;ConsoleWrite('_RibbonsBar_Tab_SetState ...' & @CRLF) For $i = 1 To UBound($Bar_CreateTab_Array) - 1 If $Bar_CreateTab_Array[$i][14] = $GUI_SHOW Then GUICtrlSetState($Bar_CreateTab_Array[$i][3], $GUI_HIDE) GUICtrlSetState($Bar_CreateTab_Array[$i][4], $GUI_HIDE) GUICtrlSetState($Bar_CreateTab_Array[$i][5], $GUI_HIDE) GUICtrlSetColor($Bar_CreateTab_Array[$i][9], $Bar_Tab_Label_Color) $Bar_CreateTab_Array[$i][14] = $GUI_HIDE EndIf If $Bar_CreateTab_Array[$i][0] == $hTab And $Bar_CreateTab_Array[$i][14] = $GUI_HIDE Then GUICtrlSetState($Bar_CreateTab_Array[$i][3], $GUI_SHOW) GUICtrlSetState($Bar_CreateTab_Array[$i][4], $GUI_SHOW) GUICtrlSetState($Bar_CreateTab_Array[$i][5], $GUI_SHOW) GUICtrlSetColor($Bar_CreateTab_Array[$i][9], $Bar_Tab_Label_HoverColor) $Bar_CreateTab_Array[$i][14] = $GUI_SHOW _RibbonsBar_TabItems_SetState($hTab) _RibbonsBar_GrandButtons_SetState($hTab) _RibbonsBar_SmallButtons_SetState($hTab) EndIf Next SetError(1) Return 0 EndFunc ;==>_RibbonsBar_Tab_SetState ; #FUNCTION# ==================================================================================================================== ; Name...........: _RibbonsBar_GetMsg() ; Description ...: Ermittelt die Mousehovers und registriert die Klicks auf die einzelnen Tabs/Buttons in der Bar ; Es wird auch das normale GUIGetMsg() vom Gui zurückgegeben ; Parameters ....: [$hGui] - (Handle des Guis indem sich die Bar befindet) ; Return values .: Erfolg - Handle der Aktion ; Fehler - keine Rückgabe ; Author ........: chrisatack ( autoit.de ) ; Remarks .......: Durchschnittiche Laufzeit ~ 0,28 ms ( Win7 2 x 2,5 GHz 3GB Ram )[kommt auf die Anzahl der Buttons an] ; =============================================================================================================================== Func _RibbonsBar_GetMsg($hGui = $Bar_MainGuiHandle) Local $aMousePos = MouseGetPos() Local $i_hover_Tab, $i_hover_GButton, $i_hover_SButton If WinActive($hGui) And TimerDiff($Bar_just_was_hover) > 40 Then ;---------------------------------------------------------------------- ; T A B S ;---------------------------------------------------------------------- For $i = 1 To UBound($Bar_CreateTab_Array) - 1 If $aMousePos[0] > $Bar_CreateTab_Array[$i][10] And _ $aMousePos[0] < $Bar_CreateTab_Array[$i][10] + $Bar_CreateTab_Array[$i][12] + 10 And _ $aMousePos[1] > $Bar_CreateTab_Array[$i][11] And _ $aMousePos[1] < $Bar_CreateTab_Array[$i][11] + 23 And _ $Bar_CreateTab_Array[$i][14] == $GUI_HIDE Then If $Bar_Tab_was_Hover == 0 Then GUICtrlSetState($Bar_CreateTab_Array[$i][6], $GUI_SHOW) GUICtrlSetState($Bar_CreateTab_Array[$i][7], $GUI_SHOW) GUICtrlSetState($Bar_CreateTab_Array[$i][8], $GUI_SHOW) $Bar_Tab_was_Hover = $i EndIf If __RibbonsBar_IsPressed(01) Then $Bar_Tab_was_Hover = 0 GUICtrlSetState($Bar_CreateTab_Array[$i][6], $GUI_HIDE) GUICtrlSetState($Bar_CreateTab_Array[$i][7], $GUI_HIDE) GUICtrlSetState($Bar_CreateTab_Array[$i][8], $GUI_HIDE) MouseUp('left') $Bar_just_was_hover = TimerInit() Return $Bar_CreateTab_Array[$i][0] EndIf EndIf If $Bar_Tab_was_Hover > 0 Then $i_hover_Tab = $Bar_Tab_was_Hover If ($aMousePos[0]) < ($Bar_CreateTab_Array[$i_hover_Tab][10]) Or _ ($aMousePos[0]) > ($Bar_CreateTab_Array[$i_hover_Tab][10] + $Bar_CreateTab_Array[$i_hover_Tab][12] + 10) Or _ ($aMousePos[1]) < ($Bar_CreateTab_Array[$i_hover_Tab][11]) Or _ ($aMousePos[1]) > ($Bar_CreateTab_Array[$i_hover_Tab][11] + 23) Then $Bar_Tab_was_Hover = 0 GUICtrlSetState($Bar_CreateTab_Array[$i_hover_Tab][6], $GUI_HIDE) GUICtrlSetState($Bar_CreateTab_Array[$i_hover_Tab][7], $GUI_HIDE) GUICtrlSetState($Bar_CreateTab_Array[$i_hover_Tab][8], $GUI_HIDE) $Bar_just_was_hover = TimerInit() EndIf EndIf Next ;---------------------------------------------------------------------- ; G R A N D B U T T O N S ;---------------------------------------------------------------------- For $i = 1 To UBound($Bar_CreateGrandButton_Array) - 1 If $aMousePos[0] > $Bar_CreateGrandButton_Array[$i][7] And _ $aMousePos[0] < ($Bar_CreateGrandButton_Array[$i][7] + $Bar_CreateGrandButton_Array[$i][9]) And _ $aMousePos[1] > $Bar_CreateGrandButton_Array[$i][8] And _ $aMousePos[1] < $Bar_CreateGrandButton_Array[$i][8] + 66 And _ $Bar_CreateGrandButton_Array[$i][10] == $GUI_SHOW Then If $Bar_GrandButton_was_Hover == 0 Then GUICtrlSetState($Bar_CreateGrandButton_Array[$i][2], $GUI_SHOW) GUICtrlSetState($Bar_CreateGrandButton_Array[$i][3], $GUI_SHOW) GUICtrlSetState($Bar_CreateGrandButton_Array[$i][4], $GUI_SHOW) $Bar_GrandButton_was_Hover = $i EndIf If __RibbonsBar_IsPressed(01) Then If $Bar_CreateGrandButton_Array[$i][14] == False Then MouseUp('left') $Bar_just_was_hover = TimerInit() EndIf Return $Bar_CreateGrandButton_Array[$i][0] EndIf EndIf If $Bar_GrandButton_was_Hover > 0 Then $i_hover_GButton = $Bar_GrandButton_was_Hover If ($aMousePos[0]) < ($Bar_CreateGrandButton_Array[$i_hover_GButton][7]) Or _ ($aMousePos[0]) > ($Bar_CreateGrandButton_Array[$i_hover_GButton][7] + $Bar_CreateGrandButton_Array[$i_hover_GButton][9]) Or _ ($aMousePos[1]) < ($Bar_CreateGrandButton_Array[$i_hover_GButton][8]) Or _ ($aMousePos[1]) > ($Bar_CreateGrandButton_Array[$i_hover_GButton][8] + 66) Then $Bar_GrandButton_was_Hover = 0 GUICtrlSetState($Bar_CreateGrandButton_Array[$i_hover_GButton][2], $GUI_HIDE) GUICtrlSetState($Bar_CreateGrandButton_Array[$i_hover_GButton][3], $GUI_HIDE) GUICtrlSetState($Bar_CreateGrandButton_Array[$i_hover_GButton][4], $GUI_HIDE) $Bar_just_was_hover = TimerInit() EndIf EndIf ;---------------------------------------------------------------------- ; C O N T E X T M E N Ü ( Hover rücksetzung bei den Grand Buttons ) ;---------------------------------------------------------------------- If $Bar_Context_was_Activ > 0 Then $Bar_Context_was_Activ = 0 $Bar_GrandButton_was_Hover = 0 GUICtrlSetState($Bar_CreateGrandButton_Array[$i][2], $GUI_HIDE) GUICtrlSetState($Bar_CreateGrandButton_Array[$i][3], $GUI_HIDE) GUICtrlSetState($Bar_CreateGrandButton_Array[$i][4], $GUI_HIDE) $Bar_just_was_hover = TimerInit() EndIf Next ;---------------------------------------------------------------------- ; S M A L L B U T T O N S ;---------------------------------------------------------------------- For $i = 1 To UBound($Bar_CreateSmallButton_Array) - 1 If $aMousePos[0] > $Bar_CreateSmallButton_Array[$i][6] And _ $aMousePos[0] < ($Bar_CreateSmallButton_Array[$i][6] + $Bar_CreateSmallButton_Array[$i][8] - 4) And _ $aMousePos[1] > $Bar_CreateSmallButton_Array[$i][7] - 2 And _ $aMousePos[1] < $Bar_CreateSmallButton_Array[$i][7] + 18 And _ $Bar_CreateSmallButton_Array[$i][9] == $GUI_SHOW Then If $Bar_SmallButton_was_Hover == 0 Then GUICtrlSetState($Bar_CreateSmallButton_Array[$i][2], $GUI_SHOW) GUICtrlSetState($Bar_CreateSmallButton_Array[$i][3], $GUI_SHOW) GUICtrlSetState($Bar_CreateSmallButton_Array[$i][4], $GUI_SHOW) $Bar_SmallButton_was_Hover = $i EndIf If __RibbonsBar_IsPressed(01) Then MouseUp('left') $Bar_just_was_hover = TimerInit() Return $Bar_CreateSmallButton_Array[$i][0] EndIf EndIf If $Bar_SmallButton_was_Hover > 0 Then $i_hover_SButton = $Bar_SmallButton_was_Hover If ($aMousePos[0]) < ($Bar_CreateSmallButton_Array[$i_hover_SButton][6]) Or _ ($aMousePos[0]) > ($Bar_CreateSmallButton_Array[$i_hover_SButton][6] + $Bar_CreateSmallButton_Array[$i_hover_SButton][8] - 4) Or _ ($aMousePos[1]) < ($Bar_CreateSmallButton_Array[$i_hover_SButton][7] - 2) Or _ ($aMousePos[1]) > ($Bar_CreateSmallButton_Array[$i_hover_SButton][7] + 18) Then $Bar_SmallButton_was_Hover = 0 GUICtrlSetState($Bar_CreateSmallButton_Array[$i_hover_SButton][2], $GUI_HIDE) GUICtrlSetState($Bar_CreateSmallButton_Array[$i_hover_SButton][3], $GUI_HIDE) GUICtrlSetState($Bar_CreateSmallButton_Array[$i_hover_SButton][4], $GUI_HIDE) $Bar_just_was_hover = TimerInit() EndIf EndIf Next EndIf Return '' EndFunc ;==>_RibbonsBar_GetMsg ; #FUNCTION# ==================================================================================================================== ; Name...........: _RibbonsBar_Tab_SetState() ; Description ...: Die TabItems eines Tabs werden angezeigt/versteckt ; Parameters ....: $hTab - Handle des Tab ; Return values .: Erfolg - Das TabItem wir angezeigt/versteckt ; Fehler - @error 1 = TabItem Handle nicht gefunden ; Author ........: chrisatack ( autoit.de ) ; Remarks .......: Durchschnittiche Laufzeit ~ 0,15 ms ( Win7 2 x 2,5 GHz 3GB Ram ) kommt drauf an wieviele Tabs in der Bar sind ; =============================================================================================================================== Func _RibbonsBar_TabItems_SetState($hTab) ;ConsoleWrite('_RibbonsBar_TabItems_SetState ...' & @CRLF) Local $Item_found = False For $i = 1 To UBound($Bar_CreateTabItem_Array) - 1 If $Bar_CreateTabItem_Array[$i][8] == $GUI_SHOW Then GUICtrlSetState($Bar_CreateTabItem_Array[$i][4], $GUI_HIDE) GUICtrlSetState($Bar_CreateTabItem_Array[$i][5], $GUI_HIDE) GUICtrlSetState($Bar_CreateTabItem_Array[$i][6], $GUI_HIDE) GUICtrlSetState($Bar_CreateTabItem_Array[$i][7], $GUI_HIDE) $Bar_CreateTabItem_Array[$i][8] = $GUI_HIDE $Item_found = True EndIf If $Bar_CreateTabItem_Array[$i][1] == $hTab And $Bar_CreateTabItem_Array[$i][8] = $GUI_HIDE Then GUICtrlSetState($Bar_CreateTabItem_Array[$i][4], $GUI_SHOW) GUICtrlSetState($Bar_CreateTabItem_Array[$i][5], $GUI_SHOW) GUICtrlSetState($Bar_CreateTabItem_Array[$i][6], $GUI_SHOW) GUICtrlSetState($Bar_CreateTabItem_Array[$i][7], $GUI_SHOW) $Bar_CreateTabItem_Array[$i][8] = $GUI_SHOW $Item_found = True EndIf Next If Not $Item_found Then SetError(1) Return 0 EndIf EndFunc ;==>_RibbonsBar_TabItems_SetState ; #FUNCTION# ==================================================================================================================== ; Name...........: _RibbonsBar_Create_TabItem() ; Description ...: Erstellt ein TabItem mit einem Label ; Parameters ....: $hTab - Handle des Tabs ; $ItemName - Bezeichnung des TabItems ; $Width - Breite des TabItems ; Return values .: Erfolg - erstellt ein TabItem ; Fehler - @error 1 = Fehler in Parametereingabe ; - @error 2 = Kann den Bar Handle nicht finden ; - @error 3 = Kann den Tab Handle nicht finden ; Author ........: chrisatack ( autoit.de ) ; Remarks .......: Durchschnittiche Laufzeit ~ 3 ms ( Win7 2 x 2,5 GHz 3GB Ram ) ; =============================================================================================================================== Func _RibbonsBar_Create_TabItem($hTab, $ItemName, $Width) ;ConsoleWrite('_RibbonsBar_Create_TabItem ...' & @CRLF) Local $Item_X_Start, $Item_Y_Start, $hIcon_Item_Left, $hIcon_Item_Center, $hIcon_Item_Right, $Label_Item, $Handle If Not $ItemName <> '' And Not IsNumber($Width) Then SetError(1) Return 0 EndIf For $i = 1 To UBound($Bar_CreateTab_Array) - 1 If $Bar_CreateTab_Array[$i][0] == $hTab Then For $i2 = 1 To UBound($Bar_Create_Array) - 1 If $Bar_Create_Array[$i2][0] == $Bar_CreateTab_Array[$i][1] Then ; Bar X Start Offset andere Items $Item_X_Start = $Bar_Create_Array[$i2][2] + $Bar_CreateTab_Array[$i][15] $Item_Y_Start = $Bar_Create_Array[$i2][3] + 28 $hIcon_Item_Left = GUICtrlCreateIcon($Bar_DLL, $Bar_Create_Array[$i2][7] & '10', $Item_X_Start, $Item_Y_Start, 3, 85, 0) GUICtrlSetState(-1, $GUI_HIDE) $hIcon_Item_Center = GUICtrlCreateIcon($Bar_DLL, $Bar_Create_Array[$i2][7] & '11', $Item_X_Start + 3, $Item_Y_Start, $Width - 6, 85, 0) GUICtrlSetState(-1, $GUI_HIDE) $hIcon_Item_Right = GUICtrlCreateIcon($Bar_DLL, $Bar_Create_Array[$i2][7] & '12', $Item_X_Start + $Width - 6, $Item_Y_Start, 3, 85, 0) GUICtrlSetState(-1, $GUI_HIDE) $Label_Item = GUICtrlCreateLabel($ItemName, $Item_X_Start, $Item_Y_Start + 70, $Width - 4, 13, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 8.9) GUICtrlSetColor(-1, $Bar_TabItem_Label_Color) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetState(-1, $GUI_HIDE) $Bar_CreateTab_Array[$i][15] += $Width - 1 $Handle = __RibbonsBar_CreateHandleCode() __RibbonsBar_Array2DAdd($Bar_CreateTabItem_Array, $Handle & '|' _ ; 0 Handle des TabItems & $hTab & '|' _ ; 1 Handle des Tab & $ItemName & '|' _ ; 2 Beschreibung des TabItems & $Width & '|' _ ; 3 Breite des TabItems & $hIcon_Item_Left & '|' _ ; 4 Handle des linken HG Icons & $hIcon_Item_Center & '|' _ ; 5 Handle des mittleren HG Icons & $hIcon_Item_Right & '|' _ ; 6 Handle des rechten HG Icons & $Label_Item & '|' _ ; 7 Handle des TabItem Labels & $GUI_HIDE & '|' _ ; 8 Visible & 5 & '|' _ ; 9 Offset Buttons links ( addiert ) & $Bar_CreateTab_Array[$i][16] & '|' _ ; 10 Bar Style & $Item_X_Start & '|' _ ; 11 Item X Start & $Item_Y_Start & '|' _ ; 12 Item Y Start & $Bar_CreateTab_Array[$i][17]) ; 13 Handle Gui $Bar_LastRowPos = 0 Return $Handle EndIf Next SetError(2) Return 0 EndIf Next SetError(3) Return 0 EndFunc ;==>_RibbonsBar_Create_TabItem ; #FUNCTION# ==================================================================================================================== ; Name...........: _RibbonsBar_Create_Tab() ; Description ...: Erstellt einen Tab in der Bar mit dem vorher im BarCreate ausgewähltem Style ; Parameters ....: $hBar - Handle der Bar in die der Tab erstellt werden soll ; $TabName - Bezeichnung des Tabs ; Return values .: Erfolg - erstellt einen Tab ; Fehler - @error 1 = Fehler in Parametereingabe ; - @error 2 = Bar Handle nicht vorhanden ; Author ........: chrisatack ( autoit.de ) ; Remarks .......: Durchschnittiche Laufzeit ~ 4,7 ms ( Win7 2 x 2,5 GHz 3GB Ram ) ; =============================================================================================================================== Func _RibbonsBar_Create_Tab($hBar, $TabName) ;ConsoleWrite('_RibbonsBar_Create_Tab ...' & @CRLF) Local $Tab_Label_W, $Tab_X_Start, $Tab_Y_Start, $hIcon_Tab_left, $hIcon_Tab_left_hover, $hIcon_Tab_Center, $hIcon_Tab_Center_hover Local $hIcon_Tab_Right, $hIcon_Tab_Right_hover, $hLabel_Tab, $Handle If Not $TabName <> '' Then SetError(1) Return 0 EndIf For $i = 1 To UBound($Bar_Create_Array) - 1 If $Bar_Create_Array[$i][0] == $hBar Then $Tab_Label_W = StringLen($TabName) * 5 + 20 $Tab_X_Start = $Bar_Create_Array[$i][2] + $Bar_Create_Array[$i][6] + 8 + $Bar_Create_Array[$i][13] $Tab_Y_Start = $Bar_Create_Array[$i][3] + 3 $hIcon_Tab_left = GUICtrlCreateIcon($Bar_DLL, $Bar_Create_Array[$i][7] & '01', $Tab_X_Start, $Tab_Y_Start, 6, 23, 0) GUICtrlSetState(-1, $GUI_HIDE) $hIcon_Tab_left_hover = GUICtrlCreateIcon($Bar_DLL, $Bar_Create_Array[$i][7] & '07', $Tab_X_Start, $Tab_Y_Start, 6, 23, 0) GUICtrlSetState(-1, $GUI_HIDE) $hIcon_Tab_Center = GUICtrlCreateIcon($Bar_DLL, $Bar_Create_Array[$i][7] & '05', $Tab_X_Start + 6, $Tab_Y_Start, $Tab_Label_W, 23, 0) GUICtrlSetState(-1, $GUI_HIDE) $hIcon_Tab_Center_hover = GUICtrlCreateIcon($Bar_DLL, $Bar_Create_Array[$i][7] & '08', $Tab_X_Start + 6, $Tab_Y_Start, $Tab_Label_W, 23, 0) GUICtrlSetState(-1, $GUI_HIDE) $hIcon_Tab_Right = GUICtrlCreateIcon($Bar_DLL, $Bar_Create_Array[$i][7] & '06', $Tab_X_Start + 6 + $Tab_Label_W, $Tab_Y_Start, 6, 23, 0) GUICtrlSetState(-1, $GUI_HIDE) $hIcon_Tab_Right_hover = GUICtrlCreateIcon($Bar_DLL, $Bar_Create_Array[$i][7] & '09', $Tab_X_Start + 6 + $Tab_Label_W, $Tab_Y_Start, 6, 23, 0) GUICtrlSetState(-1, $GUI_HIDE) $hLabel_Tab = GUICtrlCreateLabel($TabName, $Tab_X_Start + 6, $Tab_Y_Start, $Tab_Label_W, 23, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, $Bar_Tab_Label_Color) $Handle = __RibbonsBar_CreateHandleCode() $Bar_Create_Array[$i][13] += $Tab_Label_W + 15 __RibbonsBar_Array2DAdd($Bar_CreateTab_Array, $Handle & '|' _ ; 0 Handle des Tab & $hBar & '|' _ ; 1 Handle der Bar & $TabName & '|' _ ; 2 Bezeichnung des Tabs & $hIcon_Tab_left & '|' _ ; 3 Handle des TabHG Icon Links & $hIcon_Tab_Center & '|' _ ; 4 Handle des TabHG Icon Mitte & $hIcon_Tab_Right & '|' _ ; 5 Handle des TabHG Icon Rechts & $hIcon_Tab_left_hover & '|' _ ; 6 Handle des TabHG hover Icon Links & $hIcon_Tab_Center_hover & '|' _ ; 7 Handle des TabHG hover Icon Mitte & $hIcon_Tab_Right_hover & '|' _ ; 8 Handle des TabHG hover Icon Rechts & $hLabel_Tab & '|' _ ; 9 Handle des Tab Labels & $Tab_X_Start & '|' _ ; 10 Tab X Start & $Tab_Y_Start & '|' _ ; 11 Tab Y Start & $Tab_Label_W & '|' _ ; 12 Tab Label Breite & 23 & '|' _ ; 13 Tab Label Höhe & $GUI_HIDE & '|' _ ; 14 Visible & 6 & '|' _ ; 15 Offset TabItems links ( addiert ) & $Bar_Create_Array[$i][7] & '|' _ ; 16 Bar Style & $Bar_Create_Array[$i][1]) ; 17 Gui Handle Return $Handle EndIf Next SetError(2) Return 0 EndFunc ;==>_RibbonsBar_Create_Tab ; #FUNCTION# ==================================================================================================================== ; Name...........: _RibbonsBar_Create() ; Description ...: Erstellt den Barbereich und grenzt ihm mit einer Linie ab. ; Parameters ....: $hGui - Das Handle vom Gui ; [$aX] - Startwert in der X-Achse ; [$aY] - Startwert in der Y-Achse ; [$aWidth] - Länge der Bar ( wenn nichts angegeben wird auf Breite des Gui gezogen ) ; [$Offset_Tabs_left] - Die Tabs können nach rechts verschoben werden ; [$Style] - Style der Bar ( silver,blue,black ) wie in Office ; Return values .: Erfolg - Erstellt den Barbereich und grenzt ihm mit einer Linie ab. ; Fehler - @error 1 = Fehler in Parametereingabe ; - @error 2 = keine *.dll gefunden ; - @error 3 = keinen korrekten Style gewählt ; - @error 4 = finde keine Fensterbreite ; Author ........: chrisatack ( autoit.de ) ; Remarks .......: Durchschnittiche Laufzeit ~ 6,1 ms ( Win7 2 x 2,5 GHz 3GB Ram ) ; =============================================================================================================================== Func _RibbonsBar_Create($hGui, $aX = 0, $aY = 0, $aWidth = 0, $Offset_Tabs_left = 0, $Style = 'blue') ;ConsoleWrite('_RibbonsBar_Create ...' & @CRLF) Local $return, $hLabel_BarHG, $hLabel_BarBottomLine,$hIcon_Left, $hIcon_Center,$hIcon_Right, $Handle If Not IsHWnd($hGui) And Not IsNumber($aX) And Not IsNumber($aY) And Not IsNumber($aWidth) And Not IsNumber($Offset_Tabs_left) Then SetError(1) Return 0 EndIf $Bar_MainGuiHandle = $hGui If Not FileExists($Bar_DLL) Then SetError(2) Return 0 EndIf If $Style == 'silver' Then $Bar_HG_Color = $Bar_HG_Color_Silver $Bar_Bottom_Line_Color = $Bar_Bottom_Line_Color_Silve $Bar_TabItem_Label_Color = $Bar_TabItem_Label_Color_Silve $Bar_Tab_Label_Color = $Bar_Tab_Label_Color_Silve $Bar_Tab_Label_HoverColor = $Bar_Tab_Label_HoverColor_Silve ElseIf $Style == 'black' Then $Bar_HG_Color = $Bar_HG_Color_Black $Bar_Bottom_Line_Color = $Bar_Bottom_Line_Color_Black $Bar_TabItem_Label_Color = $Bar_TabItem_Label_Color_Black $Bar_Tab_Label_Color = $Bar_Tab_Label_Color_Black $Bar_Tab_Label_HoverColor = $Bar_Tab_Label_HoverColor_Black ElseIf $Style == 'blue' Then $Bar_HG_Color = $Bar_HG_Color_Blue $Bar_Bottom_Line_Color = $Bar_Bottom_Line_Color_Blue $Bar_TabItem_Label_Color = $Bar_TabItem_Label_Color_Blue $Bar_Tab_Label_Color = $Bar_Tab_Label_Color_Blue $Bar_Tab_Label_HoverColor = $Bar_Tab_Label_HoverColor_Blue Else SetError(3) Return 0 EndIf If $aWidth == -1 Or $aWidth == Default Or $aWidth == 0 Or $aWidth == '' Then $return = WinGetClientSize($hGui) If IsArray($return) Then $aWidth = $return[0] Else SetError(4) Return 0 EndIf EndIf $hLabel_BarHG = GUICtrlCreateLabel('', $aX, $aY, $aWidth, $aHeight) GUICtrlSetBkColor(-1, $Bar_HG_Color) $hLabel_BarBottomLine = GUICtrlCreateLabel('', $aX, $aY + $aHeight, $aWidth, 1) GUICtrlSetBkColor(-1, $Bar_Bottom_Line_Color) $hIcon_Left = GUICtrlCreateIcon($Bar_DLL, $Style & '02', $aX + 2, $aY + 25, 9, 92, 0) $hIcon_Center = GUICtrlCreateIcon($Bar_DLL, $Style & '04', $aX + $aWidth - 2 - 9, $aY + 25, 9, 92, 0) $hIcon_Right = GUICtrlCreateIcon($Bar_DLL, $Style & '03', $aX + 2 + 9, $aY + 25, $aWidth - 18, 92, 0) $Handle = __RibbonsBar_CreateHandleCode() __RibbonsBar_Array2DAdd($Bar_Create_Array, $Handle & '|' _ ; 0 Handle der Bar & $hGui & '|' _ ; 1 Handle Gui & $aX & '|' _ ; 2 Anfang der Bar in X & $aY & '|' _ ; 3 Anfang der Bar in Y & $aWidth & '|' _ ; 4 Breite der Bar & $aHeight & '|' _ ; 5 Höhe der Bar & $Offset_Tabs_left & '|' _ ; 6 Zusatzabstand der Tabs von links & $Style & '|' _ ; 7 Style der Bar & $hLabel_BarHG & '|' _ ; 8 Handle des neu erstellten HG Label & $hLabel_BarBottomLine & '|' _ ; 9 Handle des neu erstellten ButtomLine Label & $hIcon_Left & '|' _ ; 10 Handle des HGIcon der Bar Links & $hIcon_Center & '|' _ ; 11 Handle des HGIcon der Bar Mitte & $hIcon_Right & '|' _ ; 12 Handle des HGIcon der Bar Rechts & 0) ; 13 Offset der Tabs links ( addiert ) Return $Handle EndFunc ;==>_RibbonsBar_Create ; #FUNCTION# ==================================================================================================================== ; Name...........: __RibbonsBar_CreateHandleCode() ; Description ...: Erstellt einen eindeutigen HandleCode ; Parameters ....: n/a ; Return values .: Erfolg - 8 Stelliger Code ; Fehler - n/a ; Author ........: chrisatack ( autoit.de ) ; Remarks .......: n/a ; =============================================================================================================================== Func __RibbonsBar_CreateHandleCode() ;ConsoleWrite('__RibbonsBar_CreateHandleCode ...' & @CRLF) Return Random(1, 9, 1) & Random(0, 9, 1) & Random(0, 9, 1) & Random(0, 9, 1) & Random(0, 9, 1) & Random(0, 9, 1) & Random(0, 9, 1) & Random(0, 9, 1) EndFunc ;==>__RibbonsBar_CreateHandleCode ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __RibbonsBar_Array2DAdd() ; Description ...: Fügt einem 2D Array eine Zeile mit neuen Werten hinzu ; Parameters ....: $avArray - 2D Array ( wird auch wieder zurückgegeben ) ; [$sValue] - neuen Werte getrennt durch '|' ; Return values .: Erfolg - Gibt das neue 2D Array nit den neuen Werten zurück ; Fehler - Gibt 0 zurück und setzt @error auf 1 ; Author ........: BugFix ; Remarks .......: n/a ; =============================================================================================================================== Func __RibbonsBar_Array2DAdd(ByRef $avArray, $sValue = '') ;ConsoleWrite('__RibbonsBar_Array2DAdd ...' & @CRLF) If (Not IsArray($avArray)) Then SetError(1) Return 0 EndIf Local $UBound2nd = UBound($avArray, 2) If @error = 2 Then ReDim $avArray[UBound($avArray) + 1] $avArray[UBound($avArray) - 1] = $sValue Else Local $arValue ReDim $avArray[UBound($avArray) + 1][$UBound2nd] If $sValue = '' Then For $i = 0 To $UBound2nd - 2 $sValue &= '|' Next EndIf $arValue = StringSplit($sValue, '|') If $arValue[0] <> $UBound2nd Then SetError(2) Return 0 EndIf For $i = 0 To $UBound2nd - 1 $avArray[UBound($avArray) - 1][$i] = $arValue[$i + 1] Next EndIf Return -1 EndFunc ;==>__RibbonsBar_Array2DAdd ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __RibbonsBar_SetIconAlpha() ; Description ...: Fügt einem Icon mit transparentz ein ; Parameters ....: $hWnd - GuiHandle ; $sIcon - Pfad zum Icon ; $iIndex - Icon Nummer ; $iWidth - Breite ; $iHeight - Höhe ; Return values .: Erfolg - Zeichnet ein transparentes Icon in einen Gui ; Fehler - Gibt 0 zurück und setzt @error auf 1 ; Author ........: n/a ; Remarks .......: n/a ; =============================================================================================================================== Func __RibbonsBar_SetIconAlpha($hWnd, $sIcon, $iIndex, $iWidth, $iHeight) ;ConsoleWrite('__RibbonsBar_SetIconAlpha ...' & @CRLF) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) If $hWnd = 0 Then Return SetError(1, 0, 0) EndIf EndIf Local $hIcon = __RibbonsBar_ShellExtractIcons($sIcon, $iIndex, $iWidth, $iHeight) If $hIcon = 0 Then Return SetError(1, 0, 0) EndIf Local $hBitmap, $hObj, $hDC, $hMem, $hSv $hDC = _WinAPI_GetDC($hWnd) $hMem = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight) $hSv = _WinAPI_SelectObject($hMem, $hBitmap) _WinAPI_DrawIconEx($hMem, 0, 0, $hIcon, $iWidth, $iHeight, 0, 0, 2) _WinAPI_ReleaseDC($hWnd, $hDC) _WinAPI_SelectObject($hMem, $hSv) _WinAPI_DeleteDC($hMem) _WinAPI_DestroyIcon($hIcon) _WinAPI_DeleteObject(__RibbonsBar_SendMessage($hWnd, 0x0172, 0, 0)) __RibbonsBar_SendMessage($hWnd, 0x0172, 0, $hBitmap) $hObj = __RibbonsBar_SendMessage($hWnd, 0x0173) If $hObj <> $hBitmap Then _WinAPI_DeleteObject($hBitmap) EndIf Return 1 EndFunc ;==>__RibbonsBar_SetIconAlpha ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __RibbonsBar_ShellExtractIcons() ; Description ...: n/a ; Parameters ....: $sIcon - Pfad zum Icon ; $iIndex - Icon Nummer ; $iWidth - Breite ; $iHeight - Höhe ; Return values .: Erfolg - n/a ; Fehler - Gibt 0 zurück und setzt @error auf 1 ; Author ........: n/a ; Remarks .......: n/a ; =============================================================================================================================== Func __RibbonsBar_ShellExtractIcons($sIcon, $iIndex, $iWidth, $iHeight) ;ConsoleWrite('__RibbonsBar_ShellExtractIcons ...' & @CRLF) Local $Ret = DllCall('shell32.dll', 'int', 'SHExtractIconsW', 'wstr', $sIcon, 'int', $iIndex, 'int', $iWidth, 'int', $iHeight, 'ptr*', 0, 'ptr*', 0, 'int', 1, 'int', 0) If (@error) Or ($Ret[0] = 0) Or ($Ret[5] = Ptr(0)) Then Return SetError(1, 0, 0) EndIf Return $Ret[5] EndFunc ;==>__RibbonsBar_ShellExtractIcons ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __RibbonsBar_IsPressed ; Description ...: Check if key has been pressed ; Syntax.........: __RibbonsBar_IsPressed($sHexKey[, $vDLL = 'user32.dll']) ; Parameters ....: $sHexKey - Key to check for ; $vDLL - Handle to dll or default to user32.dll ; Return values .: True - 1 ; False - 0 ; Author ........: ezzetabi and Jon ; Modified.......: ; Remarks .......: ; =============================================================================================================================== Func __RibbonsBar_IsPressed($sHexKey, $vDLL = 'user32.dll') ;~ ;ConsoleWrite('__RibbonsBar_IsPressed ...' & @CRLF) Local $a_R = DllCall($vDLL, "int", "GetAsyncKeyState", "int", '0x' & $sHexKey) If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1 Return 0 EndFunc ;==>__RibbonsBar_IsPressed ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __RibbonsBar_SendMessage ; Description ...: Wrapper for commonly used Dll Call ; Syntax.........: __RibbonsBar_SendMessage($hWnd, $iMsg[, $wParam = 0[, $lParam = 0[, $iReturn = 0[, $wParamType = "wparam"[, $lParamType = "lparam"[, $sReturnType = "lparam"]]]]]]) ; Parameters ....: see SendMessage.au3 ; Return values .: Success - User selected value from the DllCall() result ; Failure - @error is set ; Author ........: Valik ; Modified.......: Gary Frost (GaryFrost) aka gafrost ; Remarks .......: ; =============================================================================================================================== Func __RibbonsBar_SendMessage($hWnd, $iMsg, $wParam = 0, $lParam = 0, $iReturn = 0, $wParamType = "wparam", $lParamType = "lparam", $sReturnType = "lparam") ;ConsoleWrite('__RibbonsBar_SendMessage ...' & @CRLF) Local $aResult = DllCall("user32.dll", $sReturnType, "SendMessage", "hwnd", $hWnd, "int", $iMsg, $wParamType, $wParam, $lParamType, $lParam) If @error Then Return SetError(@error, @extended, "") If $iReturn >= 0 And $iReturn <= 4 Then Return $aResult[$iReturn] Return $aResult EndFunc ;==>__RibbonsBar_SendMessage