Qwerty212 Posted October 12, 2015 Share Posted October 12, 2015 (edited) Hello again.I'm trying to set the width of scrollbars in a gui to make them wider (so it can be easier to work with touch screens to scroll up and down).As Melba has pointed in his scrollbars udf's thread, I've been looking for info to change the width of the scrollbars using the _WinAPI_SystemParametersInfo function, but I've reached a point where I'm able to change some nonclientarea parameters and not the desired one This is an example script:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <WinAPI.au3> #include <WinAPIsysinfoConstants.au3> #include <WindowsConstants.au3> #include "GUIScrollbars_Size.au3" Global $scrollBarDimension = 260 ;Based on an example on the forum: $nonclientmetrics = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") DLLStructSetData($nonclientmetrics,1,DllStructGetSize($nonclientmetrics)) ;initialize values to not reset all others ! $a = DLLCall("user32.dll","int","SystemParametersInfo","int",$SPI_GETNONCLIENTMETRICS, _ "int",DllStructGetSize($nonclientmetrics), _ "ptr",DllStructGetPtr($nonclientmetrics),"int",0) DllStructSetData($nonclientmetrics, $SM_CYSIZE, 15);This works, it changes the buttons size in the top of the windows DllStructSetData($nonclientmetrics, $SM_CXVSCROLL, 15); This doesn't works, I can not change the width of the scrollbars :( $a = DLLCall("user32.dll","int","SystemParametersInfo","int",$SPI_SETNONCLIENTMETRICS, _ "int",DllStructGetSize($nonclientmetrics), _ "ptr",DllStructGetPtr($nonclientmetrics),"int", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE));I don't know if this last BitOR will make the changes permanent ; Create and show the GUI $mainGUI = GUICreate("TEST", 300, 250) GUISetState(@SW_SHOW) ; Set scrollbars size $aRet = _GUIScrollbars_Size(0, $scrollBarDimension, 300, 250) ; Create the scrollbars _GUIScrollBars_Init($mainGUI) _GUIScrollBars_ShowScrollBar($mainGUI, $SB_VERT, True) _GUIScrollBars_ShowScrollBar($mainGUI, $SB_HORZ, False);I don't need the horizontal scrollbar _GUIScrollBars_SetScrollInfoPage($mainGUI, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($mainGUI, $SB_VERT, $aRet[3]) ConsoleWrite("Scrollbars width: " & _WinAPI_GetSystemMetrics($SM_CXVSCROLL)) ;I see that the scrollbar has not a bigger witdh, but this shows me that $SMCXVSCROLL value is ok) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEndAny help would be trully aprecciatted. Edited October 12, 2015 by Qwerty212 Link to comment Share on other sites More sharing options...
LarsJ Posted October 12, 2015 Share Posted October 12, 2015 Do you use DllStructSetData correctly? As far as I remember the second parameter is the 1-based index of the element in the structure ($nonclientmetrics). Are you sure that this index matches $SM_CXVSCROLL? Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Qwerty212 Posted October 12, 2015 Author Share Posted October 12, 2015 Do you use DllStructSetData correctly? As far as I remember the second parameter is the 1-based index of the element in the structure ($nonclientmetrics). Are you sure that this index matches $SM_CXVSCROLL?I literally don't have any idea about if the DllStructSetData was right. I copied it from an example in the forum. Link to comment Share on other sites More sharing options...
LarsJ Posted October 12, 2015 Share Posted October 12, 2015 I'll try to find time to look at it tomorrow. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
LarsJ Posted October 13, 2015 Share Posted October 13, 2015 The example reads the current width of the vertical scrollbar, increases the width with 5 pixels, and restores the original width. It seems like the height of the horizontal scroll bar is changed accordingly. I have not investigated this in detail.expandcollapse popup#include <WinAPI.au3> #include <WinAPIsysinfoConstants.au3> Global Const $tagNONCLIENTMETRICS = "uint cbSize;" & _ "int iBorderWidth;" & _ "int iScrollWidth;" & _ "int iScrollHeight;" & _ "int iCaptionWidth;" & _ "int iCaptionHeight;" & _ "byte lfCaptionFont[92];" & _ "int iSmCaptionWidth;" & _ "int iSmCaptionHeight;" & _ "byte lfSmCaptionFont[92];" & _ "int iMenuWidth;" & _ "int iMenuHeight;" & _ "byte lfMenuFont[92];" & _ "byte lfStatusFont[92];" & _ "byte lfMessageFont[92]" ;"int iPaddedBorderWidth" Global Const $tagLOGFONTW = "STRUCT;" & _ "int Height;" & _ "int Width;" & _ "int Escapement;" & _ "int Orientation;" & _ "int Weight;" & _ "byte Italic;" & _ "byte Underline;" & _ "byte Strikeout;" & _ "byte CharSet;" & _ "byte OutPrecision;" & _ "byte ClipPrecision;" & _ "byte Quality;" & _ "byte PitchAndFamily;" & _ "wchar FaceName[32];" & _ "ENDSTRUCT" Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Fill NONCLIENTMETRICS structure with current values Local $tNONCLIENTMETRICS = DllStructCreate( $tagNONCLIENTMETRICS ) DllStructSetData( $tNONCLIENTMETRICS, "cbSize", DllStructGetSize( $tNONCLIENTMETRICS ) ) _WinAPI_SystemParametersInfo( $SPI_GETNONCLIENTMETRICS, DllStructGetSize( $tNONCLIENTMETRICS ), DllStructGetPtr( $tNONCLIENTMETRICS ) ) ; Get the width of the vertical scroll bar Local $iScrollWidth = DllStructGetData( $tNONCLIENTMETRICS, "iScrollWidth" ) ConsoleWrite( "iScrollWidth = " & $iScrollWidth & @CRLF ) MsgBox( 0, "Width of vertical scroll bar", "$iScrollWidth = " & $iScrollWidth ) ;Local $lfCaptionFont = DllStructCreate( $tagLOGFONTW, DllStructGetPtr( $tNONCLIENTMETRICS, "lfCaptionFont" )) ; Increase width of scroll bar with 5 pixels DllStructSetData( $tNONCLIENTMETRICS, "iScrollWidth", $iScrollWidth + 5 ) _WinAPI_SystemParametersInfo( $SPI_SETNONCLIENTMETRICS, DllStructGetSize( $tNONCLIENTMETRICS ), DllStructGetPtr( $tNONCLIENTMETRICS ), $SPIF_SENDCHANGE ) ; Get new width of vertical scroll bar _WinAPI_SystemParametersInfo( $SPI_GETNONCLIENTMETRICS, DllStructGetSize( $tNONCLIENTMETRICS ), DllStructGetPtr( $tNONCLIENTMETRICS ) ) Local $iScrollWidthNew = DllStructGetData( $tNONCLIENTMETRICS, "iScrollWidth" ) ConsoleWrite( "iScrollWidthNew = " & $iScrollWidthNew & @CRLF ) MsgBox( 0, "New width of vertical scroll bar", "$iScrollWidthNew = $iScrollWidth + 5 = " & $iScrollWidthNew & _ @CRLF & @CRLF & "You can verify the width in a window with a scroll bar" ) ; Restore original width of scroll bar DllStructSetData( $tNONCLIENTMETRICS, "iScrollWidth", $iScrollWidth ) _WinAPI_SystemParametersInfo( $SPI_SETNONCLIENTMETRICS, DllStructGetSize( $tNONCLIENTMETRICS ), DllStructGetPtr( $tNONCLIENTMETRICS ), $SPIF_SENDCHANGE ) ; Get original width of scroll bar _WinAPI_SystemParametersInfo( $SPI_GETNONCLIENTMETRICS, DllStructGetSize( $tNONCLIENTMETRICS ), DllStructGetPtr( $tNONCLIENTMETRICS ) ) $iScrollWidth = DllStructGetData( $tNONCLIENTMETRICS, "iScrollWidth" ) ConsoleWrite( "iScrollWidth = " & $iScrollWidth & @CRLF ) MsgBox( 0, "Original width of scroll bar", "$iScrollWidth = " & $iScrollWidth ) EndFunc Professor_Bernd 1 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Qwerty212 Posted October 13, 2015 Author Share Posted October 13, 2015 Amazing!! Thanks a lot! Definitely this is something that I was never going to reach by my self Greets from Barcelona 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