Moderators Melba23 Posted February 24, 2016 Moderators Share Posted February 24, 2016 dynamitemedia, Glad you got it working properly. As requested, here is a new version with PGUP/PGDN switching between the top buttons and the others: expandcollapse popup#include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <WinAPI.au3> #include <File.au3> #include <Array.au3> #include "GUIScrollbars_Ex.au3" ; Declare global arrays to hold ControlIDs Global $aImage, $aButton, $aLabel ; Declare image count Global $iCount ; Max buttons per row Global $iCol_Count = 5 Global $hActive, $iRow_Count, $hDialog, $fFocusMain = True, $cCurrFocus = 9999 ; Set default listing filter $sListFilter = "Functions" ; Set max dialog size $iDialog_Width = 1265 $iDialog_Depth = 525 ; Determine button width $iButton_Dim = Floor(($iDialog_Width - 10 - _WinAPI_GetSystemMetrics(2)) / $iCol_Count) ; Determine required depths $iVisRows = 0 While 1 $iVisRows += 1 If $iButton_Dim * $iVisRows > $iDialog_Depth Then $iVisRows -= 1 ExitLoop EndIf WEnd $iDialog_Depth = ($iButton_Dim * $iVisRows) + 10 ; Add the space for the buttons to get the main GUI size $iMain_Depth = $iDialog_Depth + 100 Mainscript() Func Mainscript() ; Liat the images to display $aImage = _List_Images($sListFilter) $iCount = UBound($aImage) ; Create arrays to hold button and label ControlIDs Global $aButton[$iCount], $aLabel[$iCount] ; Determine rows required $iRow_Count = Ceiling($iCount / $iCol_Count) ; Create main GUI $hGUI = GUICreate("MainGUI", $iDialog_Width, $iMain_Depth) $cPrograms = GUICtrlCreateButton("Functions", ($iDialog_Width / 2) - 320, 20, 300, 60) $cNetWorks = GUICtrlCreateButton("Constants", ($iDialog_Width / 2) + 20, 20, 300, 60) GUISetState() ; Create dialog $hDialog = GUICreate("", $iDialog_Width, $iDialog_Depth, 0, 100, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) GUISetBkColor(0xFFFFFF) If $iRow_Count > $iVisRows Then _GUIScrollbars_Generate($hDialog, 0, $iButton_Dim * $iRow_Count) EndIf _Draw_Images() ; Create dummy controls $cDummy_Up = GUICtrlCreateDummy() $cDummy_Dn = GUICtrlCreateDummy() $cDummy_Left = GUICtrlCreateDummy() $cDummy_Right = GUICtrlCreateDummy() $cDummy_PgDn = GUICtrlCreateDummy() $cDummy_PgUp = GUICtrlCreateDummy() GUISetState() ; Set the Up/Down/Left/Right keys as accelerators - they will only act like this when your GUI is active Local $aAccelKeys[6][2] = [["{UP}", $cDummy_Up], ["{DOWN}", $cDummy_Dn], ["{LEFT}", $cDummy_Left], ["{RIGHT}", $cDummy_Right], ["{PGUP}", $cDummy_PgUp], ["{PGDN}", $cDummy_PgDn]] GUISetAccelerators($aAccelKeys, $hGUI) GUISetAccelerators($aAccelKeys, $hDialog) While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $cPrograms If $sListFilter <> "Functions" Then $sListFilter = "Functions" _Load_Images($sListFilter) EndIf Case $cNetWorks If $sListFilter <> "Constants" Then $sListFilter = "Constants" _Load_Images($sListFilter) EndIf Case $cDummy_Up _Move_Focus($hDialog, 1) Case $cDummy_Dn _Move_Focus($hDialog, 2) Case $cDummy_Left _Move_Focus($hDialog, 3) Case $cDummy_Right _Move_Focus($hDialog, 4) Case $cDummy_PgUp GUICtrlSetState($cPrograms, $GUI_FOCUS) Case $cDummy_PgDn GUICtrlSetState($cCurrFocus, $GUI_FOCUS) Case Else For $i = 0 To $iCount - 1 If $iMsg = $aButton[$i] Then MsgBox($MB_SYSTEMMODAL, "Pressed", GUICtrlRead($aButton[$i])) ExitLoop EndIf Next EndSwitch ; Get focused control $hCurrFocus = _WinAPI_GetFocus() ; If it has changed If $hCurrFocus <> $hActive Then ; See if it is a button For $i = 0 To $iCount - 1 If $hCurrFocus = GUICtrlGetHandle($aButton[$i]) Then ; Reset all the labels For $j = 0 To $iCount - 1 GUICtrlSetBkColor($aLabel[$j], 0xFFFFFF) Next ; Highlight the correct label GUICtrlSetBkColor($aLabel[$i], 0x00FF00) ; Store ControlID $cCurrFocus = $aButton[$i] ExitLoop EndIf Next $hActive = $hCurrFocus EndIf WEnd EndFunc ;==>Mainscript Func _Draw_Images() ; Create labels For $i = 0 To $iRow_Count - 1 For $j = 0 To $iCol_Count - 1 $iIndex = $j + ($i * $iCol_Count) If $iIndex > $iCount - 1 Then ExitLoop $aLabel[$iIndex] = GUICtrlCreateLabel("", 10 + ($iButton_Dim * $j), 10 + ($iButton_Dim * $i), $iButton_Dim - 10, $iButton_Dim - 10) GUICtrlSetBkColor($aLabel[$iIndex], 0xFFFFFF) GUICtrlSetState($aLabel[$iIndex], $GUI_DISABLE) GUICtrlSetResizing($aLabel[$iIndex], $GUI_DOCKALL) Next Next ; Create buttons For $i = 0 To $iRow_Count - 1 For $j = 0 To $iCol_Count - 1 $iIndex = $j + ($i * $iCol_Count) If $iIndex > $iCount - 1 Then ExitLoop $aButton[$iIndex] = GUICtrlCreateButton($aImage[$iIndex], 15 + ($iButton_Dim * $j), 15 + ($iButton_Dim * $i), $iButton_Dim - 20, $iButton_Dim - 20, $BS_BITMAP) GUICtrlSetImage($aButton[$iIndex], $aImage[$iIndex]) GUICtrlSetResizing($aButton[$iIndex], $GUI_DOCKALL) Next Next ; Set default button GUICtrlSetState($aButton[0], $GUI_FOCUS) GUICtrlSetBkColor($aLabel[0], 0x00FF00) $hActive = GUICtrlGetHandle($aButton[0]) EndFunc ;==>_Draw_Images Func _Load_Images($sListFilter) ; Remove current images, buttons and labels For $i = 0 To $iCount - 1 GUICtrlDelete($aButton[$i]) GUICtrlDelete($aLabel[$i]) Next ; Liat the images to display $aImage = _List_Images($sListFilter) $iCount = UBound($aImage) ; Create arrays to hold button and label ControlIDs Global $aButton[$iCount], $aLabel[$iCount] ; Determine rows required $iRow_Count = Ceiling($iCount / $iCol_Count) ; Redraw buttons _Draw_Images() ; Scrol to top, hide and if required reset the scrolling _GUIScrollbars_Scroll_Page($hDialog, 0, 1) _GUIScrollBars_ShowScrollBar($hDialog, $SB_BOTH, False) If $iRow_Count > $iVisRows Then _GUIScrollbars_Generate($hDialog, 0, $iButton_Dim * $iRow_Count) EndIf EndFunc ;==>_Load_Images Func _List_Images($sFilter) ; Here you would have your FileListToArray lines to get a list of the images to display ; But for this example we will look in the AutoIt include folder and show files with/without "Constant" in the name Local $sIncludeFolder = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", Default, -1)) & "Include" Local $aList = _FileListToArray($sIncludeFolder, "*.au3", $FLTA_FILES) ; Now filter according to the setting For $i = $aList[0] To 1 Step -1 Switch $sFilter Case "Functions" If StringInStr($aList[$i], "Constant") Then _ArrayDelete($aList, $i) $aList[0] -= 1 EndIf Case "Constants" If Not StringInStr($aList[$i], "Constant") Then _ArrayDelete($aList, $i) $aList[0] -= 1 EndIf EndSwitch Next ; Remove the count element _ArrayDelete($aList, 0) ; And return the list Return $aList EndFunc ;==>_List_Images Func _Move_Focus($hDialog, $iMode) Local $iNext_Button, $iRow, $iNewRow Local $iRow_Count = Ceiling($iCount / $iCol_Count) ; Get active control $hActive = _WinAPI_GetFocus() For $i = 0 To $iCount - 1 ; If it is a button If $hActive = GUICtrlGetHandle($aButton[$i]) Then ; Determine row $iRow = Int($i / $iCol_Count) $iNewRow = $iRow ; Set default value for next button $iNext_Button = $i Switch $iMode Case 1 ; Not if in top row If $iRow Then $iNext_Button -= $iCol_Count ; Set new row $iNewRow -= 1 EndIf Case 2 ; Not if in bottom row or there no button below If ($iRow < $iRow_Count - 1) And ($i + $iCol_Count < $iCount) Then $iNext_Button += $iCol_Count ; Set new row $iNewRow += 1 EndIf Case 3 ; If not first button If $i <> 0 Then $iNext_Button -= 1 $iNewRow = Int($iNext_Button / $iCol_Count) EndIf Case 4 ; If not last button If $i <> $iCount Then $iNext_Button += 1 $iNewRow = Int($iNext_Button / $iCol_Count) EndIf EndSwitch ; Set focus to new button GUICtrlSetState($aButton[$iNext_Button], $GUI_FOCUS) ; Get button into view by scrolling to page which includes button _GUIScrollbars_Scroll_Page($hDialog, 0, Int($iNewRow / 2) + 1) ; No point in looking further ExitLoop EndIf Next EndFunc ;==>_Move_Focus M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
dynamitemedia Posted March 7, 2016 Share Posted March 7, 2016 after a break i have gotten back to this...  when i click on one of th eiumage buttons i add a pop up that gives info about that image.  but then it messes up... to recreate you can do this: 1.) click on any of the image buttons a pop up will come up, just like i wanted.  2.) now click on the constants and look what happens expandcollapse popup#include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <WinAPI.au3> #include <File.au3> #include <Array.au3> #include "GUIScrollbars_Ex.au3" ; Declare global arrays to hold ControlIDs Global $aImage, $aButton, $aLabel ; Declare image count Global $iCount ; Max buttons per row Global $iCol_Count = 5 Global $hActive, $iRow_Count, $hDialog, $fFocusMain = True, $cCurrFocus = 9999 Global $hGUI, $hDialog, $hDialog2 ; Set max dialog size $iDialog_Width = 1265 $iDialog_Depth = 525 ; Determine button width $iButton_Dim = Floor(($iDialog_Width - 10 - _WinAPI_GetSystemMetrics(2)) / $iCol_Count) ; Set default listing filter $sListFilter = "Functions" ; Determine required depths $iVisRows = 0 While 1 $iVisRows += 1 If $iButton_Dim * $iVisRows > $iDialog_Depth Then $iVisRows -= 1 ExitLoop EndIf WEnd $iDialog_Depth = ($iButton_Dim * $iVisRows) + 10 ; Add the space for the buttons to get the main GUI size $iMain_Depth = $iDialog_Depth + 100 Mainscript() Func Mainscript() ; Liat the images to display $aImage = _List_Images($sListFilter) $iCount = UBound($aImage) ; Create arrays to hold button and label ControlIDs Global $aButton[$iCount], $aLabel[$iCount] ; Determine rows required $iRow_Count = Ceiling($iCount / $iCol_Count) ; Create main GUI $hGUI = GUICreate("MainGUI", $iDialog_Width, $iMain_Depth) $cPrograms = GUICtrlCreateButton("Functions", ($iDialog_Width / 2) - 320, 20, 300, 60) $cNetWorks = GUICtrlCreateButton("Constants", ($iDialog_Width / 2) + 20, 20, 300, 60) GUISetState() ; Create dialog $hDialog = GUICreate("", $iDialog_Width, $iDialog_Depth, 0, 100, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) GUISetBkColor(0xFFFFFF) If $iRow_Count > $iVisRows Then _GUIScrollbars_Generate($hDialog, 0, $iButton_Dim * $iRow_Count) EndIf _Draw_Images() ; Create dummy controls $cDummy_Up = GUICtrlCreateDummy() $cDummy_Dn = GUICtrlCreateDummy() $cDummy_Left = GUICtrlCreateDummy() $cDummy_Right = GUICtrlCreateDummy() $cDummy_PgDn = GUICtrlCreateDummy() $cDummy_PgUp = GUICtrlCreateDummy() GUISetState() ; Set the Up/Down/Left/Right keys as accelerators - they will only act like this when your GUI is active Local $aAccelKeys[6][2] = [["{UP}", $cDummy_Up], ["{DOWN}", $cDummy_Dn], ["{LEFT}", $cDummy_Left], ["{RIGHT}", $cDummy_Right], ["{PGUP}", $cDummy_PgUp], ["{PGDN}", $cDummy_PgDn]] GUISetAccelerators($aAccelKeys, $hGUI) GUISetAccelerators($aAccelKeys, $hDialog) While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $cPrograms If $sListFilter <> "Functions" Then $sListFilter = "Functions" _Load_Images($sListFilter) EndIf Case $cNetWorks If $sListFilter <> "Constants" Then $sListFilter = "Constants" _Load_Images($sListFilter) EndIf Case $cDummy_Up _Move_Focus($hDialog, 1) Case $cDummy_Dn _Move_Focus($hDialog, 2) Case $cDummy_Left _Move_Focus($hDialog, 3) Case $cDummy_Right _Move_Focus($hDialog, 4) Case $cDummy_PgUp GUICtrlSetState($cPrograms, $GUI_FOCUS) Case $cDummy_PgDn GUICtrlSetState($cCurrFocus, $GUI_FOCUS) Case Else For $i = 0 To $iCount - 1 If $iMsg = $aButton[$i] Then $imgLabel2send = GUICtrlRead($aButton[$i]) MsgBox($MB_SYSTEMMODAL, "Pressed", $imgLabel2send) popUpGui($imgLabel2send) ExitLoop EndIf Next EndSwitch ; Get focused control $hCurrFocus = _WinAPI_GetFocus() ; If it has changed If $hCurrFocus <> $hActive Then ; See if it is a button For $i = 0 To $iCount - 1 If $hCurrFocus = GUICtrlGetHandle($aButton[$i]) Then ; Reset all the labels For $j = 0 To $iCount - 1 GUICtrlSetBkColor($aLabel[$j], 0xFFFFFF) Next ; Highlight the correct label GUICtrlSetBkColor($aLabel[$i], 0x00FF00) ; Store ControlID $cCurrFocus = $aButton[$i] ExitLoop EndIf Next $hActive = $hCurrFocus EndIf WEnd EndFunc ;==>Mainscript Func _Draw_Images() ; Create labels For $i = 0 To $iRow_Count - 1 For $j = 0 To $iCol_Count - 1 $iIndex = $j + ($i * $iCol_Count) If $iIndex > $iCount - 1 Then ExitLoop $aLabel[$iIndex] = GUICtrlCreateLabel("", 10 + ($iButton_Dim * $j), 10 + ($iButton_Dim * $i), $iButton_Dim - 10, $iButton_Dim - 10) GUICtrlSetBkColor($aLabel[$iIndex], 0xFFFFFF) GUICtrlSetState($aLabel[$iIndex], $GUI_DISABLE) GUICtrlSetResizing($aLabel[$iIndex], $GUI_DOCKALL) Next Next ; Create buttons For $i = 0 To $iRow_Count - 1 For $j = 0 To $iCol_Count - 1 $iIndex = $j + ($i * $iCol_Count) If $iIndex > $iCount - 1 Then ExitLoop $aButton[$iIndex] = GUICtrlCreateButton($aImage[$iIndex], 15 + ($iButton_Dim * $j), 15 + ($iButton_Dim * $i), $iButton_Dim - 20, $iButton_Dim - 20, $BS_BITMAP) GUICtrlSetImage($aButton[$iIndex], $aImage[$iIndex]) GUICtrlSetResizing($aButton[$iIndex], $GUI_DOCKALL) Next Next ; Set default button GUICtrlSetState($aButton[0], $GUI_FOCUS) GUICtrlSetBkColor($aLabel[0], 0x00FF00) $hActive = GUICtrlGetHandle($aButton[0]) EndFunc ;==>_Draw_Images Func _Load_Images($sListFilter) ; Remove current images, buttons and labels For $i = 0 To $iCount - 1 GUICtrlDelete($aButton[$i]) GUICtrlDelete($aLabel[$i]) Next ; Liat the images to display $aImage = _List_Images($sListFilter) $iCount = UBound($aImage) ; Create arrays to hold button and label ControlIDs Global $aButton[$iCount], $aLabel[$iCount] ; Determine rows required $iRow_Count = Ceiling($iCount / $iCol_Count) ; Redraw buttons _Draw_Images() ; Scrol to top, hide and if required reset the scrolling _GUIScrollbars_Scroll_Page($hDialog, 0, 1) _GUIScrollBars_ShowScrollBar($hDialog, $SB_BOTH, False) If $iRow_Count > $iVisRows Then _GUIScrollbars_Generate($hDialog, 0, $iButton_Dim * $iRow_Count) EndIf EndFunc ;==>_Load_Images Func _List_Images($sFilter) ; Here you would have your FileListToArray lines to get a list of the images to display ; But for this example we will look in the AutoIt include folder and show files with/without "Constant" in the name Local $sIncludeFolder = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", Default, -1)) & "Include" Local $aList = _FileListToArray($sIncludeFolder, "*.au3", $FLTA_FILES) ; Now filter according to the setting For $i = $aList[0] To 1 Step -1 Switch $sFilter Case "Functions" If StringInStr($aList[$i], "Constant") Then _ArrayDelete($aList, $i) $aList[0] -= 1 EndIf Case "Constants" If Not StringInStr($aList[$i], "Constant") Then _ArrayDelete($aList, $i) $aList[0] -= 1 EndIf EndSwitch Next ; Remove the count element _ArrayDelete($aList, 0) ; And return the list Return $aList EndFunc ;==>_List_Images Func _Move_Focus($hDialog, $iMode) Local $iNext_Button, $iRow, $iNewRow Local $iRow_Count = Ceiling($iCount / $iCol_Count) ; Get active control $hActive = _WinAPI_GetFocus() For $i = 0 To $iCount - 1 ; If it is a button If $hActive = GUICtrlGetHandle($aButton[$i]) Then ; Determine row $iRow = Int($i / $iCol_Count) $iNewRow = $iRow ; Set default value for next button $iNext_Button = $i Switch $iMode Case 1 ; Not if in top row If $iRow Then $iNext_Button -= $iCol_Count ; Set new row $iNewRow -= 1 EndIf Case 2 ; Not if in bottom row or there no button below If ($iRow < $iRow_Count - 1) And ($i + $iCol_Count < $iCount) Then $iNext_Button += $iCol_Count ; Set new row $iNewRow += 1 EndIf Case 3 ; If not first button If $i <> 0 Then $iNext_Button -= 1 $iNewRow = Int($iNext_Button / $iCol_Count) EndIf Case 4 ; If not last button If $i <> $iCount Then $iNext_Button += 1 $iNewRow = Int($iNext_Button / $iCol_Count) EndIf EndSwitch ; Set focus to new button GUICtrlSetState($aButton[$iNext_Button], $GUI_FOCUS) ; Get button into view by scrolling to page which includes button _GUIScrollbars_Scroll_Page($hDialog, 0, Int($iNewRow / 2) + 1) ; No point in looking further ExitLoop EndIf Next EndFunc ;==>_Move_Focus func popUpGui($imgLabel) Global $imageLabel = $imgLabel Global $hDialog2 = GUICreate("Image Name : " & $imageLabel, 540, 415, -1, -1) local $img2Use = @ScriptDir & "\thumbs\" & $sListFilter & "\" & $imageLabel & ".bmp" Global $iBtnL = GUICtrlCreateButton("", 25, 25, 286, 364, BitOR($BS_BITMAP, $BS_DEFPUSHBUTTON) ) GUICtrlSetImage($iBtnL, $img2Use) GUISetState() While 2 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ; activate main gui GUISetState(@SW_ENABLE, $hGUI) WinActivate($hGUI) ; activate child gui GUISetState(@SW_ENABLE, $hDialog) WinActivate($hDialog) ; delete this popup gui GUIDelete($hDialog2) ExitLoop EndSwitch WEnd EndFunc this worked in y old script but it is because in this one you added a child gui in the main gui it looks like  so how do i delete the popup and get this all tidied up? can i get a explanation on what i was doing wrong, cause i hope to add more info buttons or maybe another popup on that popup via a button on the pop up Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 7, 2016 Moderators Share Posted March 7, 2016 dynamitemedia, The problem is caused by you creating the popup GUI. When you create a GUI AutoIt saves its handle in an internal "default GUI" value which is used to decide in which GUI to create new controls. So when you delete the popup and do not reset this "default GUI" value, AutoIt tries to create the new buttons in a GUI which no longer exists - this obviously fails and so no buttons are appear. As there are no buttons, the array of button ControlIDs only contains blanks and so the loop fires on every pass - hence the never-ending reappearances of the popup. The solution is to reset the "default GUI" value by using GUISwitch like this: Func popUpGui($imageLabel) Local $hDialog2 = GUICreate("Image Name : " & $imageLabel, 540, 415, -1, -1) Local $img2Use = @ScriptDir & "\thumbs\" & $sListFilter & "\" & $imageLabel & ".bmp" Local $iBtnL = GUICtrlCreateButton("", 25, 25, 286, 364, BitOR($BS_BITMAP, $BS_DEFPUSHBUTTON)) GUICtrlSetImage($iBtnL, $img2Use) GUISetState() While 2 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ; Delete popup GUI GUIDelete($hDialog2) ; Reset default GUI for control creation GUISwitch($hDialog) ExitLoop EndSwitch WEnd EndFunc Now the main GUI is reset as the one in which to create the new set of buttons and all works as it should when you alter the display using the top 2 selection buttons. All clear? M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
dynamitemedia Posted March 7, 2016 Share Posted March 7, 2016 yes that is clear thanks, i was on the right track  using GUISetState(@SW_ENABLE, $hGUI) WinActivate($hGUI) but also so far away, i knew i had to do something to get the main gui back as the main again, thank you very much  Link to comment Share on other sites More sharing options...
dynamitemedia Posted March 27, 2016 Share Posted March 27, 2016 (edited) i am noticing an issue with the code you posted above.  the page down to get back to the bottom won't work...  so i do the following: 1.) open up gui 2.) page up --  the tab , enter etc work.  the arrow keys do not 3.) then hit page down to get back to gui.  and it won't go back down UNLESS 4.) you click on a box with a mouse can you check that out and see if you can recreate and fix that bug?  Thanks   UPDATED CODE: expandcollapse popup#include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <WinAPI.au3> #include <File.au3> #include <Date.au3> #include <Array.au3> #include "GUIScrollbars_Ex.au3" ; Declare global arrays to hold ControlIDs Global $aImage, $aButton, $aLabel ; Declare image count Global $iCount ; Max buttons per row Global $iCol_Count = 5 Global $hActive, $iRow_Count, $hDialog, $fFocusMain = True, $cCurrFocus = 9999 Global $hGUI, $hDialog, $hDialog2,$lastsec,$lblTime ; Set max dialog size $iDialog_Width = 1265 $iDialog_Depth = 720 ; Determine button width $iButton_Dim = Floor(($iDialog_Width - 10 - _WinAPI_GetSystemMetrics(2)) / $iCol_Count) ; Set default listing filter $sListFilter = "Functions" ; Determine required depths $iVisRows = 0 While 1 $iVisRows += 1 If $iButton_Dim * $iVisRows > $iDialog_Depth Then $iVisRows -= 1 ExitLoop EndIf WEnd $iDialog_Depth = ($iButton_Dim * $iVisRows) + 10 ; Add the space for the buttons to get the main GUI size $iMain_Depth = $iDialog_Depth + 200 Global $1stTimeOpened = "yes" ; <<<< change for yourself --------------------------------------------------------->> Global $img2load1stTime = @ScriptDir & "\www\img\maxresdefault.jpg" Mainscript() Func Mainscript() ; List the images to display $aImage = _List_Images($sListFilter) $iCount = UBound($aImage) ; Create arrays to hold button and label ControlIDs Global $aButton[$iCount], $aLabel[$iCount] ; Determine rows required $iRow_Count = Ceiling($iCount / $iCol_Count) ; Create main GUI $hGUI = GUICreate("MainGUI", $iDialog_Width, $iMain_Depth) ;---------------------- set the day and time -------------------------------------- $clockDepth = $iMain_Depth - 60 $lblTime = GUICtrlCreateLabel(" ", ($iDialog_Width - 200), 36, 300, 65) $lastsec = @SEC GUICtrlSetFont(-1, 20, 600, 0, "Arial") $addDate = _DateTimeFormat(_NowCalc(), 1) $lbldate = GUICtrlCreateLabel($addDate, 40 ,$clockDepth, 420, 65) GUICtrlSetFont(-1, 20, 600, 0, "Arial") $cPrograms = GUICtrlCreateButton("Functions", ($iDialog_Width / 2) - 280, 20, 300, 60) GUICtrlSetFont(-1, 20, 600, 0, "Arial") $cNetWorks = GUICtrlCreateButton("Constants", ($iDialog_Width / 2) + 80, 20, 300, 60) GUICtrlSetFont(-1, 20, 600, 0, "Arial") $exitButton = GUICtrlCreateButton("Exit", ($iDialog_Width - 340), $clockDepth - 20, 300, 60) GUICtrlSetFont(-1, 20, 600, 0, "Arial") ;Create a combobox control. Local $idComboBox = GUICtrlCreateCombo("Category 1", 40, 32, 250, 250) GUICtrlSetFont(-1, 20, 600, 0, "Arial") ;Add additional items to the combobox. GUICtrlSetData($idComboBox, " test 1 | test 12 |Category 2| test 124 | test 124", "test 12") GUICtrlSetFont(-1, 20, 600, 0, "Arial") GUISetState() ; Create middle inside gui $hDialog = GUICreate("", $iDialog_Width, $iDialog_Depth, 0, 100, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) GUISetBkColor(0xFFFFFF) ConsoleWrite("1stTimeOpened : " & $1stTimeOpened & @CRLF) If $1stTimeOpened = "yes" Then ConsoleWrite("1stTimeOpened : " & $1stTimeOpened & @CRLF) Local $idPic = GUICtrlCreatePic($img2load1stTime, 30, 30, 500, 450) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $exitButton ExitLoop Case $cPrograms If $sListFilter <> "Functions" Then $sListFilter = "Functions" Global $1stTimeOpened = "no" GUICtrlDelete($idPic) _Load_Images($sListFilter) EndIf Case $cNetWorks If $sListFilter <> "Constants" Then $sListFilter = "Constants" Global $1stTimeOpened = "no" GUICtrlDelete($idPic) _Load_Images($sListFilter) EndIf EndSwitch updateTime() Sleep(10) WEnd ElseIf $1stTimeOpened = "no" Then GUISetBkColor(0xFFFFFF) If $iRow_Count > $iVisRows Then _GUIScrollbars_Generate($hDialog, 0, $iButton_Dim * $iRow_Count) EndIf _Draw_Images() ; Create dummy controls $cDummy_Up = GUICtrlCreateDummy() $cDummy_Dn = GUICtrlCreateDummy() $cDummy_Left = GUICtrlCreateDummy() $cDummy_Right = GUICtrlCreateDummy() $cDummy_PgDn = GUICtrlCreateDummy() $cDummy_PgUp = GUICtrlCreateDummy() GUISetState() ; Set the Up/Down/Left/Right keys as accelerators - they will only act like this when your GUI is active Local $aAccelKeys[6][2] = [["{UP}", $cDummy_Up], ["{DOWN}", $cDummy_Dn], ["{LEFT}", $cDummy_Left], ["{RIGHT}", $cDummy_Right], ["{PGUP}", $cDummy_PgUp], ["{PGDN}", $cDummy_PgDn]] GUISetAccelerators($aAccelKeys, $hGUI) GUISetAccelerators($aAccelKeys, $hDialog) While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $cPrograms If $sListFilter <> "Functions" Then $sListFilter = "Functions" local $1stTimeOpened = "no" _Load_Images($sListFilter) EndIf Case $cNetWorks If $sListFilter <> "Constants" Then $sListFilter = "Constants" local $1stTimeOpened = "no" _Load_Images($sListFilter) EndIf Case $cDummy_Up _Move_Focus($hDialog, 1) Case $cDummy_Dn _Move_Focus($hDialog, 2) Case $cDummy_Left _Move_Focus($hDialog, 3) Case $cDummy_Right _Move_Focus($hDialog, 4) Case $cDummy_PgUp GUICtrlSetState($cPrograms, $GUI_FOCUS) Case $cDummy_PgDn GUICtrlSetState($cCurrFocus, $GUI_FOCUS) Case Else For $i = 0 To $iCount - 1 If $iMsg = $aButton[$i] Then $imgLabel2send = GUICtrlRead($aButton[$i]) MsgBox($MB_SYSTEMMODAL, "Pressed", $imgLabel2send) popUpGui($imgLabel2send) ExitLoop EndIf Next EndSwitch ; Get focused control $hCurrFocus = _WinAPI_GetFocus() ; If it has changed If $hCurrFocus <> $hActive Then ; See if it is a button For $i = 0 To $iCount - 1 If $hCurrFocus = GUICtrlGetHandle($aButton[$i]) Then ; Reset all the labels For $j = 0 To $iCount - 1 GUICtrlSetBkColor($aLabel[$j], 0xFFFFFF) Next ; Highlight the correct label GUICtrlSetBkColor($aLabel[$i], 0x00FF00) ; Store ControlID $cCurrFocus = $aButton[$i] ExitLoop EndIf Next $hActive = $hCurrFocus EndIf updateTime() Sleep(10) WEnd EndIf EndFunc ;==>Mainscript Func _Draw_Images() ; Create labels For $i = 0 To $iRow_Count - 1 For $j = 0 To $iCol_Count - 1 $iIndex = $j + ($i * $iCol_Count) If $iIndex > $iCount - 1 Then ExitLoop $aLabel[$iIndex] = GUICtrlCreateLabel("", 10 + ($iButton_Dim * $j), 10 + ($iButton_Dim * $i), $iButton_Dim - 10, $iButton_Dim - 10) GUICtrlSetBkColor($aLabel[$iIndex], 0xFFFFFF) GUICtrlSetState($aLabel[$iIndex], $GUI_DISABLE) GUICtrlSetResizing($aLabel[$iIndex], $GUI_DOCKALL) Next Next ; Create buttons For $i = 0 To $iRow_Count - 1 For $j = 0 To $iCol_Count - 1 $iIndex = $j + ($i * $iCol_Count) If $iIndex > $iCount - 1 Then ExitLoop $aButton[$iIndex] = GUICtrlCreateButton($aImage[$iIndex], 15 + ($iButton_Dim * $j), 15 + ($iButton_Dim * $i), $iButton_Dim - 20, $iButton_Dim - 20, $BS_BITMAP) GUICtrlSetImage($aButton[$iIndex], $aImage[$iIndex]) GUICtrlSetResizing($aButton[$iIndex], $GUI_DOCKALL) Next Next ; Set default button GUICtrlSetState($aButton[0], $GUI_FOCUS) GUICtrlSetBkColor($aLabel[0], 0x00FF00) $hActive = GUICtrlGetHandle($aButton[0]) EndFunc ;==>_Draw_Images Func _Load_Images($sListFilter) ConsoleWrite("1stTimeOpened : " & $1stTimeOpened & @CRLF) ; Remove current images, buttons and labels For $i = 0 To $iCount - 1 GUICtrlDelete($aButton[$i]) GUICtrlDelete($aLabel[$i]) Next ; Liat the images to display $aImage = _List_Images($sListFilter) $iCount = UBound($aImage) ; Create arrays to hold button and label ControlIDs Global $aButton[$iCount], $aLabel[$iCount] ; Determine rows required $iRow_Count = Ceiling($iCount / $iCol_Count) ; Redraw buttons _Draw_Images() ; Scrol to top, hide and if required reset the scrolling _GUIScrollbars_Scroll_Page($hDialog, 0, 1) _GUIScrollBars_ShowScrollBar($hDialog, $SB_BOTH, False) If $iRow_Count > $iVisRows Then _GUIScrollbars_Generate($hDialog, 0, $iButton_Dim * $iRow_Count) EndIf EndFunc ;==>_Load_Images Func _List_Images($sFilter) ; Here you would have your FileListToArray lines to get a list of the images to display ; But for this example we will look in the AutoIt include folder and show files with/without "Constant" in the name Local $sIncludeFolder = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", Default, -1)) & "Include" Local $aList = _FileListToArray($sIncludeFolder, "*.au3", $FLTA_FILES) ; Now filter according to the setting For $i = $aList[0] To 1 Step -1 Switch $sFilter Case "Functions" If StringInStr($aList[$i], "Constant") Then _ArrayDelete($aList, $i) $aList[0] -= 1 EndIf Case "Constants" If Not StringInStr($aList[$i], "Constant") Then _ArrayDelete($aList, $i) $aList[0] -= 1 EndIf EndSwitch Next ; Remove the count element _ArrayDelete($aList, 0) ; And return the list Return $aList EndFunc ;==>_List_Images Func _Move_Focus($hDialog, $iMode) Local $iNext_Button, $iRow, $iNewRow Local $iRow_Count = Ceiling($iCount / $iCol_Count) ; Get active control $hActive = _WinAPI_GetFocus() For $i = 0 To $iCount - 1 ; If it is a button If $hActive = GUICtrlGetHandle($aButton[$i]) Then ; Determine row $iRow = Int($i / $iCol_Count) $iNewRow = $iRow ; Set default value for next button $iNext_Button = $i Switch $iMode Case 1 ; Not if in top row If $iRow Then $iNext_Button -= $iCol_Count ; Set new row $iNewRow -= 1 EndIf Case 2 ; Not if in bottom row or there no button below If ($iRow < $iRow_Count - 1) And ($i + $iCol_Count < $iCount) Then $iNext_Button += $iCol_Count ; Set new row $iNewRow += 1 EndIf Case 3 ; If not first button If $i <> 0 Then $iNext_Button -= 1 $iNewRow = Int($iNext_Button / $iCol_Count) EndIf Case 4 ; If not last button If $i <> $iCount Then $iNext_Button += 1 $iNewRow = Int($iNext_Button / $iCol_Count) EndIf EndSwitch ; Set focus to new button GUICtrlSetState($aButton[$iNext_Button], $GUI_FOCUS) ; Get button into view by scrolling to page which includes button _GUIScrollbars_Scroll_Page($hDialog, 0, Int($iNewRow / 2) + 1) ; No point in looking further ExitLoop EndIf Next EndFunc ;==>_Move_Focus func popUpGui($imgLabel) Global $imageLabel = $imgLabel Global $hDialog2 = GUICreate("Image Name : " & $imageLabel, 540, 415, -1, -1) local $img2Use = @ScriptDir & "\thumbs\" & $sListFilter & "\" & $imageLabel & ".bmp" Global $iBtnL = GUICtrlCreateButton("", 25, 25, 286, 364, BitOR($BS_BITMAP, $BS_DEFPUSHBUTTON) ) GUICtrlSetImage($iBtnL, $img2Use) GUISetState() While 2 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ; activate main gui GUISetState(@SW_ENABLE, $hGUI) WinActivate($hGUI) ; activate child gui GUISetState(@SW_ENABLE, $hDialog) WinActivate($hDialog) ; delete this popup gui GUIDelete($hDialog2) ExitLoop EndSwitch WEnd EndFunc Func updateTime() $cursec = @SEC if $cursec <> $lastsec Then $lastsec = $cursec GUICtrlSetData($lblTime , "" & _NowTime()) EndIf EndFunc Also i added a combo box  so i could do  dropdown , do you think a double enter would be best to go there or a Go button?  i think a double enter would feel natural no matter how big i make the drop down only the font size will make it thicker, am i missing something in the Docs? thanks once again @Melba23  Edited March 27, 2016 by dynamitemedia added/updated code Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 27, 2016 Moderators Share Posted March 27, 2016 dynamitemedia, Once I sorted out the awful mess you had made of the code when adding the initial picture, it works fine for me: expandcollapse popup#include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <WinAPI.au3> #include <File.au3> #include <Date.au3> #include <Array.au3> #include "GUIScrollbars_Ex.au3" ; Declare global arrays to hold ControlIDs Global $aImage, $aButton, $aLabel ; Declare image count Global $iCount ; Max buttons per row Global $iCol_Count = 5 Global $hActive, $iRow_Count, $hDialog, $fFocusMain = True, $cCurrFocus = 9999 Global $f1stTimeOpened = True Global $sImg2load1stTime = @ScriptDir & "\www\img\maxresdefault.jpg" Global $idLblTime ; Create listing filter Global $sListFilter = "" ; Set max dialog size $iDialog_Width = 1265 $iDialog_Depth = 720 ; Determine button width $iButton_Dim = Floor(($iDialog_Width - 10 - _WinAPI_GetSystemMetrics(2)) / $iCol_Count) ; Determine required depths $iVisRows = 0 While 1 $iVisRows += 1 If $iButton_Dim * $iVisRows > $iDialog_Depth Then $iVisRows -= 1 ExitLoop EndIf WEnd $iDialog_Depth = ($iButton_Dim * $iVisRows) + 10 ; Add the space for the buttons to get the main GUI size $iMain_Depth = $iDialog_Depth + 200 Mainscript() Func Mainscript() ; Liat the images to display $aImage = _List_Images($sListFilter) $iCount = UBound($aImage) ; Create arrays to hold button and label ControlIDs Global $aButton[$iCount], $aLabel[$iCount] ; Determine rows required $iRow_Count = Ceiling($iCount / $iCol_Count) ; Create main GUI $hGUI = GUICreate("MainGUI", $iDialog_Width, $iMain_Depth) $cPrograms = GUICtrlCreateButton("Functions", ($iDialog_Width / 2) - 320, 20, 300, 60) $cNetWorks = GUICtrlCreateButton("Constants", ($iDialog_Width / 2) + 20, 20, 300, 60) $clockDepth = $iMain_Depth - 60 $idLblTime = GUICtrlCreateLabel(" ", ($iDialog_Width - 200), 36, 300, 65) $iLastSec = @SEC GUICtrlSetFont(-1, 20, 600, 0, "Arial") $sAddDate = _DateTimeFormat(_NowCalc(), 1) $idLblDate = GUICtrlCreateLabel($sAddDate, 40, $clockDepth, 420, 65) GUICtrlSetFont(-1, 20, 600, 0, "Arial") ;Create a combobox control. Local $idComboBox = GUICtrlCreateCombo("Category 1", 40, 32, 250, 250) GUICtrlSetFont(-1, 20, 600, 0, "Arial") ;Add additional items to the combobox. GUICtrlSetData($idComboBox, " test 1 | test 12 |Category 2| test 124 | test 124", "test 12") GUICtrlSetFont(-1, 20, 600, 0, "Arial") GUISetState() ; Create dialog $hDialog = GUICreate("", $iDialog_Width, $iDialog_Depth, 0, 100, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) GUISetBkColor(0xFFFFFF) If $iRow_Count > $iVisRows Then _GUIScrollbars_Generate($hDialog, 0, $iButton_Dim * $iRow_Count) EndIf Local $idPic = GUICtrlCreatePic($sImg2load1stTime, 30, 30, 500, 450) ; Create dummy controls $cDummy_Up = GUICtrlCreateDummy() $cDummy_Dn = GUICtrlCreateDummy() $cDummy_Left = GUICtrlCreateDummy() $cDummy_Right = GUICtrlCreateDummy() $cDummy_PgDn = GUICtrlCreateDummy() $cDummy_PgUp = GUICtrlCreateDummy() GUISetState() ; Set the Up/Down/Left/Right keys as accelerators - they will only act like this when your GUI is active Local $aAccelKeys[6][2] = [["{UP}", $cDummy_Up], ["{DOWN}", $cDummy_Dn], ["{LEFT}", $cDummy_Left], ["{RIGHT}", $cDummy_Right], ["{PGUP}", $cDummy_PgUp], ["{PGDN}", $cDummy_PgDn]] GUISetAccelerators($aAccelKeys, $hGUI) GUISetAccelerators($aAccelKeys, $hDialog) While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $cPrograms If $f1stTimeOpened Then GUICtrlDelete($idPic) $f1stTimeOpened = False EndIf If $sListFilter <> "Functions" Then $sListFilter = "Functions" _Load_Images($sListFilter) EndIf Case $cNetWorks If $f1stTimeOpened Then GUICtrlDelete($idPic) $f1stTimeOpened = False EndIf If $sListFilter <> "Constants" Then $sListFilter = "Constants" _Load_Images($sListFilter) EndIf Case $cDummy_Up _Move_Focus($hDialog, 1) Case $cDummy_Dn _Move_Focus($hDialog, 2) Case $cDummy_Left _Move_Focus($hDialog, 3) Case $cDummy_Right _Move_Focus($hDialog, 4) Case $cDummy_PgUp GUICtrlSetState($cPrograms, $GUI_FOCUS) Case $cDummy_PgDn GUICtrlSetState($cCurrFocus, $GUI_FOCUS) Case 0 ; Do nothing - needed because button array is empty when first started Case Else For $i = 0 To $iCount - 1 If $iMsg = $aButton[$i] Then MsgBox($MB_SYSTEMMODAL, "Pressed", GUICtrlRead($aButton[$i])) ExitLoop EndIf Next EndSwitch ; Get focused control $hCurrFocus = _WinAPI_GetFocus() ; If it has changed If $hCurrFocus <> $hActive Then ; See if it is a button For $i = 0 To $iCount - 1 If $hCurrFocus = GUICtrlGetHandle($aButton[$i]) Then ; Reset all the labels For $j = 0 To $iCount - 1 GUICtrlSetBkColor($aLabel[$j], 0xFFFFFF) Next ; Highlight the correct label GUICtrlSetBkColor($aLabel[$i], 0x00FF00) ; Store ControlID $cCurrFocus = $aButton[$i] ExitLoop EndIf Next $hActive = $hCurrFocus EndIf _UpdateTime() WEnd EndFunc ;==>Mainscript Func _Draw_Images() ; Create labels For $i = 0 To $iRow_Count - 1 For $j = 0 To $iCol_Count - 1 $iIndex = $j + ($i * $iCol_Count) If $iIndex > $iCount - 1 Then ExitLoop $aLabel[$iIndex] = GUICtrlCreateLabel("", 10 + ($iButton_Dim * $j), 10 + ($iButton_Dim * $i), $iButton_Dim - 10, $iButton_Dim - 10) GUICtrlSetBkColor($aLabel[$iIndex], 0xFFFFFF) GUICtrlSetState($aLabel[$iIndex], $GUI_DISABLE) GUICtrlSetResizing($aLabel[$iIndex], $GUI_DOCKALL) Next Next ; Create buttons For $i = 0 To $iRow_Count - 1 For $j = 0 To $iCol_Count - 1 $iIndex = $j + ($i * $iCol_Count) If $iIndex > $iCount - 1 Then ExitLoop $aButton[$iIndex] = GUICtrlCreateButton($aImage[$iIndex], 15 + ($iButton_Dim * $j), 15 + ($iButton_Dim * $i), $iButton_Dim - 20, $iButton_Dim - 20, $BS_BITMAP) GUICtrlSetImage($aButton[$iIndex], $aImage[$iIndex]) GUICtrlSetResizing($aButton[$iIndex], $GUI_DOCKALL) Next Next ; Set default button GUICtrlSetState($aButton[0], $GUI_FOCUS) GUICtrlSetBkColor($aLabel[0], 0x00FF00) $hActive = GUICtrlGetHandle($aButton[0]) EndFunc ;==>_Draw_Images Func _Load_Images($sListFilter) ; Remove current images, buttons and labels For $i = 0 To $iCount - 1 GUICtrlDelete($aButton[$i]) GUICtrlDelete($aLabel[$i]) Next ; Liat the images to display $aImage = _List_Images($sListFilter) $iCount = UBound($aImage) ; Create arrays to hold button and label ControlIDs Global $aButton[$iCount], $aLabel[$iCount] ; Determine rows required $iRow_Count = Ceiling($iCount / $iCol_Count) ; Redraw buttons _Draw_Images() ; Scrol to top, hide and if required reset the scrolling _GUIScrollbars_Scroll_Page($hDialog, 0, 1) _GUIScrollBars_ShowScrollBar($hDialog, $SB_BOTH, False) If $iRow_Count > $iVisRows Then _GUIScrollbars_Generate($hDialog, 0, $iButton_Dim * $iRow_Count) EndIf EndFunc ;==>_Load_Images Func _List_Images($sFilter) ; Here you would have your FileListToArray lines to get a list of the images to display ; But for this example we will look in the AutoIt include folder and show files with/without "Constant" in the name Local $sIncludeFolder = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", Default, -1)) & "Include" Local $aList = _FileListToArray($sIncludeFolder, "*.au3", $FLTA_FILES) ; Now filter according to the setting For $i = $aList[0] To 1 Step -1 Switch $sFilter Case "Functions" If StringInStr($aList[$i], "Constant") Then _ArrayDelete($aList, $i) $aList[0] -= 1 EndIf Case "Constants" If Not StringInStr($aList[$i], "Constant") Then _ArrayDelete($aList, $i) $aList[0] -= 1 EndIf EndSwitch Next ; Remove the count element _ArrayDelete($aList, 0) ; And return the list Return $aList EndFunc ;==>_List_Images Func _Move_Focus($hDialog, $iMode) Local $iNext_Button, $iRow, $iNewRow Local $iRow_Count = Ceiling($iCount / $iCol_Count) ; Get active control $hActive = _WinAPI_GetFocus() For $i = 0 To $iCount - 1 ; If it is a button If $hActive = GUICtrlGetHandle($aButton[$i]) Then ; Determine row $iRow = Int($i / $iCol_Count) $iNewRow = $iRow ; Set default value for next button $iNext_Button = $i Switch $iMode Case 1 ; Not if in top row If $iRow Then $iNext_Button -= $iCol_Count ; Set new row $iNewRow -= 1 EndIf Case 2 ; Not if in bottom row or there no button below If ($iRow < $iRow_Count - 1) And ($i + $iCol_Count < $iCount) Then $iNext_Button += $iCol_Count ; Set new row $iNewRow += 1 EndIf Case 3 ; If not first button If $i <> 0 Then $iNext_Button -= 1 $iNewRow = Int($iNext_Button / $iCol_Count) EndIf Case 4 ; If not last button If $i <> $iCount Then $iNext_Button += 1 $iNewRow = Int($iNext_Button / $iCol_Count) EndIf EndSwitch ; Set focus to new button GUICtrlSetState($aButton[$iNext_Button], $GUI_FOCUS) ; Get button into view by scrolling to page which includes button _GUIScrollbars_Scroll_Page($hDialog, 0, Int($iNewRow / 2) + 1) ; No point in looking further ExitLoop EndIf Next EndFunc ;==>_Move_Focus Func _UpdateTime() Static Local $iLastSec = @SEC $iCurrSec = @SEC If $iCurrSec <> $iLastSec Then $iLastSec = $iCurrSec GUICtrlSetData($idLblTime, "" & _NowTime()) EndIf EndFunc ;==>_UpdateTime Please ask if you have any questions about how I have recast the code to make it work. M23 dynamitemedia 1  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
dynamitemedia Posted March 27, 2016 Share Posted March 27, 2016 sorry  i tried l one question b4 i go to bed and look in more detail my eyes are shot,  did you think a Go buton for drop down is better or double enter? the double enter would basically be a new Global $sListFilter = "" thanks Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 27, 2016 Moderators Share Posted March 27, 2016 dynamitemedia, Quote did you think a Go buton for drop down is better or double enter? That makes no sense at all to me. Go and get some sleep and come back when you can explain more clearly. M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
dynamitemedia Posted March 27, 2016 Share Posted March 27, 2016 ha the combo box.... it will be loaded with "$sListFilter" items so when u look in the drop down, you scroll to one and hit enter it selects one of them. i want that selected item to be used as  a $sListFilter item...  i prefer the 2nd time you hit enter it will send to the Func _List_Images($sFilter) to load the images.  because going to be more than 6 of them and dont want that many buttons on the top gui... hope that helps Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 27, 2016 Moderators Share Posted March 27, 2016 dynamitemedia, Do you want the combo to replace the existing buttons, or will it be in addition? If the former, then I would suggest that you retain one button to action the selection that has been made in the combo - if the latter then I would just action the combo selection as it is made. Just let me know how you want them to work and I will see what I can do. M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
dynamitemedia Posted March 27, 2016 Share Posted March 27, 2016 (edited) i think one to replace  the other will just "refresh"  the already displayed images...  just waking up again  after a trip to ER...  going to play with it a bit now  expandcollapse popup#include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <WinAPI.au3> #include <File.au3> #include <Date.au3> #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <Array.au3> #include "GUIScrollbars_Ex.au3" ; Declare global arrays to hold ControlIDs Global $aImage, $aButton, $aLabel ; Declare image count Global $iCount ; Max buttons per row Global $iCol_Count = 5 Global $hActive, $iRow_Count, $hDialog, $fFocusMain = True, $cCurrFocus = 9999 Global $f1stTimeOpened = True Global $sImg2load1stTime = @ScriptDir & "\www\img\maxresdefault.jpg" Global $idLblTime ; Create listing filter Global $sListFilter = "" ; Set max dialog size $iDialog_Width = 1265 $iDialog_Depth = 720 ; Determine button width $iButton_Dim = Floor(($iDialog_Width - 10 - _WinAPI_GetSystemMetrics(2)) / $iCol_Count) ; Determine required depths $iVisRows = 0 While 1 $iVisRows += 1 If $iButton_Dim * $iVisRows > $iDialog_Depth Then $iVisRows -= 1 ExitLoop EndIf WEnd $iDialog_Depth = ($iButton_Dim * $iVisRows) + 10 ; Add the space for the buttons to get the main GUI size $iMain_Depth = $iDialog_Depth + 200 Mainscript() Func Mainscript() ; Liat the images to display $aImage = _List_Images($sListFilter) $iCount = UBound($aImage) ; Create arrays to hold button and label ControlIDs Global $aButton[$iCount], $aLabel[$iCount] ; Determine rows required $iRow_Count = Ceiling($iCount / $iCol_Count) ; Determine Bottom positions $clockDepth = $iMain_Depth - 60 ; Create main GUI $hGUI = GUICreate("MainGUI", $iDialog_Width, $iMain_Depth) $cGo = GUICtrlCreateButton("GO", ($iDialog_Width / 2) - 300, 20, 160, 60) GUICtrlSetFont(-1, 20, 600, 0, "Arial") $cNetWorks = GUICtrlCreateButton("Refresh", ($iDialog_Width - 508), $clockDepth - 20, 224, 60) GUICtrlSetFont(-1, 20, 600, 0, "Arial") $exitButton = GUICtrlCreateButton("Exit", ($iDialog_Width - 260), $clockDepth - 20, 224, 60) GUICtrlSetFont(-1, 20, 600, 0, "Arial") $idLblTime = GUICtrlCreateLabel(" ", ($iDialog_Width - 180), 36, 300, 65) $iLastSec = @SEC GUICtrlSetFont(-1, 20, 600, 0, "Arial") $sAddDate = _DateTimeFormat(_NowCalc(), 1) $idLblDate = GUICtrlCreateLabel($sAddDate, 40, $clockDepth, 420, 65) GUICtrlSetFont(-1, 20, 600, 0, "Arial") ;Create a combobox control. Local $idComboBox = GUICtrlCreateCombo("Category 1", 40, 32, 260, 250) GUICtrlSetFont(-1, 20, 600, 0, "Arial") ;Add additional items to the combobox. GUICtrlSetData($idComboBox, " test 1 | test 12 |Category 2| test 124 | test 124", "test 12") GUICtrlSetFont(-1, 20, 600, 0, "Arial") GUISetState() ; Create dialog $hDialog = GUICreate("", $iDialog_Width, $iDialog_Depth, 0, 100, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) GUISetBkColor(0xFFFFFF) If $iRow_Count > $iVisRows Then _GUIScrollbars_Generate($hDialog, 0, $iButton_Dim * $iRow_Count) EndIf ; <<<<<<<<<<<------------- load opening page info ----------------->>>>>>>>>>>>>>> Local $idPic = GUICtrlCreatePic($sImg2load1stTime, 30, 30, 500, 450) ; <<<<<<<<<<<----------------------------------------------------------------->>>>>>>>>>>>>>> ; Create dummy controls $cDummy_Up = GUICtrlCreateDummy() $cDummy_Dn = GUICtrlCreateDummy() $cDummy_Left = GUICtrlCreateDummy() $cDummy_Right = GUICtrlCreateDummy() $cDummy_PgDn = GUICtrlCreateDummy() $cDummy_PgUp = GUICtrlCreateDummy() GUISetState() ; Set the Up/Down/Left/Right keys as accelerators - they will only act like this when your GUI is active Local $aAccelKeys[6][2] = [["{UP}", $cDummy_Up], ["{DOWN}", $cDummy_Dn], ["{LEFT}", $cDummy_Left], ["{RIGHT}", $cDummy_Right], ["{PGUP}", $cDummy_PgUp], ["{PGDN}", $cDummy_PgDn]] GUISetAccelerators($aAccelKeys, $hGUI) GUISetAccelerators($aAccelKeys, $hDialog) While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $exitButton ExitLoop Case $cGo If $f1stTimeOpened Then GUICtrlDelete($idPic) $f1stTimeOpened = False EndIf $sListFilter = StringStripWS(GUICtrlRead($idComboBox), $STR_STRIPLEADING) ConsoleWrite("$sListFilter : " & $sListFilter & @CRLF) _Load_Images($sListFilter) Case $cNetWorks If $f1stTimeOpened Then GUICtrlDelete($idPic) $f1stTimeOpened = False EndIf If $sListFilter <> "Constants" Then $sListFilter = "Constants" _Load_Images($sListFilter) EndIf Case $cDummy_Up _Move_Focus($hDialog, 1) Case $cDummy_Dn _Move_Focus($hDialog, 2) Case $cDummy_Left _Move_Focus($hDialog, 3) Case $cDummy_Right _Move_Focus($hDialog, 4) Case $cDummy_PgUp GUICtrlSetState($cPrograms, $GUI_FOCUS) Case $cDummy_PgDn GUICtrlSetState($cCurrFocus, $GUI_FOCUS) Case 0 ; Do nothing - needed because button array is empty when first started Case Else For $i = 0 To $iCount - 1 If $iMsg = $aButton[$i] Then MsgBox($MB_SYSTEMMODAL, "Pressed", GUICtrlRead($aButton[$i])) ExitLoop EndIf Next EndSwitch ; Get focused control $hCurrFocus = _WinAPI_GetFocus() ; If it has changed If $hCurrFocus <> $hActive Then ; See if it is a button For $i = 0 To $iCount - 1 If $hCurrFocus = GUICtrlGetHandle($aButton[$i]) Then ; Reset all the labels For $j = 0 To $iCount - 1 GUICtrlSetBkColor($aLabel[$j], 0xFFFFFF) Next ; Highlight the correct label GUICtrlSetBkColor($aLabel[$i], 0x00FF00) ; Store ControlID $cCurrFocus = $aButton[$i] ExitLoop EndIf Next $hActive = $hCurrFocus EndIf _UpdateTime() WEnd EndFunc ;==>Mainscript Func _Draw_Images() ; Create labels For $i = 0 To $iRow_Count - 1 For $j = 0 To $iCol_Count - 1 $iIndex = $j + ($i * $iCol_Count) If $iIndex > $iCount - 1 Then ExitLoop $aLabel[$iIndex] = GUICtrlCreateLabel("", 10 + ($iButton_Dim * $j), 10 + ($iButton_Dim * $i), $iButton_Dim - 10, $iButton_Dim - 10) GUICtrlSetBkColor($aLabel[$iIndex], 0xFFFFFF) GUICtrlSetState($aLabel[$iIndex], $GUI_DISABLE) GUICtrlSetResizing($aLabel[$iIndex], $GUI_DOCKALL) Next Next ; Create buttons For $i = 0 To $iRow_Count - 1 For $j = 0 To $iCol_Count - 1 $iIndex = $j + ($i * $iCol_Count) If $iIndex > $iCount - 1 Then ExitLoop $aButton[$iIndex] = GUICtrlCreateButton($aImage[$iIndex], 15 + ($iButton_Dim * $j), 15 + ($iButton_Dim * $i), $iButton_Dim - 20, $iButton_Dim - 20, $BS_BITMAP) GUICtrlSetImage($aButton[$iIndex], $aImage[$iIndex]) GUICtrlSetResizing($aButton[$iIndex], $GUI_DOCKALL) Next Next ; Set default button GUICtrlSetState($aButton[0], $GUI_FOCUS) GUICtrlSetBkColor($aLabel[0], 0x00FF00) $hActive = GUICtrlGetHandle($aButton[0]) EndFunc ;==>_Draw_Images Func _Load_Images($sListFilter) ; Remove current images, buttons and labels For $i = 0 To $iCount - 1 GUICtrlDelete($aButton[$i]) GUICtrlDelete($aLabel[$i]) Next ; Liat the images to display $aImage = _List_Images($sListFilter) $iCount = UBound($aImage) ; Create arrays to hold button and label ControlIDs Global $aButton[$iCount], $aLabel[$iCount] ; Determine rows required $iRow_Count = Ceiling($iCount / $iCol_Count) ; Redraw buttons _Draw_Images() ; Scrol to top, hide and if required reset the scrolling _GUIScrollbars_Scroll_Page($hDialog, 0, 1) _GUIScrollBars_ShowScrollBar($hDialog, $SB_BOTH, False) If $iRow_Count > $iVisRows Then _GUIScrollbars_Generate($hDialog, 0, $iButton_Dim * $iRow_Count) EndIf EndFunc ;==>_Load_Images Func _List_Images($sFilter) ; Here you would have your FileListToArray lines to get a list of the images to display ; But for this example we will look in the AutoIt include folder and show files with/without "Constant" in the name Local $sIncludeFolder = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", Default, -1)) & "Include" Local $aList = _FileListToArray($sIncludeFolder, "*.au3", $FLTA_FILES) ; Now filter according to the setting For $i = $aList[0] To 1 Step -1 Switch $sFilter Case "Functions" If StringInStr($aList[$i], "Constant") Then _ArrayDelete($aList, $i) $aList[0] -= 1 EndIf Case "Constants" If Not StringInStr($aList[$i], "Constant") Then _ArrayDelete($aList, $i) $aList[0] -= 1 EndIf EndSwitch Next ; Remove the count element _ArrayDelete($aList, 0) ; And return the list Return $aList EndFunc ;==>_List_Images Func _Move_Focus($hDialog, $iMode) Local $iNext_Button, $iRow, $iNewRow Local $iRow_Count = Ceiling($iCount / $iCol_Count) ; Get active control $hActive = _WinAPI_GetFocus() For $i = 0 To $iCount - 1 ; If it is a button If $hActive = GUICtrlGetHandle($aButton[$i]) Then ; Determine row $iRow = Int($i / $iCol_Count) $iNewRow = $iRow ; Set default value for next button $iNext_Button = $i Switch $iMode Case 1 ; Not if in top row If $iRow Then $iNext_Button -= $iCol_Count ; Set new row $iNewRow -= 1 EndIf Case 2 ; Not if in bottom row or there no button below If ($iRow < $iRow_Count - 1) And ($i + $iCol_Count < $iCount) Then $iNext_Button += $iCol_Count ; Set new row $iNewRow += 1 EndIf Case 3 ; If not first button If $i <> 0 Then $iNext_Button -= 1 $iNewRow = Int($iNext_Button / $iCol_Count) EndIf Case 4 ; If not last button If $i <> $iCount Then $iNext_Button += 1 $iNewRow = Int($iNext_Button / $iCol_Count) EndIf EndSwitch ; Set focus to new button GUICtrlSetState($aButton[$iNext_Button], $GUI_FOCUS) ; Get button into view by scrolling to page which includes button _GUIScrollbars_Scroll_Page($hDialog, 0, Int($iNewRow / 2) + 1) ; No point in looking further ExitLoop EndIf Next EndFunc ;==>_Move_Focus Func _UpdateTime() Static Local $iLastSec = @SEC $iCurrSec = @SEC If $iCurrSec <> $iLastSec Then $iLastSec = $iCurrSec GUICtrlSetData($idLblTime, "" & _NowTime()) EndIf EndFunc ;==>_UpdateTime  the Go Button will choose image folder basically... The refresh should refresh whatever page that is being used that time... do you feel that look is pleasing to the eye?   also with that set up,  is it even possible to do a Tab?  say i a settings page or what not Edited March 27, 2016 by dynamitemedia Link to comment Share on other sites More sharing options...
dynamitemedia Posted March 28, 2016 Share Posted March 28, 2016 @Melba23Â Â Â i boticed that when you get to combo box... to do drop downs the up and down do not work to scroll thru them. Â Â is that a known bug? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 28, 2016 Moderators Share Posted March 28, 2016 dynamitemedia, The up/down keys do not work in the combo because you have set them as Accel keys - so we have to check whether the combo is open and, if so, cancel the Accel keys (look at lines 177-189): expandcollapse popup#include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <WinAPI.au3> #include <File.au3> #include <Date.au3> #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <GuiComboBox.au3> #include <Array.au3> #include "GUIScrollbars_Ex.au3" ; Declare global arrays to hold ControlIDs Global $aImage, $aButton, $aLabel ; Declare image count Global $iCount ; Max buttons per row Global $iCol_Count = 5 Global $hActive, $iRow_Count, $hDialog, $fFocusMain = True, $cCurrFocus = 9999 Global $f1stTimeOpened = True Global $sImg2load1stTime = @ScriptDir & "\www\img\maxresdefault.jpg" Global $idLblTime ; Create listing filter Global $sListFilter = "" ; Set max dialog size $iDialog_Width = 1265 $iDialog_Depth = 720 ; Determine button width $iButton_Dim = Floor(($iDialog_Width - 10 - _WinAPI_GetSystemMetrics(2)) / $iCol_Count) ; Determine required depths $iVisRows = 0 While 1 $iVisRows += 1 If $iButton_Dim * $iVisRows > $iDialog_Depth Then $iVisRows -= 1 ExitLoop EndIf WEnd $iDialog_Depth = ($iButton_Dim * $iVisRows) + 10 ; Add the space for the buttons to get the main GUI size $iMain_Depth = $iDialog_Depth + 200 Mainscript() Func Mainscript() ; Liat the images to display $aImage = _List_Images($sListFilter) $iCount = UBound($aImage) ; Create arrays to hold button and label ControlIDs Global $aButton[$iCount], $aLabel[$iCount] ; Determine rows required $iRow_Count = Ceiling($iCount / $iCol_Count) ; Determine Bottom positions $clockDepth = $iMain_Depth - 60 ; Create main GUI $hGUI = GUICreate("MainGUI", $iDialog_Width, $iMain_Depth) $idLblTime = GUICtrlCreateLabel(" ", ($iDialog_Width - 180), 36, 300, 65) $iLastSec = @SEC GUICtrlSetFont(-1, 20, 600, 0, "Arial") $sAddDate = _DateTimeFormat(_NowCalc(), 1) $idLblDate = GUICtrlCreateLabel($sAddDate, 40, $clockDepth, 420, 65) GUICtrlSetFont(-1, 20, 600, 0, "Arial") ;Create a combobox control. Local $idComboBox = GUICtrlCreateCombo("", 40, 32, 260, 250) GUICtrlSetFont(-1, 20, 600, 0, "Arial") ;Add items to the combobox. GUICtrlSetData($idComboBox, "Constants|Functions") GUICtrlSetFont(-1, 20, 600, 0, "Arial") $cGo = GUICtrlCreateButton("GO", ($iDialog_Width / 2) - 300, 20, 160, 60) GUICtrlSetFont(-1, 20, 600, 0, "Arial") $cRefresh = GUICtrlCreateButton("Refresh", ($iDialog_Width - 508), $clockDepth - 20, 224, 60) GUICtrlSetFont(-1, 20, 600, 0, "Arial") $exitButton = GUICtrlCreateButton("Exit", ($iDialog_Width - 260), $clockDepth - 20, 224, 60) GUICtrlSetFont(-1, 20, 600, 0, "Arial") GUISetState() ; Create dialog $hDialog = GUICreate("", $iDialog_Width, $iDialog_Depth, 0, 100, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) GUISetBkColor(0xFFFFFF) If $iRow_Count > $iVisRows Then _GUIScrollbars_Generate($hDialog, 0, $iButton_Dim * $iRow_Count) EndIf ; <<<<<<<<<<<------------- load opening page info ----------------->>>>>>>>>>>>>>> Local $idPic = GUICtrlCreatePic($sImg2load1stTime, 30, 30, 500, 450) ; <<<<<<<<<<<----------------------------------------------------------------->>>>>>>>>>>>>>> ; Create dummy controls $cDummy_Up = GUICtrlCreateDummy() $cDummy_Dn = GUICtrlCreateDummy() $cDummy_Left = GUICtrlCreateDummy() $cDummy_Right = GUICtrlCreateDummy() $cDummy_PgDn = GUICtrlCreateDummy() $cDummy_PgUp = GUICtrlCreateDummy() GUISetState() ; Set the Up/Down/Left/Right keys as accelerators - they will only act like this when your GUI is active Local $aAccelKeys[6][2] = [["{UP}", $cDummy_Up], ["{DOWN}", $cDummy_Dn], ["{LEFT}", $cDummy_Left], ["{RIGHT}", $cDummy_Right], ["{PGUP}", $cDummy_PgUp], ["{PGDN}", $cDummy_PgDn]] GUISetAccelerators($aAccelKeys, $hGUI) GUISetAccelerators($aAccelKeys, $hDialog) ; Set flag to show Accel keys active Local $fAccelSet = True While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $exitButton ExitLoop Case $cGo If $f1stTimeOpened Then GUICtrlDelete($idPic) $f1stTimeOpened = False EndIf $sListFilter = StringStripWS(GUICtrlRead($idComboBox), $STR_STRIPLEADING) ConsoleWrite("$sListFilter : " & $sListFilter & @CRLF) _Load_Images($sListFilter) Case $cRefresh If $f1stTimeOpened Then ; Do nothing Else _Load_Images($sListFilter) EndIf Case $cDummy_Up _Move_Focus($hDialog, 1) Case $cDummy_Dn _Move_Focus($hDialog, 2) Case $cDummy_Left _Move_Focus($hDialog, 3) Case $cDummy_Right _Move_Focus($hDialog, 4) Case $cDummy_PgUp GUICtrlSetState($cGo, $GUI_FOCUS) Case $cDummy_PgDn GUICtrlSetState($cCurrFocus, $GUI_FOCUS) Case 0 ; Do nothing - needed because button array is empty when first started Case Else For $i = 0 To $iCount - 1 If $iMsg = $aButton[$i] Then MsgBox($MB_SYSTEMMODAL, "Pressed", GUICtrlRead($aButton[$i])) ExitLoop EndIf Next EndSwitch ; Check if combo opened and Accel keys set If _GUICtrlComboBox_GetDroppedState($idComboBox) And $fAccelSet Then ; Clear flag and stop Accel keys $fAccelSet = False GUISetAccelerators(0, $hGUI) GUISetAccelerators(0, $hDialog) ; Check if combo closed and Accel keys inactive ElseIf (Not _GUICtrlComboBox_GetDroppedState($idComboBox)) And (Not $fAccelSet) Then ; Set flag and reset Accel keys $fAccelSet = True GUISetAccelerators($aAccelKeys, $hGUI) GUISetAccelerators($aAccelKeys, $hDialog) EndIf ; Get focused control $hCurrFocus = _WinAPI_GetFocus() ; If it has changed If $hCurrFocus <> $hActive Then ; See if it is a button For $i = 0 To $iCount - 1 If $hCurrFocus = GUICtrlGetHandle($aButton[$i]) Then ; Reset all the labels For $j = 0 To $iCount - 1 GUICtrlSetBkColor($aLabel[$j], 0xFFFFFF) Next ; Highlight the correct label GUICtrlSetBkColor($aLabel[$i], 0x00FF00) ; Store ControlID $cCurrFocus = $aButton[$i] ExitLoop EndIf Next $hActive = $hCurrFocus EndIf _UpdateTime() WEnd EndFunc ;==>Mainscript Func _Draw_Images() ; Create labels For $i = 0 To $iRow_Count - 1 For $j = 0 To $iCol_Count - 1 $iIndex = $j + ($i * $iCol_Count) If $iIndex > $iCount - 1 Then ExitLoop $aLabel[$iIndex] = GUICtrlCreateLabel("", 10 + ($iButton_Dim * $j), 10 + ($iButton_Dim * $i), $iButton_Dim - 10, $iButton_Dim - 10) GUICtrlSetBkColor($aLabel[$iIndex], 0xFFFFFF) GUICtrlSetState($aLabel[$iIndex], $GUI_DISABLE) GUICtrlSetResizing($aLabel[$iIndex], $GUI_DOCKALL) Next Next ; Create buttons For $i = 0 To $iRow_Count - 1 For $j = 0 To $iCol_Count - 1 $iIndex = $j + ($i * $iCol_Count) If $iIndex > $iCount - 1 Then ExitLoop $aButton[$iIndex] = GUICtrlCreateButton($aImage[$iIndex], 15 + ($iButton_Dim * $j), 15 + ($iButton_Dim * $i), $iButton_Dim - 20, $iButton_Dim - 20, $BS_BITMAP) GUICtrlSetImage($aButton[$iIndex], $aImage[$iIndex]) GUICtrlSetResizing($aButton[$iIndex], $GUI_DOCKALL) Next Next ; Set default button GUICtrlSetState($aButton[0], $GUI_FOCUS) GUICtrlSetBkColor($aLabel[0], 0x00FF00) $hActive = GUICtrlGetHandle($aButton[0]) EndFunc ;==>_Draw_Images Func _Load_Images($sListFilter) ; Remove current images, buttons and labels For $i = 0 To $iCount - 1 GUICtrlDelete($aButton[$i]) GUICtrlDelete($aLabel[$i]) Next ; Liat the images to display $aImage = _List_Images($sListFilter) $iCount = UBound($aImage) ; Create arrays to hold button and label ControlIDs Global $aButton[$iCount], $aLabel[$iCount] ; Determine rows required $iRow_Count = Ceiling($iCount / $iCol_Count) ; Redraw buttons _Draw_Images() ; Scrol to top, hide and if required reset the scrolling _GUIScrollbars_Scroll_Page($hDialog, 0, 1) _GUIScrollBars_ShowScrollBar($hDialog, $SB_BOTH, False) If $iRow_Count > $iVisRows Then _GUIScrollbars_Generate($hDialog, 0, $iButton_Dim * $iRow_Count) EndIf EndFunc ;==>_Load_Images Func _List_Images($sFilter) ; Here you would have your FileListToArray lines to get a list of the images to display ; But for this example we will look in the AutoIt include folder and show files with/without "Constant" in the name Local $sIncludeFolder = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", Default, -1)) & "Include" Local $aList = _FileListToArray($sIncludeFolder, "*.au3", $FLTA_FILES) ; Now filter according to the setting For $i = $aList[0] To 1 Step -1 Switch $sFilter Case "Functions" If StringInStr($aList[$i], "Constant") Then _ArrayDelete($aList, $i) $aList[0] -= 1 EndIf Case "Constants" If Not StringInStr($aList[$i], "Constant") Then _ArrayDelete($aList, $i) $aList[0] -= 1 EndIf EndSwitch Next ; Remove the count element _ArrayDelete($aList, 0) ; And return the list Return $aList EndFunc ;==>_List_Images Func _Move_Focus($hDialog, $iMode) Local $iNext_Button, $iRow, $iNewRow Local $iRow_Count = Ceiling($iCount / $iCol_Count) ; Get active control $hActive = _WinAPI_GetFocus() For $i = 0 To $iCount - 1 ; If it is a button If $hActive = GUICtrlGetHandle($aButton[$i]) Then ; Determine row $iRow = Int($i / $iCol_Count) $iNewRow = $iRow ; Set default value for next button $iNext_Button = $i Switch $iMode Case 1 ; Not if in top row If $iRow Then $iNext_Button -= $iCol_Count ; Set new row $iNewRow -= 1 EndIf Case 2 ; Not if in bottom row or there no button below If ($iRow < $iRow_Count - 1) And ($i + $iCol_Count < $iCount) Then $iNext_Button += $iCol_Count ; Set new row $iNewRow += 1 EndIf Case 3 ; If not first button If $i <> 0 Then $iNext_Button -= 1 $iNewRow = Int($iNext_Button / $iCol_Count) EndIf Case 4 ; If not last button If $i <> $iCount Then $iNext_Button += 1 $iNewRow = Int($iNext_Button / $iCol_Count) EndIf EndSwitch ; Set focus to new button GUICtrlSetState($aButton[$iNext_Button], $GUI_FOCUS) ; Get button into view by scrolling to page which includes button _GUIScrollbars_Scroll_Page($hDialog, 0, Int($iNewRow / 2) + 1) ; No point in looking further ExitLoop EndIf Next EndFunc ;==>_Move_Focus Func _UpdateTime() Static Local $iLastSec = @SEC $iCurrSec = @SEC If $iCurrSec <> $iLastSec Then $iLastSec = $iCurrSec GUICtrlSetData($idLblTime, "" & _NowTime()) EndIf EndFunc ;==>_UpdateTime I have also adjusted the behaviour of the "Refresh" key - if there is nothing to refresh it does nothing! Plus one or two other little tweaks which should be obvious. I do not fully understand what you mean when you say: Quote is it even possible to do a Tab?  say i a settings page or what not Do you mean that you want to put all of that GUI on a tab control with a setting page on another tab? If so I would counsel against it - what is wrong with adding a "Settings" button to open a separate dialog? M23 dynamitemedia 1  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
dynamitemedia Posted March 28, 2016 Share Posted March 28, 2016 i think your right about then settings option... tabs could get ugly and a mess... going to play with this code and see the changes you made Link to comment Share on other sites More sharing options...
dynamitemedia Posted March 29, 2016 Share Posted March 29, 2016 ok i went over the code line for line,  cause i obviously added a bunch of new code to it for my gui, lol...  that's when i realized it was not a oversight on my end with the copy and pasting certain code. when i Tab to the combo box, unless i click with my mouse it wont do anything, am i missing something?  like  i tried tabbing to it and hit enter and still nothing. Thanks @Melba23  your awesome! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 29, 2016 Moderators Share Posted March 29, 2016 dynamitemedia, Some people are never satisfied. We need to change the conditions for clearing/resetting the Accel keys. First, add these lines after having created the combo: ;Create a combobox control. Local $idComboBox = GUICtrlCreateCombo("", 40, 32, 260, 250) GUICtrlSetFont(-1, 20, 600, 0, "Arial") ;Add items to the combobox. GUICtrlSetData($idComboBox, "Constants|Functions") GUICtrlSetFont(-1, 20, 600, 0, "Arial") Local $tInfo _GUICtrlComboBox_GetComboBoxInfo($idComboBox, $tInfo) Local $hComboEdit = DllStructGetData($tInfo, "hEdit") Local $hComboList = DllStructGetData($tInfo, "hList") And then change the Accel key clear/reset code to this: ; Check if combo has focus and Accel keys set $hFocus = _WinAPI_GetFocus() If ($hFocus = $hComboEdit Or $hFocus = $hComboList) And $fAccelSet Then ; Clear flag and stop Accel keys $fAccelSet = False GUISetAccelerators(0, $hGUI) GUISetAccelerators(0, $hDialog) ; Check if combo not focused and Accel keys inactive ElseIf ($hFocus <> $hComboEdit And $hFocus <> $hComboList) And (Not $fAccelSet) Then ; Set flag and reset Accel keys $fAccelSet = True GUISetAccelerators($aAccelKeys, $hGUI) GUISetAccelerators($aAccelKeys, $hDialog) EndIf Now the Accel keys are cleared if either the combo edit or list has focus, so the arrow keys will work in either case. M23 dynamitemedia 1  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now