storme Posted May 5, 2009 Share Posted May 5, 2009 (edited) G'day AllIs there anyway to set up a scrollable area of a window.I'd like be able to setup an area that will act as a window to a larger area of controls.Like a "listbox" but be able to put anything I choose (controls) into it.I've looked around and there are a few scroll programs but the ones I've tried scroll the whole window. Like I'm currently using in GUI Control Array Grid I'd like to be able to place this in a normal form with other controls around it and only have the "GUI Control Array Grid" scroll.Is this possible?Thanks for any and all helpJohn Morrison Edited May 5, 2009 by storme Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E Link to comment Share on other sites More sharing options...
Authenticity Posted May 5, 2009 Share Posted May 5, 2009 expandcollapse popup#include <GuiScrollBars.au3> #include <ScrollBarConstants.au3> #include <WindowsConstants.au3> Const $LINESTEP = 10 Const $PAGESTEP = 25 Dim $iPos = 0 GUIRegisterMsg($WM_VSCROLL, 'OnVertScroll') Dim $hGUI = GUICreate('Test', 100, 200) Dim $avButton[100] For $i = 0 To 99 $avButton[$i] = GUICtrlCreateButton('Button ' & $i+1, 20, 20+$i*30, 60, 25) Next Dim $hVScroll = _GUIScrollBars_Init($hGUI, 200) _GUIScrollBars_SetScrollRange($hGUI, $SB_VERT, 0, 200) _GUIScrollBars_ShowScrollBar($hGUI, $SB_HORZ, False) GUISetState() Do Until GUIGetMsg() = -3 GUIDelete() Func OnVertScroll($hwnd, $iMsg, $iwParam, $ilParam) Local $iScrollCode = BitAND($iwParam, 0xFFFF) Switch $iScrollCode Case $SB_LINEDOWN $iPos += $LINESTEP Case $SB_LINEUP $iPos -= $LINESTEP Case $SB_PAGEDOWN $iPos += $PAGESTEP Case $SB_PAGEUP $iPos -= $PAGESTEP EndSwitch If $iPos > 200 Then $iPos = 200 ElseIf $iPos < 0 Then $iPos = 0 EndIf _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, $iPos) EndFunc Link to comment Share on other sites More sharing options...
storme Posted May 5, 2009 Author Share Posted May 5, 2009 G'day Authenticity Thanks for the code but sadly it doesn't do what I wanted. I want to scroll an "area" inside the main window. Not the whole window. To make it clearer... this text area I'm typing into is what I'd like to be able to achieve, except I want to put controls (buttons, etc) on the scolling area not just text. Using the "GUI Control Array Grid" I'd like to be able to place buttons above and below the area to "do things" but only scroll the "GUI Control Array Grid" area of the window. Thanks again! John Morrison Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E Link to comment Share on other sites More sharing options...
martin Posted May 5, 2009 Share Posted May 5, 2009 (edited) G'day AuthenticityThanks for the code but sadly it doesn't do what I wanted.I want to scroll an "area" inside the main window. Not the whole window.To make it clearer... this text area I'm typing into is what I'd like to be able to achieve, except I want to put controls (buttons, etc) on the scolling area not just text.Using the "GUI Control Array Grid" I'd like to be able to place buttons above and below the area to "do things" but only scroll the "GUI Control Array Grid" area of the window.Thanks again!John MorrisonIf you want to scroll an area inside the main window then you have to create a child window, put all the components that have to be scrolled in that window and add the scroll bars to the child window. I did something similar here.Edit, come to think of it, doesn't the example for _Scrollbarts_init do that? Edited May 5, 2009 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
storme Posted May 5, 2009 Author Share Posted May 5, 2009 Hi (again) Martin I did have a look through your code but with 1700 lines it was a bit big to digest in one go. I was hoping there was a simpler example to start with. As I siad earlier GUIs' and I don't see eye to eye. But I've got a bit of momentum up at the moment with "GUI Control Array Grid" and it's a control that I need for several other projects I have in mind. I know if I loose momentum it maybe ages before I get back to it....sigh! I've looked up "_Scrollbars_init"...sigh...Yes it does have it in the example...I wish I'd seen it before now. AutoIT never ceases to amaze me...there isn't much it can't do. That code should give me everything I need (at least untill I get messed up again). What I want to produce is a "control/window" that I can "place" on "main window" with the my scrolling list of controls. What you've given me should allow me to do that. (I HOPE!! ) Thanks again Martin John Morrison Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E Link to comment Share on other sites More sharing options...
martin Posted May 5, 2009 Share Posted May 5, 2009 Hi (again) Martin I did have a look through your code but with 1700 lines it was a bit big to digest in one go. I was hoping there was a simpler example to start with. As I siad earlier GUIs' and I don't see eye to eye. But I've got a bit of momentum up at the moment with "GUI Control Array Grid" and it's a control that I need for several other projects I have in mind. I know if I loose momentum it maybe ages before I get back to it....sigh! I've looked up "_Scrollbars_init"...sigh...Yes it does have it in the example...I wish I'd seen it before now. AutoIT never ceases to amaze me...there isn't much it can't do. That code should give me everything I need (at least untill I get messed up again). What I want to produce is a "control/window" that I can "place" on "main window" with the my scrolling list of controls. What you've given me should allow me to do that. (I HOPE!! ) Thanks again Martin John MorrisonGood luck. It's actually quite easy once you've done it, like many things. Here is Authenticity's code with a parent to hold the gui with the scroll bar expandcollapse popup#include <GuiScrollBars.au3> #include <ScrollBarConstants.au3> #include <WindowsConstants.au3> Const $LINESTEP = 10 Const $PAGESTEP = 25 Dim $iPos = 0 GUIRegisterMsg($WM_VSCROLL, 'OnVertScroll') $hContainer = GUICreate("container",200,300,200,200);Make a window to hoild the window to be scrolled GUISetState();show it Dim $hGUI = GUICreate('Test', 100, 200,10,80,$WS_CHILD,-1,$hContainer);make the scrolled window as a child of $hContainer ;everything else stays the same Dim $avButton[100] For $i = 0 To 99 $avButton[$i] = GUICtrlCreateButton('Button ' & $i+1, 20, 20+$i*30, 60, 25) Next Dim $hVScroll = _GUIScrollBars_Init($hGUI, 200) _GUIScrollBars_SetScrollRange($hGUI, $SB_VERT, 0, 200) _GUIScrollBars_ShowScrollBar($hGUI, $SB_HORZ, False) GUISetState() Do Until GUIGetMsg() = -3 GUIDelete() Func OnVertScroll($hwnd, $iMsg, $iwParam, $ilParam) Local $iScrollCode = BitAND($iwParam, 0xFFFF) Switch $iScrollCode Case $SB_LINEDOWN $iPos += $LINESTEP Case $SB_LINEUP $iPos -= $LINESTEP Case $SB_PAGEDOWN $iPos += $PAGESTEP Case $SB_PAGEUP $iPos -= $PAGESTEP EndSwitch If $iPos > 200 Then $iPos = 200 ElseIf $iPos < 0 Then $iPos = 0 EndIf _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, $iPos) EndFunc Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
qwert Posted July 13, 2009 Share Posted July 13, 2009 I noticed the very good example in the previous post and am wondering if someone might be able to modify it to show how to scroll a PNG in the same child window (instead of the 100 buttons). I've tried replacing the button creation with the following, but got nothing but a scrollable blank area: $pngSrc = @WorkingDir & "\image.png" _GDIPlus_Startup() $hSplashImage = _GDIPlus_ImageLoadFromFile($pngSrc) $width = _GDIPlus_ImageGetWidth($hSplashImage) $height = _GDIPlus_ImageGetHeight($hSplashImage) SetBitmap($hGUI, $hSplashImage, 0) GUISetState()Thanks in advance for any help. Link to comment Share on other sites More sharing options...
Authenticity Posted July 14, 2009 Share Posted July 14, 2009 expandcollapse popup#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <GUIScrollBars.au3> #include <Icons.au3> #include <ScrollBarConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Dim $hGUI, $hChildGUI, $Pic Dim $hImage, $hBitMap Dim $hScroll, $tSCROLLINFO Dim $iWidth, $iHeight, $sSrc Dim $iLineH, $iPageH, $iLineV, $iPageV Dim $tSCROLLINFO _GDIPlus_Startup() GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL") GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL") $sSrc = @ScriptDir & '\image.png' $hImage = _GDIPlus_BitmapCreateFromFile($sSrc) $iWidth = _GDIPlus_ImageGetWidth($hImage) $iHeight = _GDIPlus_ImageGetHeight($hImage) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $iLineH = Int($iWidth/20) $iPageH = Int($iWidth/10) $iLineV = Int($iHeight/20) $iPageV = Int($iHeight/10) _GDIPlus_ImageDispose($hImage) $hGUI = GUICreate('', 300, 200, -1, -1, $WS_OVERLAPPEDWINDOW) $hChildGUI = GUICreate('', 300, 200, 0, 0, $WS_CHILD, -1, $hGUI) GUISetBkColor(0xE1FFC4) $Pic = GUICtrlCreatePic('', 0, 0, $iWidth, $iHeight) _SetHImage($Pic, $hBitMap) GUICtrlSetResizing($Pic, $GUI_DOCKALL) _GUIScrollBars_Init($hChildGUI) _GUIScrollBars_SetScrollInfoMax($hChildGUI, $SB_HORZ, $iWidth-300+55) _GUIScrollBars_SetScrollInfoMax($hChildGUI, $SB_VERT, $iHeight-200+25) GUISetState() GUISwitch($hGUI) GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete($hChildGUI) GUIDelete($hGUI) _WinAPI_DeleteObject($hBitMap) _GDIPlus_Shutdown() Exit Func WM_HSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $index = -1, $xChar, $xPos Local $Min, $Max, $Page, $Pos, $TrackPos For $x = 0 To UBound($aSB_WindowInfo) - 1 If $aSB_WindowInfo[$x][0] = $hWnd Then $index = $x $xChar = $aSB_WindowInfo[$index][2] ExitLoop EndIf Next If $index = -1 Then Return 0 ;~ ; Get all the horizontal scroll bar information Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $Min = DllStructGetData($tSCROLLINFO, "nMin") $Max = DllStructGetData($tSCROLLINFO, "nMax") ; Save the position for comparison later on $xPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $xPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") #forceref $Min, $Max Switch $nScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO, "nPos", $Pos - $iLineH) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO, "nPos", $Pos + $iLineH) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $Pos - $iPageH) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $Pos + $iPageH) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) 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 $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $xPos) Then _GUIScrollBars_ScrollWindow($hWnd, $xPos - $Pos, 0) Return $GUI_RUNDEFMSG EndFunc ;==>WM_HSCROLL Func WM_VSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $index = -1, $yChar, $yPos Local $Min, $Max, $Pos, $TrackPos For $x = 0 To UBound($aSB_WindowInfo) - 1 If $aSB_WindowInfo[$x][0] = $hWnd Then $index = $x $yChar = $aSB_WindowInfo[$index][3] ExitLoop EndIf Next If $index = -1 Then Return 0 ; Get all the vertial scroll bar information Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO, "nMin") $Max = DllStructGetData($tSCROLLINFO, "nMax") ; Save the position for comparison later on $yPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $yPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_TOP ; user clicked the HOME keyboard key DllStructSetData($tSCROLLINFO, "nPos", $Min) Case $SB_BOTTOM ; user clicked the END keyboard key DllStructSetData($tSCROLLINFO, "nPos", $Max) Case $SB_LINEUP ; user clicked the top arrow DllStructSetData($tSCROLLINFO, "nPos", $Pos - $iLineV) Case $SB_LINEDOWN ; user clicked the bottom arrow DllStructSetData($tSCROLLINFO, "nPos", $Pos + $iLineV) Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box DllStructSetData($tSCROLLINFO, "nPos", $Pos - $iPageV) Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box DllStructSetData($tSCROLLINFO, "nPos", $Pos + $iPageV) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) 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 $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $yPos) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $yPos - $Pos) Return $GUI_RUNDEFMSG EndFunc ;==>WM_VSCROLL A little modification of help file example. Link to comment Share on other sites More sharing options...
qwert Posted July 14, 2009 Share Posted July 14, 2009 A little modification of help file example. Excellent! Thank you very much. Link to comment Share on other sites More sharing options...
rajeshontheweb Posted September 6, 2009 Share Posted September 6, 2009 I HAD AN EXACT SITUATION LIKE THIS, i had dynamically listed controls added to new rows, i got things sorted out, had resizing of gui sorted out but couldnt get the scroll bar to work the way i wanted to - i have earlier got it working with listbox or editbox controls working well with scroll bars but this got my requirement fullfilled thanks mate. Started late is much better than having never started it!!!!Failure is another step towards success. I've been messing around with: Adding Entry to 'Hosts'File Information Lister (Logger)Yet Another AutoIT Error Handler Yet Another AutoIT Error Handler & Debugger Control your App's TaskBar Button YCurrency Ticker (Latest Release : 16 Apr 2009)_WinInetInternetCheckConnection UDF Symantec Definitions Lister UDF _GetLocalIPAddresses UDF UDF to get Special Folder Information WMI_NetworkAdapterConfiguration2Array WMI_CDRomDriveCapabilities _ScriptExists - Check if your au3 script is running!! Uninstaller UDF Get Version for your application (at script level or compiled stage) Uninstaller Pro - faster alternative to windows application removal applet 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