Jump to content

How to show all buttons in gui without empty space at bottom of gui?


Recommended Posts

How to show all auto generated buttons in gui, but without empty space?
 To look like this at bottom:

SnapCrab_No-0000.png

instead of this:

SnapCrab_No-0001.png

; www.autoitscript.com/forum/topic/79684-scroll-udf-much-easier-than-the-_guiscrollbars-udf/#comment-710515
; www.autoitscript.com/autoit3/docs/libfunctions/_GUIScrollBars_SetScrollInfo.htm

#NoTrayIcon
#RequireAdmin
#include <Constants.au3>
#include <GUIConstants.au3>
#include <GuiScrollBars.au3>
#include <SendMessage.au3>
#include <WinAPI.au3>
#include <Array.au3>

Opt("WinWaitDelay", 0)
Opt("MouseClickDelay", 0)
Opt("MouseClickDownDelay", 0)
Opt("MouseClickDragDelay", 0)
Opt("SendKeyDelay", 0)
Opt("SendKeyDownDelay", 0)
Opt("WinTitleMatchMode", 3)
Opt("GUIOnEventMode", 1)

Global $ButtonWidth = 110
Global $ButtonHeight = 50
Global $GuiWidth, $GuiHeight
Global $AllButtons[310][3] = [[309]]

$GuiWidth = ($ButtonWidth-1)*5+1
$GuiHeight = (Int($AllButtons[0][0]/5)+1)*$ButtonHeight
$UseScrollbar = 'no'
If $GuiHeight > 400 Then
   $UseScrollbar = 'yes'
   $GuiHeight = 8*($ButtonHeight-1)+1
   $GuiWidth = ($ButtonWidth-1)*5+1+_WinAPI_GetSystemMetrics($SM_CXVSCROLL)-1
EndIf
Global $hGUI = GUICreate("", $GuiWidth, $GuiHeight, -1, -1)
If $UseScrollbar = 'yes' Then
   _GUIScrollBars_Init($hGUI, 0)
   _GUIScrollBars_EnableScrollBar($hGUI, $SB_VERT, $ESB_ENABLE_BOTH)
   $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hGUI, $SB_VERT)
   DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE))
   DllStructSetData($tSCROLLINFO, "nMin", 0)
   DllStructSetData($tSCROLLINFO, "nMax", 378/2)
   DllStructSetData($tSCROLLINFO, "nPage", 1.0)
   _GUIScrollBars_SetScrollInfo($hGUI, $SB_VERT, $tSCROLLINFO)
   GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")
   GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL")
 EndIf
GUISetOnEvent($GUI_EVENT_CLOSE, '_AllExit')
For $i = 1 to $AllButtons[0][0]
   $quotient = Int(($i-1)/5)
   $remainder = Mod($i-1, 5)
   $AllButtons[$i][2] = GUICtrlCreateButton($AllButtons[$i][0], ($ButtonWidth-1)*$remainder, ($ButtonHeight-1)*$quotient, $ButtonWidth, $ButtonHeight, BitOR($SS_CENTER, $BS_MULTILINE))
   GUICtrlSetOnEvent($AllButtons[$i][2], '_Launcher')
Next
GUISetState(@SW_SHOW, $hGUI)

While 1
   Sleep(1000)
WEnd

Func _AllExit()
   GUIDelete($hGUI)
   Exit
EndFunc

Func _Launcher()
   $text = GUICtrlRead(@GUI_CtrlId)
EndFunc

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

   Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)
   $iMin = DllStructGetData($tSCROLLINFO, "nMin")
   $iMax = DllStructGetData($tSCROLLINFO, "nMax")
   $iPage = DllStructGetData($tSCROLLINFO, "nPage")
   $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

   DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
   _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
   _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
   $iPos = DllStructGetData($tSCROLLINFO, "nPos")
   If ($iPos <> $iPosY) Then
      _GUIScrollBars_ScrollWindow($hWnd, 0, $iCharY * ($iPosY - $iPos))
      $iPosY = $iPos
   EndIf
   Return $GUI_RUNDEFMSG
EndFunc

Func WM_MOUSEWHEEL($hWnd, $iMsg, $iwParam, $ilParam)
   #forceref $hwnd, $iMsg, $ilParam
   If BitShift($iwParam, 16) > 0 Then
      _SendMessage($hGUI, $WM_VSCROLL, $SB_LINEUP)
   Else
      _SendMessage($hGUI, $WM_VSCROLL, $SB_LINEDOWN)
   EndIf
   Return $GUI_RUNDEFMSG
EndFunc

 

Edited by Nikolas92
Link to comment
Share on other sites

  • Moderators

Nikolas92,

Look at my Scrollbars UDF (the link is in my sig). You need to calculate the size of the buttons and then use that value to create the scrollbars.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

Nikolas92,

The UDF merely uses the standard Windows scrollbars with very similar message handlers to the ones you were using above. If you post your code where you have tried to integrate my UDF I could try and run in on my Win10 machine to see if I can spot the problem.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...