misioooo Posted September 4, 2014 Posted September 4, 2014 Hi! I did some script: expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiScrollBars.au3> #include <StructureConstants.au3> Opt("GUIResizeMode",$GUI_DOCKALL) #Region ### VAR/CONST DECLARATION ### Const $MANUFACTURER = 1 Const $MODEL = 2 Const $GROUP1 = 3 Const $GROUP2 = 4 Const $LAN = 5 Const $GSM = 6 Const $NONET = 7 Const $DISTANCE_S = 8 Const $DISTANCE_M = 9 Const $DISTANCE_L = 10 Const $PLAYER = 11 Const $EXTENDER = 12 Const $LICENSE = 13 Const $ADD_MON = 14 Const $GROUP = 15 Global $array2d_ControlID[50][16] $array2d_ControlID[0][0] = 1 ;because we start with 1 set of controls already created Local $_y_offset = 60 Local $_y_base_offset = 60 #EndRegion ### VAR/CONST DECLARATION ### #Region ### START Koda GUI section ### Form=d:\users\azpr196\documents\konfigurator ds autoit\form12.kxf ;*********** LABELS ***************** $hGUI = GUICreate("Form1", 1399, 682, 113, 102, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX)) $Label1 = GUICtrlCreateLabel("Producent", 48, 88, 53, 17) $Label2 = GUICtrlCreateLabel("Model", 144, 88, 33, 17) $Label3 = GUICtrlCreateLabel("Grupa", 304, 88, 33, 17) $Label4 = GUICtrlCreateLabel("Ekstender", 712, 88, 52, 17) ;********** GENERAL OPTIONS ******** ;********** 1st MONITOR ************ $array2d_ControlID[1][$MANUFACTURER] = GUICtrlCreateCombo("Samsung", 48, 120, 81, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) $array2d_ControlID[1][$MODEL] = GUICtrlCreateCombo("Model", 144, 120, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) $array2d_ControlID[1][$GROUP] = GUICtrlCreateInput("1", 304, 120, 41, 21) $array2d_ControlID[1][$GROUP1] = GUICtrlCreateGroup("Połączenie sieciowe", 360, 104, 153, 57) $array2d_ControlID[1][$LAN] = GUICtrlCreateRadio("LAN", 368, 128, 41, 17) GUICtrlSetState(-1, $GUI_CHECKED) $array2d_ControlID[1][$GSM] = GUICtrlCreateRadio("GSM", 408, 128, 41, 17) $array2d_ControlID[1][$NONET] = GUICtrlCreateRadio("Brak", 456, 128, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $array2d_ControlID[1][$GROUP2] = GUICtrlCreateGroup("Odległosć do poprzedniego", 520, 104, 169, 57) $array2d_ControlID[1][$DISTANCE_S] = GUICtrlCreateRadio("< 20m", 528, 128, 49, 17) GUICtrlSetState(-1, $GUI_CHECKED) $array2d_ControlID[1][$DISTANCE_M] = GUICtrlCreateRadio("20-50m", 576, 128, 57, 17) $array2d_ControlID[1][$DISTANCE_L] = GUICtrlCreateRadio("> 50m", 632, 128, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $array2d_ControlID[1][$PLAYER] = GUICtrlCreateCombo("Player", 864, 120, 89, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1,"|Player 1|Player 2|Player 3") $array2d_ControlID[1][$EXTENDER] = GUICtrlCreateCombo("Extender", 704, 120, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetState(-1, $GUI_DISABLE) $array2d_ControlID[1][$LICENSE] = GUICtrlCreateCheckbox("Licencja", 968, 120, 65, 17) GUICtrlSetState(-1, $GUI_DISABLE) $array2d_ControlID[1][$ADD_MON] = GUICtrlCreateButton("Dodaj monitor", 1048, 104, 59, 57, $BS_BITMAP) GUICtrlSetImage(-1, "D:\Users\azpr196\Documents\Konfigurator DS autoit\image_add.bmp", -1) GUIRegisterMsg($WM_SIZE, "WM_SIZE") GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL") GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### #Region ### INITIALIZE ### _GUIScrollBars_Init($hGUI) #EndRegion ### INITIALIZE ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $array2d_ControlID[1][$ADD_MON] _AddMon() EndSwitch WEnd Func _RefreshAll() MsgBox(0,"","Refresh function here...") EndFunc Func _AddMon() Local $i $array2d_ControlID[0][0] += 1 $i = $array2d_ControlID[0][0] $array2d_ControlID[$i][$MANUFACTURER] = GUICtrlCreateCombo("Samsung", 48, 120+$_y_offset, 81, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) $array2d_ControlID[$i][$MODEL] = GUICtrlCreateCombo("Model", 144, 120+$_y_offset, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) $array2d_ControlID[$i][$GROUP] = GUICtrlCreateInput("", 304, 120+$_y_offset, 41, 21) GUICtrlSetData(-1,GUICtrlRead($array2d_ControlID[$i-1][$GROUP])) $array2d_ControlID[$i][$GROUP1] = GUICtrlCreateGroup("Połączenie sieciowe", 360, 104+$_y_offset, 153, 57) $array2d_ControlID[$i][$LAN] = GUICtrlCreateRadio("LAN", 368, 128+$_y_offset, 41, 17) GUICtrlSetState(-1, $GUI_CHECKED) $array2d_ControlID[$i][$GSM] = GUICtrlCreateRadio("GSM", 408, 128+$_y_offset, 41, 17) $array2d_ControlID[$i][$NONET] = GUICtrlCreateRadio("Brak", 456, 128+$_y_offset, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $array2d_ControlID[$i][$GROUP2] = GUICtrlCreateGroup("Odległosć do poprzedniego", 520, 104+$_y_offset, 169, 57) $array2d_ControlID[$i][$DISTANCE_S] = GUICtrlCreateRadio("< 20m", 528, 128+$_y_offset, 49, 17) GUICtrlSetState(-1, $GUI_CHECKED) $array2d_ControlID[$i][$DISTANCE_M] = GUICtrlCreateRadio("20-50m", 576, 128+$_y_offset, 57, 17) $array2d_ControlID[$i][$DISTANCE_L] = GUICtrlCreateRadio("> 50m", 632, 128+$_y_offset, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $array2d_ControlID[$i][$PLAYER] = GUICtrlCreateCombo("Player", 864, 120+$_y_offset, 89, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1,"|Player 1|Player 2|Player 3") GUICtrlSetData(-1,GUICtrlRead($array2d_ControlID[$i-1][$PLAYER])) $array2d_ControlID[$i][$EXTENDER] = GUICtrlCreateCombo("Extender", 704, 120+$_y_offset, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetState(-1, $GUI_DISABLE) $array2d_ControlID[$i][$LICENSE] = GUICtrlCreateCheckbox("Licencja", 968, 120+$_y_offset, 65, 17) GUICtrlSetState(-1, $GUI_DISABLE) $array2d_ControlID[$i][$ADD_MON] = GUICtrlCreateButton("Dodaj monitor", 1048, 104+$_y_offset, 59, 57, $BS_BITMAP) GUICtrlSetImage(-1, "D:\Users\azpr196\Documents\Konfigurator DS autoit\image_add.bmp", -1) GUICtrlSetState($array2d_ControlID[$i-1][$ADD_MON],$GUI_HIDE) $array2d_ControlID[1][$ADD_MON] = $array2d_ControlID[$i][$ADD_MON] $_y_offset += $_y_base_offset EndFunc Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam Local $iIndex = -1, $iCharY, $iCharX, $iClientMaxX, $iClientX, $iClientY, $iMax For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $iClientMaxX = $__g_aSB_WindowInfo[$iIndex][1] $iCharX = $__g_aSB_WindowInfo[$iIndex][2] $iCharY = $__g_aSB_WindowInfo[$iIndex][3] $iMax = $__g_aSB_WindowInfo[$iIndex][7] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO) ; Retrieve the dimensions of the client area. $iClientX = BitAND($lParam, 0x0000FFFF) $iClientY = BitShift($lParam, 16) $__g_aSB_WindowInfo[$iIndex][4] = $iClientX $__g_aSB_WindowInfo[$iIndex][5] = $iClientY ; Set the vertical scrolling range and page size DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE)) DllStructSetData($tSCROLLINFO, "nMin", 0) DllStructSetData($tSCROLLINFO, "nMax", $iMax) DllStructSetData($tSCROLLINFO, "nPage", $iClientY / $iCharY) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) ; Set the horizontal scrolling range and page size DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE)) DllStructSetData($tSCROLLINFO, "nMin", 0) DllStructSetData($tSCROLLINFO, "nMax", 2 + $iClientMaxX / $iCharX) DllStructSetData($tSCROLLINFO, "nPage", $iClientX / $iCharX) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE Func WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $iScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $iCharX, $iPosX Local $iMin, $iMax, $iPage, $iPos, $iTrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $iCharX = $__g_aSB_WindowInfo[$iIndex][2] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 ; ; Get all the horizontal scroll bar information Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $iMin = DllStructGetData($tSCROLLINFO, "nMin") $iMax = DllStructGetData($tSCROLLINFO, "nMax") $iPage = DllStructGetData($tSCROLLINFO, "nPage") ; Save the position for comparison later on $iPosX = DllStructGetData($tSCROLLINFO, "nPos") $iPos = $iPosX $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") #forceref $iMin, $iMax Switch $iScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos) EndSwitch ; // Set the position and then retrieve it. Due to adjustments ; // by Windows it may not be the same as the value set. DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) ;// If the position has changed, scroll the window and update it $iPos = DllStructGetData($tSCROLLINFO, "nPos") If ($iPos <> $iPosX) Then _GUIScrollBars_ScrollWindow($hWnd, $iCharX * ($iPosX - $iPos), 0) Return $GUI_RUNDEFMSG EndFunc ;==>WM_HSCROLL Func WM_VSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam, $lParam Local $iScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $iCharY, $iPosY Local $iMin, $iMax, $iPage, $iPos, $iTrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $iCharY = $__g_aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 ; Get all the vertial scroll bar information Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $iMin = DllStructGetData($tSCROLLINFO, "nMin") $iMax = DllStructGetData($tSCROLLINFO, "nMax") $iPage = DllStructGetData($tSCROLLINFO, "nPage") ; Save the position for comparison later on $iPosY = DllStructGetData($tSCROLLINFO, "nPos") $iPos = $iPosY $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $iScrollCode Case $SB_TOP ; user clicked the HOME keyboard key DllStructSetData($tSCROLLINFO, "nPos", $iMin) Case $SB_BOTTOM ; user clicked the END keyboard key DllStructSetData($tSCROLLINFO, "nPos", $iMax) Case $SB_LINEUP ; user clicked the top arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) Case $SB_LINEDOWN ; user clicked the bottom arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage) Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos) EndSwitch ; // Set the position and then retrieve it. Due to adjustments ; // by Windows it may not be the same as the value set. DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) ;// If the position has changed, scroll the window and update it $iPos = DllStructGetData($tSCROLLINFO, "nPos") If ($iPos <> $iPosY) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $iCharY * ($iPosY - $iPos)) $iPosY = $iPos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_VSCROLL Any tips how to do "scrolling" when i add more controls (using a button in GUI)?
computergroove Posted September 4, 2014 Posted September 4, 2014 (edited) https://www.autoitscript.com/autoit3/docs/libfunctions/_GUIScrollBars_Init.htm On line 76 I added _GUIScrollBars_Init($hGUI,2000,10000) It added scroll bars to the bottom and the side. You can use a variable for these values and just add a value to the variable instead of having a large number. Edited September 4, 2014 by computergroove Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
computergroove Posted September 4, 2014 Posted September 4, 2014 While 1 Local $VHeight = 900 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $array2d_ControlID[1][$ADD_MON] _AddMon() $VHeight = $VHeight + 100 _GUIScrollBars_Init($hGUI,1000,$VHeight) EndSwitch I added this to line 79 with mixed results. It is supposed to add vertical height to the scrollbar every time you hit the button but the program refreshes the window and I get mixed results. My first thought is to have the control add a line in the gui under the top line rather than have the whole control show up under the top item. Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
Moderators Melba23 Posted September 4, 2014 Moderators Posted September 4, 2014 misioooo,My GUIScrollBars_Size UDF is what you need - take a look at Example 2 in particular. 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
misioooo Posted September 4, 2014 Author Posted September 4, 2014 (edited) Looked at it - looks awesome, but of course... I have no idea what i am doing wrong. Looks like $aBet (being a result of _GUIScrollbars_Size) is not an array (so some error in ..._Size function). Before that point - $aBet is an array. Line 128: expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiScrollBars.au3> #include <StructureConstants.au3> #include <ScrollBarConstants.au3> #include <Array.au3> #include "GUIScrollbars_Size.au3" Opt("GUIResizeMode",$GUI_DOCKALL) #Region ### VAR/CONST DECLARATION ### Const $MANUFACTURER = 1 Const $MODEL = 2 Const $GROUP1 = 3 Const $GROUP2 = 4 Const $LAN = 5 Const $GSM = 6 Const $NONET = 7 Const $DISTANCE_S = 8 Const $DISTANCE_M = 9 Const $DISTANCE_L = 10 Const $PLAYER = 11 Const $EXTENDER = 12 Const $LICENSE = 13 Const $ADD_MON = 14 Const $GROUP = 15 Const $REM_MON = 16 Global $array2d_ControlID[2][17] $array2d_ControlID[0][0] = 1 ;because we start with 1 set of controls already created Local $_y_offset = 60 Local $_y_base_offset = 60 Global $player_list = "|Player 1|Player 2|Player 3|Player 4" Global $manufacturer_list = "|Samsung|LG|Iiyama|Philips|NEC" Global $samsung_list = "" Global $iiyama_list = "" Global $nec_list = "" Global $philips_list = "" Global $lg_list = "" ;*** USED FOR SCROLLBARS $iH_Aperture = 400 $iV_Aperture = 400 $iH_Scroll = 1000 $iV_Scroll = 1000 ;*** END OF SCROLLBARS VARS #EndRegion ### VAR/CONST DECLARATION ### #Region ### START Koda GUI section ### Form=d:\users\azpr196\documents\konfigurator ds autoit\form12.kxf ;*********** LABELS ***************** $hGUI = GUICreate("Form1", 1399, 682, 113, 102, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX)) $aBet = _GUIScrollbars_Size(0, 550, 300, 300) GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL") _GUIScrollBars_Init($hGUI) _GUIScrollBars_ShowScrollBar($hGUI, $SB_VERT, True) _GUIScrollBars_ShowScrollBar($hGUI, $SB_HORZ, False) _GUIScrollBars_SetScrollInfoPage($hGUI, $SB_VERT, $aBet[2]) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_VERT, $aBet[3]) $Label1 = GUICtrlCreateLabel("Producent", 48, 88, 53, 17) $Label2 = GUICtrlCreateLabel("Model", 144, 88, 33, 17) $Label3 = GUICtrlCreateLabel("Grupa", 304, 88, 33, 17) $Label4 = GUICtrlCreateLabel("Ekstender", 712, 88, 52, 17) ;********** GENERAL OPTIONS ******** ;********** 1st MONITOR ************ $array2d_ControlID[1][$MANUFACTURER] = GUICtrlCreateCombo("", 48, 120, 81, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1,$manufacturer_list) $array2d_ControlID[1][$MODEL] = GUICtrlCreateCombo("", 144, 120, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) $array2d_ControlID[1][$GROUP] = GUICtrlCreateInput("1", 304, 120, 41, 21) $array2d_ControlID[1][$GROUP1] = GUICtrlCreateGroup("Połączenie sieciowe", 360, 104, 153, 57) $array2d_ControlID[1][$LAN] = GUICtrlCreateRadio("LAN", 368, 128, 41, 17) GUICtrlSetState(-1, $GUI_CHECKED) $array2d_ControlID[1][$GSM] = GUICtrlCreateRadio("GSM", 408, 128, 41, 17) $array2d_ControlID[1][$NONET] = GUICtrlCreateRadio("Brak", 456, 128, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $array2d_ControlID[1][$GROUP2] = GUICtrlCreateGroup("Odległosć do poprzedniego", 520, 104, 169, 57) $array2d_ControlID[1][$DISTANCE_S] = GUICtrlCreateRadio("< 20m", 528, 128, 49, 17) GUICtrlSetState(-1, $GUI_CHECKED) $array2d_ControlID[1][$DISTANCE_M] = GUICtrlCreateRadio("20-50m", 576, 128, 57, 17) $array2d_ControlID[1][$DISTANCE_L] = GUICtrlCreateRadio("> 50m", 632, 128, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $array2d_ControlID[1][$PLAYER] = GUICtrlCreateCombo("Player", 864, 120, 89, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1,$player_list) $array2d_ControlID[1][$EXTENDER] = GUICtrlCreateCombo("Extender", 704, 120, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetState(-1, $GUI_DISABLE) $array2d_ControlID[1][$LICENSE] = GUICtrlCreateCheckbox("Licencja", 968, 120, 65, 17) GUICtrlSetState(-1, $GUI_DISABLE) $array2d_ControlID[1][$ADD_MON] = GUICtrlCreateButton("Dodaj monitor", 1048, 104, 59, 57, $BS_BITMAP) GUICtrlSetImage(-1, "D:\Users\azpr196\Documents\Konfigurator DS autoit\image_add.bmp", -1) $array2d_ControlID[0][$ADD_MON]= $array2d_ControlID[1][$ADD_MON] GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### #Region ### INITIALIZE ### _GetNec() _GetSamsung() _GetLG() _GetIiyama() _GetPhilips() #EndRegion ### INITIALIZE ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_RESTORE _GUIScrollbars_Restore($hGUI, True, False) Case $array2d_ControlID[0][$ADD_MON] _AddMon() MsgBox(0,"","Monitors so far: "&$array2d_ControlID[0][0]) $aBet = _GUIScrollbars_Size(0, $_y_offset + $_y_base_offset, 300, 300) If IsArray($aBet) Then _ArrayDisplay($aBet) Else MsgBox(0,"","$aBet is NOT an array! Whats going on?!") EndIf _GUIScrollBars_SetScrollInfoPage($hGUI, $SB_VERT, $aBet[2]) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_VERT, $aBet[3]) Case $array2d_ControlID[0][$REM_MON] _RemMon() Case $array2d_ControlID[1][$MANUFACTURER] $manufact = GUICtrlRead($array2d_ControlID[1][$MANUFACTURER]) Select Case $manufact = "Samsung" GUICtrlSetData($array2d_ControlID[1][$MODEL],$samsung_list) Case $manufact = "NEC" GUICtrlSetData($array2d_ControlID[1][$MODEL],$nec_list) Case $manufact = "Iiyama" GUICtrlSetData($array2d_ControlID[1][$MODEL],$iiyama_list) Case $manufact = "LG" GUICtrlSetData($array2d_ControlID[1][$MODEL],$lg_list) Case $manufact = "Philips" GUICtrlSetData($array2d_ControlID[1][$MODEL],$philips_list) EndSelect EndSwitch WEnd Func _RefreshAll() MsgBox(0,"","Refresh function here...") EndFunc Func _AddMon() Local $i $array2d_ControlID[0][0] += 1 $i = $array2d_ControlID[0][0] ReDim $array2d_ControlID[UBound($array2d_ControlID)+1][UBound($array2d_ControlID,2)] $array2d_ControlID[$i][$MANUFACTURER] = GUICtrlCreateCombo("", 48, 120+$_y_offset, 81, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1,$manufacturer_list) $array2d_ControlID[$i][$MODEL] = GUICtrlCreateCombo("", 144, 120+$_y_offset, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) $array2d_ControlID[$i][$GROUP] = GUICtrlCreateInput("", 304, 120+$_y_offset, 41, 21) GUICtrlSetData(-1,GUICtrlRead($array2d_ControlID[$i-1][$GROUP])) $array2d_ControlID[$i][$GROUP1] = GUICtrlCreateGroup("Połączenie sieciowe", 360, 104+$_y_offset, 153, 57) $array2d_ControlID[$i][$LAN] = GUICtrlCreateRadio("LAN", 368, 128+$_y_offset, 41, 17) GUICtrlSetState(-1, $GUI_CHECKED) $array2d_ControlID[$i][$GSM] = GUICtrlCreateRadio("GSM", 408, 128+$_y_offset, 41, 17) $array2d_ControlID[$i][$NONET] = GUICtrlCreateRadio("Brak", 456, 128+$_y_offset, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $array2d_ControlID[$i][$GROUP2] = GUICtrlCreateGroup("Odległosć do poprzedniego", 520, 104+$_y_offset, 169, 57) $array2d_ControlID[$i][$DISTANCE_S] = GUICtrlCreateRadio("< 20m", 528, 128+$_y_offset, 49, 17) GUICtrlSetState(-1, $GUI_CHECKED) $array2d_ControlID[$i][$DISTANCE_M] = GUICtrlCreateRadio("20-50m", 576, 128+$_y_offset, 57, 17) $array2d_ControlID[$i][$DISTANCE_L] = GUICtrlCreateRadio("> 50m", 632, 128+$_y_offset, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $array2d_ControlID[$i][$PLAYER] = GUICtrlCreateCombo("Player", 864, 120+$_y_offset, 89, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1,$player_list) If GUICtrlRead($array2d_ControlID[$i-1][$PLAYER]) <> "" Then GUICtrlSetData(-1,GUICtrlRead($array2d_ControlID[$i-1][$PLAYER])) $array2d_ControlID[$i][$EXTENDER] = GUICtrlCreateCombo("Extender", 704, 120+$_y_offset, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetState(-1, $GUI_DISABLE) $array2d_ControlID[$i][$LICENSE] = GUICtrlCreateCheckbox("Licencja", 968, 120+$_y_offset, 65, 17) GUICtrlSetState(-1, $GUI_DISABLE) $array2d_ControlID[$i][$ADD_MON] = GUICtrlCreateButton("Dodaj monitor", 1048, 104+$_y_offset, 59, 57, $BS_BITMAP) GUICtrlSetImage(-1, "D:\Users\azpr196\Documents\Konfigurator DS autoit\image_add.bmp", -1) GUICtrlSetState($array2d_ControlID[$i-1][$ADD_MON],$GUI_HIDE) $array2d_ControlID[$i][$REM_MON] = GUICtrlCreateButton("Usuń monitor", 1148, 104+$_y_offset, 80, 57, $BS_BITMAP) GUICtrlSetState($array2d_ControlID[$i-1][$REM_MON],$GUI_HIDE) $array2d_ControlID[0][$ADD_MON] = $array2d_ControlID[$i][$ADD_MON] $array2d_ControlID[0][$REM_MON] = $array2d_ControlID[$i][$REM_MON] $_y_offset += $_y_base_offset EndFunc Func _RemMon() If $array2d_ControlID[0][0] > 1 Then Local $i, $aa=1, $ctrl $array2d_ControlID[0][0] -= 1 $i = $array2d_ControlID[0][0] + 1 For $aa=1 To (UBound($array2d_ControlID,2)-1) Step 1 $ctrl = $array2d_ControlID[$i][$aa] GUICtrlDelete($ctrl) Next $i -= 1 $array2d_ControlID[0][$ADD_MON] = $array2d_ControlID[$i][$ADD_MON] $array2d_ControlID[0][$REM_MON] = $array2d_ControlID[$i][$REM_MON] GUICtrlSetState($array2d_ControlID[$i][$ADD_MON],$GUI_SHOW) GUICtrlSetState($array2d_ControlID[$i][$REM_MON],$GUI_SHOW) $_y_offset -= $_y_base_offset ReDim $array2d_ControlID[UBound($array2d_ControlID)-1][UBound($array2d_ControlID,2)] EndIf EndFunc Func _GetPhilips() Global $philips_array = _ParseCSV("philips.csv",";","Cant read from philips.csv file!",True) ;get all SAMSUNG data into 2D array (0,0 and 0,1 holds number of columns/rows) If $philips_array = False Then Return 1 Global $philips_models_names[$philips_array[0][0]+1] $philips_models_names[0] = $philips_array[0][0] For $i = $philips_array[0][0] To 1 Step -1 ;For $j = $samsung_models[0][1] To 1 Step -1 $philips_models_names[$i] = $philips_array[$i][4] ;Next Next $philips_list = "|"&_ArrayToString($philips_models_names,"|",1) EndFunc Func _GetIiyama() Global $iiyama_array = _ParseCSV("yi.csv",";","Cant read from yi.csv file!",True) ;get all SAMSUNG data into 2D array (0,0 and 0,1 holds number of columns/rows) If $iiyama_array = False Then Return 1 Global $yi_models_names[$iiyama_array[0][0]+1] $yi_models_names[0] = $iiyama_array[0][0] For $i = $iiyama_array[0][0] To 1 Step -1 ;For $j = $samsung_models[0][1] To 1 Step -1 $yi_models_names[$i] = $iiyama_array[$i][4] ;Next Next $iiyama_list = "|"&_ArrayToString($yi_models_names,"|",1) EndFunc Func _GetLG() Global $lg_models = _ParseCSV("LG.csv",";","Cant read from LG.csv file!",True) ;get all SAMSUNG data into 2D array (0,0 and 0,1 holds number of columns/rows) Global $lg_models_names[$lg_models[0][0]+1] $lg_models_names[0] = $lg_models[0][0] For $i = $lg_models[0][0] To 1 Step -1 ;For $j = $samsung_models[0][1] To 1 Step -1 $lg_models_names[$i] = $lg_models[$i][4] ;Next Next $lg_list = "|"&_ArrayToString($lg_models_names,"|",1) EndFunc ;read Samsung data from CSV file Func _GetSamsung() Global $samsung_models = _ParseCSV("SAMSUNG.csv",";","Cant read from SAMSUNG.csv file!",True) ;get all SAMSUNG data into 2D array (0,0 and 0,1 holds number of columns/rows) ;_ArrayDisplay($samsung_models) Global $samsung_models_names[$samsung_models[0][0]+1] $samsung_models_names[0] = $samsung_models[0][0] For $i = $samsung_models[0][0] To 1 Step -1 ;For $j = $samsung_models[0][1] To 1 Step -1 $samsung_models_names[$i] = $samsung_models[$i][4] ;Next Next $samsung_list = "|"&_ArrayToString($samsung_models_names,"|",1) EndFunc ;read NEC data from CSV file Func _GetNec() Global $nec_models = _ParseCSV("NEC.csv",";","Cant read from NEC.csv file!",True) ;get all NEC data into 2D array (0,0 and 0,1 holds number of columns/rows) ;_ArrayDisplay($samsung_models) Global $nec_models_names[$nec_models[0][0]+1] $nec_models_names[0] = $nec_models[0][0] For $i = $nec_models[0][0] To 1 Step -1 ;For $j = $samsung_models[0][1] To 1 Step -1 $nec_models_names[$i] = $nec_models[$i][4] ;Next Next $nec_list = "|"&_ArrayToString($nec_models_names,"|",1) EndFunc ;****************** CSV to Array (2D) Func _ParseCSV($f,$Dchar,$error,$skip) Local $array[500][500] Local $line = "" $i = 0 $file = FileOpen($f,0) If $file = -1 Then MsgBox(0, "Error", $error) Return False EndIf ;skip 1st line If $skip Then $line = FileReadLine($file) While 1 $i = $i + 1 Local $line = FileReadLine($file) If @error = -1 Then ExitLoop $row_array = StringSplit($line,$Dchar) If $i == 1 Then $row_size = UBound($row_array) If $row_size <> UBound($row_array) Then MsgBox(0, "Error", "Row: " & $i & " has different size ") $row_size = UBound($row_array) $array = _arrayAdd_2d($array,$i,$row_array,$row_size) WEnd FileClose($file) $array[0][0] = $i-1 ;stores number of lines $array[0][1] = $row_size -1 ; stores number of data in a row (data corresponding to index 0 is the number of data in a row actually that's way the -1) Return $array EndFunc Func _arrayAdd_2d($array,$inwhich,$row_array,$row_size) For $i=1 To $row_size -1 Step 1 $array[$inwhich][$i] = $row_array[$i] Next Return $array EndFunc ;***************************************************** Func _Scroll_Move_Corr($hWnd) Local $aCorr[2] $aCorr[0] = _GUIScrollBars_GetScrollInfoPos($hWnd, $SB_HORZ) * Int($iH_Scroll / _GUIScrollBars_GetScrollInfoMax($hWnd, $SB_HORZ)) $aCorr[1] = _GUIScrollBars_GetScrollInfoPos($hWnd, $SB_VERT) * Int($iV_Scroll / _GUIScrollBars_GetScrollInfoMax($hWnd, $SB_VERT)) Return $aCorr EndFunc Func _Scrollbars_WM_VSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $yChar, $yPos Local $Min, $Max, $Page, $Pos, $TrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $yChar = $__g_aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO, "nMin") $Max = DllStructGetData($tSCROLLINFO, "nMax") $Page = DllStructGetData($tSCROLLINFO, "nPage") $yPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $yPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_TOP DllStructSetData($tSCROLLINFO, "nPos", $Min) Case $SB_BOTTOM DllStructSetData($tSCROLLINFO, "nPos", $Max) Case $SB_LINEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $yPos) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos)) $yPos = $Pos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_VSCROLL Func _Scrollbars_WM_HSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $xChar, $xPos Local $Page, $Pos, $TrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $xChar = $__g_aSB_WindowInfo[$iIndex][2] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $Page = DllStructGetData($tSCROLLINFO, "nPage") $xPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $xPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_LINELEFT DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINERIGHT DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGELEFT DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGERIGHT DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $xPos) Then _GUIScrollBars_ScrollWindow($hWnd, $xChar * ($xPos - $Pos), 0) Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_HSCROLL Any idea what i did wrong? Edited September 4, 2014 by misioooo
computergroove Posted September 4, 2014 Posted September 4, 2014 (edited) This is the document he is talking about. Download, unzip and put in the autoit include directory. http://www.autoitscript.com/forum/index.php?app=core&module=attach§ion=attach&attach_id=44827 Your code line 11 needs to look like #include <GUIScrollbars_Size.au3> I am getting a cannot open NEC.csv error. Can you include it here please? Edited September 4, 2014 by computergroove Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
Moderators Melba23 Posted September 4, 2014 Moderators Posted September 4, 2014 (edited) misioooo,Can I have a sample csv file, or at least the format you use, so I can at least run the script?M23Edit: Forget the above, I have it working with a dummy file. I will let you know when I have a solution. Edited September 4, 2014 by Melba23 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
Moderators Melba23 Posted September 4, 2014 Moderators Posted September 4, 2014 misioooo,That was quite a difficult problem. Scrollbars are very complicated beasts and I make no pretence of being an expert but I have a working solution for adding rows to your GUI when pressing the "Dodaj monitor" button - look for the <<<<<<< lines:expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiScrollBars.au3> #include <StructureConstants.au3> #include <ScrollBarConstants.au3> #include <Array.au3> #include "GUIScrollbars_Size.au3" Opt("GUIResizeMode", $GUI_DOCKALL) #Region ### VAR/CONST DECLARATION ### ; How to set increasing constants <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Enum $MANUFACTURER = 1, $MODEL, $GROUP1, $GROUP2, $LAN, $GSM, $NONET, $DISTANCE_S, $DISTANCE_M, $DISTANCE_L, $PLAYER, $EXTENDER, $LICENSE, $ADD_MON, $GROUP, $REM_MON Global $array2d_ControlID[2][17] = [[1]] ;because we start with 1 set of controls already created Local $_y_offset = 60 Local $_y_base_offset = 60 Global $player_list = "|Player 1|Player 2|Player 3|Player 4" Global $manufacturer_list = "|Samsung|LG|Iiyama|Philips|NEC" Global $samsung_list = "" Global $iiyama_list = "" Global $nec_list = "" Global $philips_list = "" Global $lg_list = "" Global $iPage, $iMax ;*** USED FOR SCROLLBARS $iH_Aperture = 400 $iV_Aperture = 400 $iH_Scroll = 1000 $iV_Scroll = 1000 ;*** END OF SCROLLBARS VARS #EndRegion ### VAR/CONST DECLARATION ### #Region ### START Koda GUI section ### Form=d:\users\azpr196\documents\konfigurator ds autoit\form12.kxf ;*********** LABELS ***************** $hGUI = GUICreate("Form1", 1399, 682, 113, 102, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX)) GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL") _GUIScrollBars_Init($hGUI) _GUIScrollBars_ShowScrollBar($hGUI, $SB_VERT, False) _GUIScrollBars_ShowScrollBar($hGUI, $SB_HORZ, False) $Label1 = GUICtrlCreateLabel("Producent", 48, 88, 53, 17) $Label2 = GUICtrlCreateLabel("Model", 144, 88, 33, 17) $Label3 = GUICtrlCreateLabel("Grupa", 304, 88, 33, 17) $Label4 = GUICtrlCreateLabel("Ekstender", 712, 88, 52, 17) ;********** GENERAL OPTIONS ******** ;********** 1st MONITOR ************ $array2d_ControlID[1][$MANUFACTURER] = GUICtrlCreateCombo("", 48, 120, 81, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, $manufacturer_list) $array2d_ControlID[1][$MODEL] = GUICtrlCreateCombo("", 144, 120, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) $array2d_ControlID[1][$GROUP] = GUICtrlCreateInput("1", 304, 120, 41, 21) $array2d_ControlID[1][$GROUP1] = GUICtrlCreateGroup("Polaczenie sieciowe", 360, 104, 153, 57) $array2d_ControlID[1][$LAN] = GUICtrlCreateRadio("LAN", 368, 128, 41, 17) GUICtrlSetState(-1, $GUI_CHECKED) $array2d_ControlID[1][$GSM] = GUICtrlCreateRadio("GSM", 408, 128, 41, 17) $array2d_ControlID[1][$NONET] = GUICtrlCreateRadio("Brak", 456, 128, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $array2d_ControlID[1][$GROUP2] = GUICtrlCreateGroup("Odleglosc do poprzedniego", 520, 104, 169, 57) $array2d_ControlID[1][$DISTANCE_S] = GUICtrlCreateRadio("< 20m", 528, 128, 49, 17) GUICtrlSetState(-1, $GUI_CHECKED) $array2d_ControlID[1][$DISTANCE_M] = GUICtrlCreateRadio("20-50m", 576, 128, 57, 17) $array2d_ControlID[1][$DISTANCE_L] = GUICtrlCreateRadio("> 50m", 632, 128, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $array2d_ControlID[1][$PLAYER] = GUICtrlCreateCombo("Player", 864, 120, 89, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, $player_list) $array2d_ControlID[1][$EXTENDER] = GUICtrlCreateCombo("Extender", 704, 120, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlSetState(-1, $GUI_DISABLE) $array2d_ControlID[1][$LICENSE] = GUICtrlCreateCheckbox("Licencja", 968, 120, 65, 17) GUICtrlSetState(-1, $GUI_DISABLE) $array2d_ControlID[1][$ADD_MON] = GUICtrlCreateButton("Dodaj monitor", 1048, 104, 59, 57, $BS_BITMAP) GUICtrlSetImage(-1, "D:\Users\azpr196\Documents\Konfigurator DS autoit\image_add.bmp", -1) $array2d_ControlID[0][$ADD_MON] = $array2d_ControlID[1][$ADD_MON] GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### #Region ### INITIALIZE ### ;_GetNec() ;_GetSamsung() ;_GetLG() ;_GetIiyama() ;_GetPhilips() #EndRegion ### INITIALIZE ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_RESTORE _GUIScrollbars_Restore($hGUI, True, False) Case $array2d_ControlID[0][$ADD_MON] ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ; Get current scroll position $iPos = _GUIScrollBars_GetScrollPos($hGUI, $SB_VERT) ; Scroll to top so coordinates are correct for creation of new line _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, 0) ; Create the new line _AddMon() ; If scrollbars are now needed If $_y_offset + ($_y_base_offset * 2) > 682 Then ; Show the bar _GUIScrollBars_ShowScrollBar($hGUI, $SB_VERT, True) ; Get the required data $aBet = _GUIScrollbars_Size(0, $_y_offset + ($_y_base_offset * 2), $hGUI) ; The function fails to return a Max value at times - I have no idea why <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< If $aBet[2] Then $iPage = $aBet[2] If $aBet[3] Then $iMax = $aBet[3] Else $iMax = $iPos + ($_y_base_offset * 2) EndIf ; Set the new data _GUIScrollBars_SetScrollInfoPage($hGUI, $SB_VERT, $iPage) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_VERT, $iMax) ; Scroll to new position _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, $_y_offset + ($_y_base_offset * 2)) EndIf Case $array2d_ControlID[0][$REM_MON] _RemMon() Case $array2d_ControlID[1][$MANUFACTURER] $manufact = GUICtrlRead($array2d_ControlID[1][$MANUFACTURER]) Select Case $manufact = "Samsung" GUICtrlSetData($array2d_ControlID[1][$MODEL], $samsung_list) Case $manufact = "NEC" GUICtrlSetData($array2d_ControlID[1][$MODEL], $nec_list) Case $manufact = "Iiyama" GUICtrlSetData($array2d_ControlID[1][$MODEL], $iiyama_list) Case $manufact = "LG" GUICtrlSetData($array2d_ControlID[1][$MODEL], $lg_list) Case $manufact = "Philips" GUICtrlSetData($array2d_ControlID[1][$MODEL], $philips_list) EndSelect EndSwitch WEnd Func _RefreshAll() MsgBox(0, "", "Refresh function here...") EndFunc ;==>_RefreshAll Func _AddMon() Static $iCount = 0 $iCount += 1 ConsoleWrite($iCount & @CRLF) Local $i $array2d_ControlID[0][0] += 1 $i = $array2d_ControlID[0][0] ReDim $array2d_ControlID[UBound($array2d_ControlID) + 1][UBound($array2d_ControlID, 2)] $array2d_ControlID[$i][$MANUFACTURER] = GUICtrlCreateCombo("", 48, 120 + $_y_offset, 81, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, $manufacturer_list) $array2d_ControlID[$i][$MODEL] = GUICtrlCreateCombo("", 144, 120 + $_y_offset, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) $array2d_ControlID[$i][$GROUP] = GUICtrlCreateInput("", 304, 120 + $_y_offset, 41, 21) GUICtrlSetData(-1, GUICtrlRead($array2d_ControlID[$i - 1][$GROUP])) $array2d_ControlID[$i][$GROUP1] = GUICtrlCreateGroup("Polaczenie sieciowe", 360, 104 + $_y_offset, 153, 57) $array2d_ControlID[$i][$LAN] = GUICtrlCreateRadio("LAN", 368, 128 + $_y_offset, 41, 17) GUICtrlSetState(-1, $GUI_CHECKED) $array2d_ControlID[$i][$GSM] = GUICtrlCreateRadio("GSM", 408, 128 + $_y_offset, 41, 17) $array2d_ControlID[$i][$NONET] = GUICtrlCreateRadio("Brak", 456, 128 + $_y_offset, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $array2d_ControlID[$i][$GROUP2] = GUICtrlCreateGroup("Odleglosc do poprzedniego", 520, 104 + $_y_offset, 169, 57) $array2d_ControlID[$i][$DISTANCE_S] = GUICtrlCreateRadio("< 20m", 528, 128 + $_y_offset, 49, 17) GUICtrlSetState(-1, $GUI_CHECKED) $array2d_ControlID[$i][$DISTANCE_M] = GUICtrlCreateRadio("20-50m", 576, 128 + $_y_offset, 57, 17) $array2d_ControlID[$i][$DISTANCE_L] = GUICtrlCreateRadio("> 50m", 632, 128 + $_y_offset, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $array2d_ControlID[$i][$PLAYER] = GUICtrlCreateCombo("Player", 864, 120 + $_y_offset, 89, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, $player_list) If GUICtrlRead($array2d_ControlID[$i - 1][$PLAYER]) <> "" Then GUICtrlSetData(-1, GUICtrlRead($array2d_ControlID[$i - 1][$PLAYER])) $array2d_ControlID[$i][$EXTENDER] = GUICtrlCreateCombo("Extender", 704, 120 + $_y_offset, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlSetState(-1, $GUI_DISABLE) $array2d_ControlID[$i][$LICENSE] = GUICtrlCreateCheckbox("Licencja", 968, 120 + $_y_offset, 65, 17) GUICtrlSetState(-1, $GUI_DISABLE) $array2d_ControlID[$i][$ADD_MON] = GUICtrlCreateButton("Dodaj monitor", 1048, 104 + $_y_offset, 59, 57, $BS_BITMAP) GUICtrlSetImage(-1, "D:\Users\azpr196\Documents\Konfigurator DS autoit\image_add.bmp", -1) GUICtrlSetState($array2d_ControlID[$i - 1][$ADD_MON], $GUI_HIDE) $array2d_ControlID[$i][$REM_MON] = GUICtrlCreateButton("Usun monitor", 1148, 104 + $_y_offset, 80, 57, $BS_BITMAP) GUICtrlSetState($array2d_ControlID[$i - 1][$REM_MON], $GUI_HIDE) $array2d_ControlID[0][$ADD_MON] = $array2d_ControlID[$i][$ADD_MON] $array2d_ControlID[0][$REM_MON] = $array2d_ControlID[$i][$REM_MON] $_y_offset += $_y_base_offset EndFunc ;==>_AddMon Func _RemMon() If $array2d_ControlID[0][0] > 1 Then Local $i, $aa = 1, $ctrl $array2d_ControlID[0][0] -= 1 $i = $array2d_ControlID[0][0] + 1 For $aa = 1 To (UBound($array2d_ControlID, 2) - 1) Step 1 $ctrl = $array2d_ControlID[$i][$aa] GUICtrlDelete($ctrl) Next $i -= 1 $array2d_ControlID[0][$ADD_MON] = $array2d_ControlID[$i][$ADD_MON] $array2d_ControlID[0][$REM_MON] = $array2d_ControlID[$i][$REM_MON] GUICtrlSetState($array2d_ControlID[$i][$ADD_MON], $GUI_SHOW) GUICtrlSetState($array2d_ControlID[$i][$REM_MON], $GUI_SHOW) $_y_offset -= $_y_base_offset ReDim $array2d_ControlID[UBound($array2d_ControlID) - 1][UBound($array2d_ControlID, 2)] EndIf EndFunc ;==>_RemMon Func _GetPhilips() Global $philips_array = _ParseCSV("philips.csv", ";", "Cant read from philips.csv file!", True) ;get all SAMSUNG data into 2D array (0,0 and 0,1 holds number of columns/rows) If $philips_array = False Then Return 1 Global $philips_models_names[$philips_array[0][0] + 1] $philips_models_names[0] = $philips_array[0][0] For $i = $philips_array[0][0] To 1 Step -1 ;For $j = $samsung_models[0][1] To 1 Step -1 $philips_models_names[$i] = $philips_array[$i][4] ;Next Next $philips_list = "|" & _ArrayToString($philips_models_names, "|", 1) EndFunc ;==>_GetPhilips Func _GetIiyama() Global $iiyama_array = _ParseCSV("yi.csv", ";", "Cant read from yi.csv file!", True) ;get all SAMSUNG data into 2D array (0,0 and 0,1 holds number of columns/rows) If $iiyama_array = False Then Return 1 Global $yi_models_names[$iiyama_array[0][0] + 1] $yi_models_names[0] = $iiyama_array[0][0] For $i = $iiyama_array[0][0] To 1 Step -1 ;For $j = $samsung_models[0][1] To 1 Step -1 $yi_models_names[$i] = $iiyama_array[$i][4] ;Next Next $iiyama_list = "|" & _ArrayToString($yi_models_names, "|", 1) EndFunc ;==>_GetIiyama Func _GetLG() Global $lg_models = _ParseCSV("LG.csv", ";", "Cant read from LG.csv file!", True) ;get all SAMSUNG data into 2D array (0,0 and 0,1 holds number of columns/rows) Global $lg_models_names[$lg_models[0][0] + 1] $lg_models_names[0] = $lg_models[0][0] For $i = $lg_models[0][0] To 1 Step -1 ;For $j = $samsung_models[0][1] To 1 Step -1 $lg_models_names[$i] = $lg_models[$i][4] ;Next Next $lg_list = "|" & _ArrayToString($lg_models_names, "|", 1) EndFunc ;==>_GetLG ;read Samsung data from CSV file Func _GetSamsung() Global $samsung_models = _ParseCSV("SAMSUNG.csv", ";", "Cant read from SAMSUNG.csv file!", True) ;get all SAMSUNG data into 2D array (0,0 and 0,1 holds number of columns/rows) ;_ArrayDisplay($samsung_models) Global $samsung_models_names[$samsung_models[0][0] + 1] $samsung_models_names[0] = $samsung_models[0][0] For $i = $samsung_models[0][0] To 1 Step -1 ;For $j = $samsung_models[0][1] To 1 Step -1 $samsung_models_names[$i] = $samsung_models[$i][4] ;Next Next $samsung_list = "|" & _ArrayToString($samsung_models_names, "|", 1) EndFunc ;==>_GetSamsung ;read NEC data from CSV file Func _GetNec() Global $nec_models = _ParseCSV("NEC.csv", ";", "Cant read from NEC.csv file!", True) ;get all NEC data into 2D array (0,0 and 0,1 holds number of columns/rows) ;_ArrayDisplay($samsung_models) Global $nec_models_names[$nec_models[0][0] + 1] $nec_models_names[0] = $nec_models[0][0] For $i = $nec_models[0][0] To 1 Step -1 ;For $j = $samsung_models[0][1] To 1 Step -1 $nec_models_names[$i] = $nec_models[$i][4] ;Next Next $nec_list = "|" & _ArrayToString($nec_models_names, "|", 1) EndFunc ;==>_GetNec ;****************** CSV to Array (2D) Func _ParseCSV($f, $Dchar, $error, $skip) Local $array[500][500] Local $line = "" $i = 0 $file = FileOpen($f, 0) If $file = -1 Then MsgBox(0, "Error", $error) Return False EndIf ;skip 1st line If $skip Then $line = FileReadLine($file) While 1 $i = $i + 1 Local $line = FileReadLine($file) If @error = -1 Then ExitLoop $row_array = StringSplit($line, $Dchar) If $i == 1 Then $row_size = UBound($row_array) If $row_size <> UBound($row_array) Then MsgBox(0, "Error", "Row: " & $i & " has different size ") $row_size = UBound($row_array) $array = _arrayAdd_2d($array, $i, $row_array, $row_size) WEnd FileClose($file) $array[0][0] = $i - 1 ;stores number of lines $array[0][1] = $row_size - 1 ; stores number of data in a row (data corresponding to index 0 is the number of data in a row actually that's way the -1) Return $array EndFunc ;==>_ParseCSV Func _arrayAdd_2d($array, $inwhich, $row_array, $row_size) For $i = 1 To $row_size - 1 Step 1 $array[$inwhich][$i] = $row_array[$i] Next Return $array EndFunc ;==>_arrayAdd_2d ;***************************************************** Func _Scroll_Move_Corr($hWnd) Local $aCorr[2] $aCorr[0] = _GUIScrollBars_GetScrollInfoPos($hWnd, $SB_HORZ) * Int($iH_Scroll / _GUIScrollBars_GetScrollInfoMax($hWnd, $SB_HORZ)) $aCorr[1] = _GUIScrollBars_GetScrollInfoPos($hWnd, $SB_VERT) * Int($iV_Scroll / _GUIScrollBars_GetScrollInfoMax($hWnd, $SB_VERT)) Return $aCorr EndFunc ;==>_Scroll_Move_Corr Func _Scrollbars_WM_VSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $yChar, $yPos Local $Min, $Max, $Page, $Pos, $TrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $yChar = $__g_aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO, "nMin") $Max = DllStructGetData($tSCROLLINFO, "nMax") $Page = DllStructGetData($tSCROLLINFO, "nPage") $yPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $yPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_TOP DllStructSetData($tSCROLLINFO, "nPos", $Min) Case $SB_BOTTOM DllStructSetData($tSCROLLINFO, "nPos", $Max) Case $SB_LINEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $yPos) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos)) $yPos = $Pos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_VSCROLL Func _Scrollbars_WM_HSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $xChar, $xPos Local $Page, $Pos, $TrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $xChar = $__g_aSB_WindowInfo[$iIndex][2] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $Page = DllStructGetData($tSCROLLINFO, "nPage") $xPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $xPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_LINELEFT DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINERIGHT DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGELEFT DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGERIGHT DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $xPos) Then _GUIScrollBars_ScrollWindow($hWnd, $xChar * ($xPos - $Pos), 0) Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_HSCROLLGive it a try and see how you get on. 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
misioooo Posted September 5, 2014 Author Posted September 5, 2014 Thank you. Enum is awesome Why didnt i knew about it earlier? As for scrollbars... When i reach end of window (gui is full) scrollbar appears, but i can not scroll. Whatever, i will think of different solution - maybe separate GUI windows for every group or something.
Moderators Melba23 Posted September 5, 2014 Moderators Posted September 5, 2014 (edited) misioooo,Do not give up so easily. I told you scrollbars are difficult beasts, so some patience is necessary to get what you want.Does this one work any better? Remember that I have only coded for the "Dodaj monitor" button:expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiScrollBars.au3> #include <StructureConstants.au3> #include <ScrollBarConstants.au3> #include <Array.au3> #include "GUIScrollbars_Size.au3" Opt("GUIResizeMode", $GUI_DOCKALL) #Region ### VAR/CONST DECLARATION ### ; How to set increasing constants <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Enum $MANUFACTURER = 1, $MODEL, $GROUP1, $GROUP2, $LAN, $GSM, $NONET, $DISTANCE_S, $DISTANCE_M, $DISTANCE_L, $PLAYER, $EXTENDER, $LICENSE, $ADD_MON, $GROUP, $REM_MON Global $array2d_ControlID[2][17] = [[1]] ;because we start with 1 set of controls already created Local $_y_offset = 60 Local $_y_base_offset = 60 Global $player_list = "|Player 1|Player 2|Player 3|Player 4" Global $manufacturer_list = "|Samsung|LG|Iiyama|Philips|NEC" Global $samsung_list = "" Global $iiyama_list = "" Global $nec_list = "" Global $philips_list = "" Global $lg_list = "" Global $iPage, $iMax ;*** USED FOR SCROLLBARS $iH_Aperture = 400 $iV_Aperture = 400 $iH_Scroll = 1000 $iV_Scroll = 1000 ;*** END OF SCROLLBARS VARS #EndRegion ### VAR/CONST DECLARATION ### #Region ### START Koda GUI section ### Form=d:\users\azpr196\documents\konfigurator ds autoit\form12.kxf ;*********** LABELS ***************** $hGUI = GUICreate("Form1", 1399, 682, 113, 102, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX)) GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL") _GUIScrollBars_Init($hGUI) _GUIScrollBars_ShowScrollBar($hGUI, $SB_VERT, False) _GUIScrollBars_ShowScrollBar($hGUI, $SB_HORZ, False) $Label1 = GUICtrlCreateLabel("Producent", 48, 88, 53, 17) $Label2 = GUICtrlCreateLabel("Model", 144, 88, 33, 17) $Label3 = GUICtrlCreateLabel("Grupa", 304, 88, 33, 17) $Label4 = GUICtrlCreateLabel("Ekstender", 712, 88, 52, 17) ;********** GENERAL OPTIONS ******** ;********** 1st MONITOR ************ $array2d_ControlID[1][$MANUFACTURER] = GUICtrlCreateCombo("", 48, 120, 81, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, $manufacturer_list) $array2d_ControlID[1][$MODEL] = GUICtrlCreateCombo("", 144, 120, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) $array2d_ControlID[1][$GROUP] = GUICtrlCreateInput("1", 304, 120, 41, 21) $array2d_ControlID[1][$GROUP1] = GUICtrlCreateGroup("Polaczenie sieciowe", 360, 104, 153, 57) $array2d_ControlID[1][$LAN] = GUICtrlCreateRadio("LAN", 368, 128, 41, 17) GUICtrlSetState(-1, $GUI_CHECKED) $array2d_ControlID[1][$GSM] = GUICtrlCreateRadio("GSM", 408, 128, 41, 17) $array2d_ControlID[1][$NONET] = GUICtrlCreateRadio("Brak", 456, 128, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $array2d_ControlID[1][$GROUP2] = GUICtrlCreateGroup("Odleglosc do poprzedniego", 520, 104, 169, 57) $array2d_ControlID[1][$DISTANCE_S] = GUICtrlCreateRadio("< 20m", 528, 128, 49, 17) GUICtrlSetState(-1, $GUI_CHECKED) $array2d_ControlID[1][$DISTANCE_M] = GUICtrlCreateRadio("20-50m", 576, 128, 57, 17) $array2d_ControlID[1][$DISTANCE_L] = GUICtrlCreateRadio("> 50m", 632, 128, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $array2d_ControlID[1][$PLAYER] = GUICtrlCreateCombo("Player", 864, 120, 89, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, $player_list) $array2d_ControlID[1][$EXTENDER] = GUICtrlCreateCombo("Extender", 704, 120, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlSetState(-1, $GUI_DISABLE) $array2d_ControlID[1][$LICENSE] = GUICtrlCreateCheckbox("Licencja", 968, 120, 65, 17) GUICtrlSetState(-1, $GUI_DISABLE) $array2d_ControlID[1][$ADD_MON] = GUICtrlCreateButton("Dodaj monitor", 1048, 104, 59, 57, $BS_BITMAP) GUICtrlSetImage(-1, "D:\Users\azpr196\Documents\Konfigurator DS autoit\image_add.bmp", -1) $array2d_ControlID[0][$ADD_MON] = $array2d_ControlID[1][$ADD_MON] GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### #Region ### INITIALIZE ### ;_GetNec() ;_GetSamsung() ;_GetLG() ;_GetIiyama() ;_GetPhilips() #EndRegion ### INITIALIZE ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_RESTORE _GUIScrollbars_Restore($hGUI, True, False) Case $array2d_ControlID[0][$ADD_MON] ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ; Get current scroll position $iPos = _GUIScrollBars_GetScrollPos($hGUI, $SB_VERT) ; Scroll to top so coordinates are correct for creation of new line _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, 0) ; Create the new line _AddMon() ; If scrollbars are now needed If $_y_offset + ($_y_base_offset * 2) > 682 Then ; Show the bar _GUIScrollBars_ShowScrollBar($hGUI, $SB_VERT, True) ; Get the required data $aBet = _GUIScrollbars_Size(0, $_y_offset + ($_y_base_offset * 2), $hGUI) ; The function fails to return a Max value at times - I have no idea why <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< If $aBet[2] Then $iPage = $aBet[2] If $aBet[3] Then $iMax = $aBet[3] ConsoleWrite("Func: ") Else $iMax = Int(($_y_offset + ($_y_base_offset * 2)) / 15) ConsoleWrite("Auto: ") EndIf ConsoleWrite($iMax & " - " & Int(($_y_offset + ($_y_base_offset * 2)) / 15) & @CRLF) ; Set the new data _GUIScrollBars_SetScrollInfoPage($hGUI, $SB_VERT, $iPage) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_VERT, $iMax) ; Scroll to new position _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, $iMax) EndIf Case $array2d_ControlID[0][$REM_MON] _RemMon() Case $array2d_ControlID[1][$MANUFACTURER] $manufact = GUICtrlRead($array2d_ControlID[1][$MANUFACTURER]) Select Case $manufact = "Samsung" GUICtrlSetData($array2d_ControlID[1][$MODEL], $samsung_list) Case $manufact = "NEC" GUICtrlSetData($array2d_ControlID[1][$MODEL], $nec_list) Case $manufact = "Iiyama" GUICtrlSetData($array2d_ControlID[1][$MODEL], $iiyama_list) Case $manufact = "LG" GUICtrlSetData($array2d_ControlID[1][$MODEL], $lg_list) Case $manufact = "Philips" GUICtrlSetData($array2d_ControlID[1][$MODEL], $philips_list) EndSelect EndSwitch WEnd Func _RefreshAll() MsgBox(0, "", "Refresh function here...") EndFunc ;==>_RefreshAll Func _AddMon() Static $iCount = 0 $iCount += 1 ConsoleWrite($iCount & @CRLF) Local $i $array2d_ControlID[0][0] += 1 $i = $array2d_ControlID[0][0] ReDim $array2d_ControlID[UBound($array2d_ControlID) + 1][UBound($array2d_ControlID, 2)] $array2d_ControlID[$i][$MANUFACTURER] = GUICtrlCreateCombo("", 48, 120 + $_y_offset, 81, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, $manufacturer_list) $array2d_ControlID[$i][$MODEL] = GUICtrlCreateCombo("", 144, 120 + $_y_offset, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) $array2d_ControlID[$i][$GROUP] = GUICtrlCreateInput("", 304, 120 + $_y_offset, 41, 21) GUICtrlSetData(-1, GUICtrlRead($array2d_ControlID[$i - 1][$GROUP])) $array2d_ControlID[$i][$GROUP1] = GUICtrlCreateGroup("Polaczenie sieciowe", 360, 104 + $_y_offset, 153, 57) $array2d_ControlID[$i][$LAN] = GUICtrlCreateRadio("LAN", 368, 128 + $_y_offset, 41, 17) GUICtrlSetState(-1, $GUI_CHECKED) $array2d_ControlID[$i][$GSM] = GUICtrlCreateRadio("GSM", 408, 128 + $_y_offset, 41, 17) $array2d_ControlID[$i][$NONET] = GUICtrlCreateRadio("Brak", 456, 128 + $_y_offset, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $array2d_ControlID[$i][$GROUP2] = GUICtrlCreateGroup("Odleglosc do poprzedniego", 520, 104 + $_y_offset, 169, 57) $array2d_ControlID[$i][$DISTANCE_S] = GUICtrlCreateRadio("< 20m", 528, 128 + $_y_offset, 49, 17) GUICtrlSetState(-1, $GUI_CHECKED) $array2d_ControlID[$i][$DISTANCE_M] = GUICtrlCreateRadio("20-50m", 576, 128 + $_y_offset, 57, 17) $array2d_ControlID[$i][$DISTANCE_L] = GUICtrlCreateRadio("> 50m", 632, 128 + $_y_offset, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $array2d_ControlID[$i][$PLAYER] = GUICtrlCreateCombo("Player", 864, 120 + $_y_offset, 89, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, $player_list) If GUICtrlRead($array2d_ControlID[$i - 1][$PLAYER]) <> "" Then GUICtrlSetData(-1, GUICtrlRead($array2d_ControlID[$i - 1][$PLAYER])) $array2d_ControlID[$i][$EXTENDER] = GUICtrlCreateCombo("Extender", 704, 120 + $_y_offset, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlSetState(-1, $GUI_DISABLE) $array2d_ControlID[$i][$LICENSE] = GUICtrlCreateCheckbox("Licencja", 968, 120 + $_y_offset, 65, 17) GUICtrlSetState(-1, $GUI_DISABLE) $array2d_ControlID[$i][$ADD_MON] = GUICtrlCreateButton("Dodaj monitor", 1048, 104 + $_y_offset, 59, 57, $BS_BITMAP) GUICtrlSetImage(-1, "D:\Users\azpr196\Documents\Konfigurator DS autoit\image_add.bmp", -1) GUICtrlSetState($array2d_ControlID[$i - 1][$ADD_MON], $GUI_HIDE) $array2d_ControlID[$i][$REM_MON] = GUICtrlCreateButton("Usun monitor", 1148, 104 + $_y_offset, 80, 57, $BS_BITMAP) GUICtrlSetState($array2d_ControlID[$i - 1][$REM_MON], $GUI_HIDE) $array2d_ControlID[0][$ADD_MON] = $array2d_ControlID[$i][$ADD_MON] $array2d_ControlID[0][$REM_MON] = $array2d_ControlID[$i][$REM_MON] $_y_offset += $_y_base_offset EndFunc ;==>_AddMon Func _RemMon() If $array2d_ControlID[0][0] > 1 Then Local $i, $aa = 1, $ctrl $array2d_ControlID[0][0] -= 1 $i = $array2d_ControlID[0][0] + 1 For $aa = 1 To (UBound($array2d_ControlID, 2) - 1) Step 1 $ctrl = $array2d_ControlID[$i][$aa] GUICtrlDelete($ctrl) Next $i -= 1 $array2d_ControlID[0][$ADD_MON] = $array2d_ControlID[$i][$ADD_MON] $array2d_ControlID[0][$REM_MON] = $array2d_ControlID[$i][$REM_MON] GUICtrlSetState($array2d_ControlID[$i][$ADD_MON], $GUI_SHOW) GUICtrlSetState($array2d_ControlID[$i][$REM_MON], $GUI_SHOW) $_y_offset -= $_y_base_offset ReDim $array2d_ControlID[UBound($array2d_ControlID) - 1][UBound($array2d_ControlID, 2)] EndIf EndFunc ;==>_RemMon Func _GetPhilips() Global $philips_array = _ParseCSV("philips.csv", ";", "Cant read from philips.csv file!", True) ;get all SAMSUNG data into 2D array (0,0 and 0,1 holds number of columns/rows) If $philips_array = False Then Return 1 Global $philips_models_names[$philips_array[0][0] + 1] $philips_models_names[0] = $philips_array[0][0] For $i = $philips_array[0][0] To 1 Step -1 ;For $j = $samsung_models[0][1] To 1 Step -1 $philips_models_names[$i] = $philips_array[$i][4] ;Next Next $philips_list = "|" & _ArrayToString($philips_models_names, "|", 1) EndFunc ;==>_GetPhilips Func _GetIiyama() Global $iiyama_array = _ParseCSV("yi.csv", ";", "Cant read from yi.csv file!", True) ;get all SAMSUNG data into 2D array (0,0 and 0,1 holds number of columns/rows) If $iiyama_array = False Then Return 1 Global $yi_models_names[$iiyama_array[0][0] + 1] $yi_models_names[0] = $iiyama_array[0][0] For $i = $iiyama_array[0][0] To 1 Step -1 ;For $j = $samsung_models[0][1] To 1 Step -1 $yi_models_names[$i] = $iiyama_array[$i][4] ;Next Next $iiyama_list = "|" & _ArrayToString($yi_models_names, "|", 1) EndFunc ;==>_GetIiyama Func _GetLG() Global $lg_models = _ParseCSV("LG.csv", ";", "Cant read from LG.csv file!", True) ;get all SAMSUNG data into 2D array (0,0 and 0,1 holds number of columns/rows) Global $lg_models_names[$lg_models[0][0] + 1] $lg_models_names[0] = $lg_models[0][0] For $i = $lg_models[0][0] To 1 Step -1 ;For $j = $samsung_models[0][1] To 1 Step -1 $lg_models_names[$i] = $lg_models[$i][4] ;Next Next $lg_list = "|" & _ArrayToString($lg_models_names, "|", 1) EndFunc ;==>_GetLG ;read Samsung data from CSV file Func _GetSamsung() Global $samsung_models = _ParseCSV("SAMSUNG.csv", ";", "Cant read from SAMSUNG.csv file!", True) ;get all SAMSUNG data into 2D array (0,0 and 0,1 holds number of columns/rows) ;_ArrayDisplay($samsung_models) Global $samsung_models_names[$samsung_models[0][0] + 1] $samsung_models_names[0] = $samsung_models[0][0] For $i = $samsung_models[0][0] To 1 Step -1 ;For $j = $samsung_models[0][1] To 1 Step -1 $samsung_models_names[$i] = $samsung_models[$i][4] ;Next Next $samsung_list = "|" & _ArrayToString($samsung_models_names, "|", 1) EndFunc ;==>_GetSamsung ;read NEC data from CSV file Func _GetNec() Global $nec_models = _ParseCSV("NEC.csv", ";", "Cant read from NEC.csv file!", True) ;get all NEC data into 2D array (0,0 and 0,1 holds number of columns/rows) ;_ArrayDisplay($samsung_models) Global $nec_models_names[$nec_models[0][0] + 1] $nec_models_names[0] = $nec_models[0][0] For $i = $nec_models[0][0] To 1 Step -1 ;For $j = $samsung_models[0][1] To 1 Step -1 $nec_models_names[$i] = $nec_models[$i][4] ;Next Next $nec_list = "|" & _ArrayToString($nec_models_names, "|", 1) EndFunc ;==>_GetNec ;****************** CSV to Array (2D) Func _ParseCSV($f, $Dchar, $error, $skip) Local $array[500][500] Local $line = "" $i = 0 $file = FileOpen($f, 0) If $file = -1 Then MsgBox(0, "Error", $error) Return False EndIf ;skip 1st line If $skip Then $line = FileReadLine($file) While 1 $i = $i + 1 Local $line = FileReadLine($file) If @error = -1 Then ExitLoop $row_array = StringSplit($line, $Dchar) If $i == 1 Then $row_size = UBound($row_array) If $row_size <> UBound($row_array) Then MsgBox(0, "Error", "Row: " & $i & " has different size ") $row_size = UBound($row_array) $array = _arrayAdd_2d($array, $i, $row_array, $row_size) WEnd FileClose($file) $array[0][0] = $i - 1 ;stores number of lines $array[0][1] = $row_size - 1 ; stores number of data in a row (data corresponding to index 0 is the number of data in a row actually that's way the -1) Return $array EndFunc ;==>_ParseCSV Func _arrayAdd_2d($array, $inwhich, $row_array, $row_size) For $i = 1 To $row_size - 1 Step 1 $array[$inwhich][$i] = $row_array[$i] Next Return $array EndFunc ;==>_arrayAdd_2d ;***************************************************** Func _Scroll_Move_Corr($hWnd) Local $aCorr[2] $aCorr[0] = _GUIScrollBars_GetScrollInfoPos($hWnd, $SB_HORZ) * Int($iH_Scroll / _GUIScrollBars_GetScrollInfoMax($hWnd, $SB_HORZ)) $aCorr[1] = _GUIScrollBars_GetScrollInfoPos($hWnd, $SB_VERT) * Int($iV_Scroll / _GUIScrollBars_GetScrollInfoMax($hWnd, $SB_VERT)) Return $aCorr EndFunc ;==>_Scroll_Move_Corr Func _Scrollbars_WM_VSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $yChar, $yPos Local $Min, $Max, $Page, $Pos, $TrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $yChar = $__g_aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO, "nMin") $Max = DllStructGetData($tSCROLLINFO, "nMax") $Page = DllStructGetData($tSCROLLINFO, "nPage") $yPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $yPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_TOP DllStructSetData($tSCROLLINFO, "nPos", $Min) Case $SB_BOTTOM DllStructSetData($tSCROLLINFO, "nPos", $Max) Case $SB_LINEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $yPos) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos)) $yPos = $Pos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_VSCROLL Func _Scrollbars_WM_HSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $xChar, $xPos Local $Page, $Pos, $TrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $xChar = $__g_aSB_WindowInfo[$iIndex][2] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $Page = DllStructGetData($tSCROLLINFO, "nPage") $xPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $xPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_LINELEFT DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINERIGHT DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGELEFT DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGERIGHT DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $xPos) Then _GUIScrollBars_ScrollWindow($hWnd, $xChar * ($xPos - $Pos), 0) Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_HSCROLLHow is that? M23 Edited September 5, 2014 by Melba23 Added code 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
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