Search the Community
Showing results for tags 'with a re-sizeable gui'.
-
hello world! i am trying to make a section of a gui scrollable to fit icons within the frame space allocated. the gui is resizable so if the icons don't fit then thats when the scrollbar should help, if the icons fit the scroll bar should disappear. i tried using Melba's UDF but have not been able to get it working. i would also like to make it scroll vertically only not horizontally. here is melba's udf and below is the working example script thanks in advance!! #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WINAPI.au3> #include <StaticConstants.au3> #include <array.au3> #include "GUIScrollbars_Ex.au3" Opt("GUIOnEventMode", 1) Global $buttons[1][3] $dGUI = GUICreate("test", 507, 440) $dashboard_frame = GUICtrlCreateLabel("", 4, 120, 500, 274, BitOR($SS_CENTER, $SS_RIGHT, $SS_BLACKRECT, $SS_GRAYRECT, $SS_WHITERECT, $SS_BLACKFRAME, $SS_SUNKEN, $WS_CLIPSIBLINGS)) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKTOP)) GUISetStyle(BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) GUICtrlCreateButton("Create", 10, 10, 50, 20) GUICtrlSetOnEvent(-1, "CreateBtns") GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKSIZE)) GUICtrlCreateButton("Delete", 70, 10, 50, 20) GUICtrlSetOnEvent(-1, "DeleteBtns") GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKSIZE)) GUISetState() GUISetOnEvent($GUI_EVENT_RESIZED, "Resize") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Resize") GUISetOnEvent($GUI_EVENT_RESTORE, "Resize") GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") While 1 Sleep(10) WEnd Func Resize() $window_position = WinGetPos($dGUI) If Not @error Then $window_x_position = $window_position[0] $window_y_position = $window_position[1] $window_width = $window_position[2] $window_height = $window_position[3] If $window_width < 507 And $window_height < 440 Then $window_width = 507 $window_height = 440 EndIf If $window_width < 507 Then $window_width = 507 EndIf If $window_height < 440 Then $window_height = 440 EndIf WinMove($dGUI, "", $window_x_position, $window_y_position, $window_width, $window_height) GUICtrlSetPos($dashboard_frame, 2, 120, $window_width - 12, $window_height - 200) CreateBtns() EndIf EndFunc ;==>Resize Func CreateBtns() DeleteBtns() $frame_position = ControlGetPos("", "", $dashboard_frame) $frame_x = $frame_position[0] $frame_y = $frame_position[1] $frame_width = $frame_position[2] $frame_height = $frame_position[3] $iconsdrawn = 50 ReDim $buttons[$iconsdrawn][3] $item_space = 65 $startX = $frame_x + 10 $startY = $frame_y + 10 $allocated_width = $frame_width - 30 $allocated_height = $frame_height - 20 $horizontal_items = Floor($allocated_width / $item_space) $vertical_rows = Ceiling($iconsdrawn / $horizontal_items) $item_Y = $startY $item_count = 0 For $p = 0 To $vertical_rows - 1 $item_x = $startX For $m = 0 To $horizontal_items - 1 If $item_count = $iconsdrawn Then ExitLoop $buttons[$item_count][0] = GUICtrlCreateCheckbox("", $item_x + 6, $item_Y + 13, 13, 13);$startX + $ButHor * $horPitch, $StartY + $ButVert * $VertPItch + 6, 13, 13) $buttons[$item_count][1] = GUICtrlCreateButton("", $item_x + 26, $item_Y + 6, 30, 30);$startX + $ButHor * $horPitch + 20, $StartY + $ButVert * $VertPItch, $ButWid, $ButHeight, $BS_ICON) $buttons[$item_count][2] = GUICtrlCreateLabel($item_count+1, $item_x + 5, $item_Y + 40, 60, 15);$startX + $ButHor * $horPitch - 10, $StartY + $ButVert * $VertPItch + $ButHeight + 6) $item_x += $item_space $item_count += 1 Next $item_Y += $item_space Next _GUIScrollbars_Generate($dGUI, $frame_width, $frame_height) EndFunc ;==>CreateBtns Func DeleteBtns() For $m = 0 To UBound($buttons)-1 GUICtrlDelete($buttons[$m][0]) GUICtrlDelete($buttons[$m][1]) GUICtrlDelete($buttons[$m][2]) Next EndFunc ;==>deletebtns Func _Exit() Exit EndFunc ;==>_Exit