Jump to content

Scrollbar 'Over-shoot'


Burgs
 Share

Recommended Posts

Greetings,

I have modified the standard "Func WM_HSCROLL" that handles scrollbars (horizontal) so as to control 2 different GUI scrollbars at the same time. It seems to be working fairly well however I am seeing an irritating problem when the 'smaller' GUI scrollbar 'over-shoots' the scroll position a bit when the scrollbar is dragged all the way to the left...I am having a difficult time correcting this, here's the code I have:

Global $MapWidth = 768
Global $MapHeight = 576
...
Sleep(500)
Map_Window()
Sleep(500)
Mini_Map()
...

Func Map_Window()
Global $MapBack = GUICreate("", $MapWidth, $MapHeight, 0, 28, $WS_CHILD, -1, $MainGUI)
GUISetState(@SW_SHOW)
;**SCROLL BARS...
GUISwitch($MapBack)
GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")
GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL")

_GUIScrollBars_Init($MapBack, 2048, 127)
_GUIScrollBars_SetScrollInfoMin($MapBack, $SB_HORZ, 0)
_GUIScrollBars_SetScrollInfoMax($MapBack, $SB_HORZ, 221)
_GUIScrollBars_SetScrollInfoPage($MapBack, $SB_HORZ, 34)
EndFunc

Func Mini_Map()

Global $MiniBack = GUICreate("Mini Map Viewer", 256, 256, 768, 0, BitOR($WS_CHILD, $WS_CAPTION), -1, $MainGUI)
GUISetState(@SW_SHOW)

;**SCROLL BARS...
GUISwitch($MiniBack)
GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")
GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL")

_GUIScrollBars_Init($MiniBack, 1536, 512)   
_GUIScrollBars_SetScrollInfoMin($MiniBack, $SB_HORZ, 0)
_GUIScrollBars_SetScrollInfoMax($MiniBack, $SB_HORZ, 221)   
EndFunc

Func WM_HSCROLL($hwd, $Msg, $wParam, $lParam)
#forceref $Msg, $lParam
Local $nScrollCode = BitAND($wParam, 0x0000FFFF)
Local $index = -1, $xChar, $xPos
Local $Min, $Max, $Page, $Pos, $TrackPos
Local $special = 0
For $x = 0 To UBound($aSB_WindowInfo) - 1
     If $aSB_WindowInfo[$x][0] = $hwd Then
         $index = $x
$index2 = $x
         $xChar = $aSB_WindowInfo[$index][2]
$xChar2 = $aSB_WindowInfo[$index2][2]
         ExitLoop
     EndIf
Next
If $index = -1 Then Return 0

;~ ; Get all the horizontal scroll bar information
Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($MapBack, $SB_HORZ)
Local $tSCROLLINFO2 = _GUIScrollBars_GetScrollInfoEx($MiniBack, $SB_HORZ)
$Min = DllStructGetData($tSCROLLINFO, "nMin")
$Min2 = DllStructGetData($tSCROLLINFO2, "nMin")
$Max = DllStructGetData($tSCROLLINFO, "nMax")
$Max2 = DllStructGetData($tSCROLLINFO2, "nMax")
$Page = DllStructGetData($tSCROLLINFO, "nPage")
$Page2 = DllStructGetData($tSCROLLINFO2, "nPage")
; Save the position for comparison later on
$xPos = DllStructGetData($tSCROLLINFO, "nPos")
$xPos2 = DllStructGetData($tSCROLLINFO2, "nPos")
$Pos = $xPos
$Pos2 = $xPos2
$TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")
$TrackPos2 = DllStructGetData($tSCROLLINFO2, "nTrackPos")
#forceref $Min, $Max
#forceref $Min2, $Max2
Switch $nScrollCode
     Case $SB_LINELEFT ; user clicked left arrow
         DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1)
DllStructSetData($tSCROLLINFO2, "nPos", $Pos2 - 1)
     Case $SB_LINERIGHT ; user clicked right arrow
         DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1)
DllStructSetData($tSCROLLINFO2, "nPos", $Pos2 + 1)
     Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box
         DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page)
DllStructSetData($tSCROLLINFO2, "nPos", ($Pos2 - $Page2))
     Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box
         DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page)
DllStructSetData($tSCROLLINFO2, "nPos", $Pos2 + $Page2)
     Case $SB_THUMBTRACK ; user dragged the scroll box
$special = 1    
         DllStructSetData($tSCROLLINFO, "nPos", $TrackPos)
DllStructSetData($tSCROLLINFO2, "nPos", $TrackPos2)
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)
DllStructSetData($tSCROLLINFO2, "fMask", $SIF_POS)
_GUIScrollBars_SetScrollInfo($MapBack, $SB_HORZ, $tSCROLLINFO)
_GUIScrollBars_SetScrollInfo($MiniBack, $SB_HORZ, $tSCROLLINFO2)
_GUIScrollBars_GetScrollInfo($MapBack, $SB_HORZ, $tSCROLLINFO)
_GUIScrollBars_GetScrollInfo($MiniBack, $SB_HORZ, $tSCROLLINFO2)
;// If the position has changed, scroll the window and update it
$Pos = DllStructGetData($tSCROLLINFO, "nPos")
$Pos2 = DllStructGetData($tSCROLLINFO2, "nPos")
If ($Pos <> $xPos) Then _GUIScrollBars_ScrollWindow($MapBack, $xChar * ($xPos - $Pos), 0)
If ($Pos2 <> $xPos2) Then _GUIScrollBars_ScrollWindow($MiniBack, ($xChar2 * ($xPos2 - $Pos2)) * .58567, 0)

;**PROBLEM RESIDES HERE, WHEN THE SCROLLBAR IS 'DRAGGED' BY THE USER...CAUSES AN 'OVER-SHOOT' WHEN THE SCROLLBAR IS DRAGGED ALL THE WAY TO THE LEFT...

If ($Pos <> $xPos) AND $special == 1 Then
$xChar2 = $xChar
$xPos2 = $xPos
$Pos2 = $Pos
$TrackPos2 = $TrackPos

_GUIScrollBars_SetScrollInfoPOS($MiniBack, $SB_HORZ, $TrackPos)
if $xPos > 0 AND $Pos > 0 Then _GUIScrollBars_ScrollWindow($MiniBack, ($xChar * ($xPos - $Pos)) * .12234, 0)
EndIf
EndFunc ;==>WM_HSCROLL

Is there a command to force a scrollbar to be set in a certain 'fixed' position? The "GUIScrollBars_ScrollWindow" uses increments...not fixed positions. I thought maybe I could force the window scroll to be in a fixed horizontal position of "0" when the "$xPos" and "$Pos" variables are also "0"...any help appreciated, thank you in advance.

Link to comment
Share on other sites

  • Moderators

Burgs,

If all you post is some incomplete code which has undeclared variables and several missing includes, you are very unlikely to get any help. People are not prepared to write goodness knows how many lines of additional code to make the above work - and anyway the chances are their code would be significantly different to yours and very unlikely to show the same problem. :(

So post some working code that shows the problem and then you stand a chance of getting some advice on your 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

Hmm thanks for the response but that basically is the complete (and working) code. That is the entire "WM_HSCROLL" function (modified from AutoIT Help file) along with the functions that establish the 2 GUI windows in question...what has been omitted are only the things that have absolutely nothing to do with those windows and/or the scrolling...

Is there no way to 'force' a scrollbar into a fixed position? I believe what seems to be happening is that when the user 'clicks and drags' the scrollbar without releasing the mouse button the initial $xPos and $Pos values are used...they are not updated to the 'present' position until after the mouse button is released, that seems to be what I am seeing using 'ConsoleWrite' to report the values...is this correct? Due to this it is possible to move/scroll to a position beyond the bounderies set by " _GUIScrollBars_SetScrollInfoMax" and "_GUIScrollBars_SetScrollInfoMin"...?

Link to comment
Share on other sites

  • Moderators

Burgs,

"What has been omitted" prevents the script from running. ;)

If you cannot provide working code to show the problem, I am certainly not writing the necessary additional code to make the script run and see if I can reproduce it - I doubt anyone else will either. Certainly I have never had an "overshoot" problem with scrollbars and so unless you can provide some code which shows the problem there is little I can do to help. :)

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

Hello,

OK thanks I have posted 'working' code that I have tested in a seperate script here:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <WinAPI.au3>
#include <GuiScrollBars.au3>
#include <ScrollBarConstants.au3>
#include <GDIPlus.au3>

Global $MapFile = "C:\Program Files\AAC\Scenarios\Maps\Falk_SAT.jpg"
Global $MapFile2 = "C:\Program Files\AAC\Scenarios\Maps\FalkX.jpg"
Global $MapWidth = 768
Global $MapHeight = 576

Global $MainGUI = GUICreate("MAIN INTERFACE WINDOW", 1024, 768)
GUISetState(@SW_SHOW)
Global $Menu_Bar = GUICtrlCreateGraphic(0, 1, 768, 25, $SS_BLACKFRAME)

Sleep(500)
Map_Window()
Sleep(500)
Mini_Map()


While 1
$nMsg = GUIGetMsg()
Switch $nMsg

     Case $GUI_EVENT_CLOSE
         Exit
EndSwitch
WEnd

Func Map_Window()
Global $MapBack = GUICreate("", $MapWidth, $MapHeight, 0, 28, $WS_CHILD, -1, $MainGUI)
;**SCROLL BARS...
GUISwitch($MapBack)
GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL")

_GUIScrollBars_Init($MapBack, 2048, 127)
_GUIScrollBars_SetScrollInfoMin($MapBack, $SB_HORZ, 0)
_GUIScrollBars_SetScrollInfoMax($MapBack, $SB_HORZ, 221)
_GUIScrollBars_SetScrollInfoPage($MapBack, $SB_HORZ, 34)

;**
; background picture
Global $TheMap = GUICtrlCreatePic($MapFile2, 9, 0, 2048, 2048, -1, -1)
GUISetState(@SW_SHOW)

EndFunc
Func Mini_Map()

Global $MiniBack = GUICreate("Mini Map Viewer", 256, 256, 768, 0, BitOR($WS_CHILD, $WS_CAPTION), -1, $MainGUI)


;**SCROLL BARS...
GUISwitch($MiniBack)
GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL")

_GUIScrollBars_Init($MiniBack, 1536, 512)
_GUIScrollBars_SetScrollInfoMin($MiniBack, $SB_HORZ, 0)         
_GUIScrollBars_SetScrollInfoMax($MiniBack, $SB_HORZ, 221)           
;**

; background picture
Global $MiniMap = GUICtrlCreatePic($MapFile, 0, 0, 2048, 2048, -1, -1)
GUISetState(@SW_SHOW)

EndFunc

Func WM_HSCROLL($hwd, $Msg, $wParam, $lParam)
#forceref $Msg, $lParam
Local $nScrollCode = BitAND($wParam, 0x0000FFFF)
Local $index = -1, $xChar, $xPos
Local $Min, $Max, $Page, $Pos, $TrackPos
Local $special = 0
For $x = 0 To UBound($aSB_WindowInfo) - 1
     If $aSB_WindowInfo[$x][0] = $hwd Then
         $index = $x
$index2 = $x
         $xChar = $aSB_WindowInfo[$index][2]
$xChar2 = $aSB_WindowInfo[$index2][2]
         ExitLoop
     EndIf
Next
If $index = -1 Then Return 0

;~ ; Get all the horizontal scroll bar information
Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($MapBack, $SB_HORZ)
Local $tSCROLLINFO2 = _GUIScrollBars_GetScrollInfoEx($MiniBack, $SB_HORZ)
$Min = DllStructGetData($tSCROLLINFO, "nMin")
$Min2 = DllStructGetData($tSCROLLINFO2, "nMin")
$Max = DllStructGetData($tSCROLLINFO, "nMax")
$Max2 = DllStructGetData($tSCROLLINFO2, "nMax")
$Page = DllStructGetData($tSCROLLINFO, "nPage")
$Page2 = DllStructGetData($tSCROLLINFO2, "nPage")
; Save the position for comparison later on
$xPos = DllStructGetData($tSCROLLINFO, "nPos")
$xPos2 = DllStructGetData($tSCROLLINFO2, "nPos")
$Pos = $xPos
$Pos2 = $xPos2
$TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")
$TrackPos2 = DllStructGetData($tSCROLLINFO2, "nTrackPos")
#forceref $Min, $Max
#forceref $Min2, $Max2
Switch $nScrollCode
     Case $SB_LINELEFT ; user clicked left arrow
         DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1)
DllStructSetData($tSCROLLINFO2, "nPos", $Pos2 - 1)
     Case $SB_LINERIGHT ; user clicked right arrow
         DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1)
DllStructSetData($tSCROLLINFO2, "nPos", $Pos2 + 1)
     Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box
         DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page)
DllStructSetData($tSCROLLINFO2, "nPos", ($Pos2 - $Page2))
     Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box
         DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page)
DllStructSetData($tSCROLLINFO2, "nPos", $Pos2 + $Page2)
     Case $SB_THUMBTRACK ; user dragged the scroll box
$special = 1    
         DllStructSetData($tSCROLLINFO, "nPos", $TrackPos)
DllStructSetData($tSCROLLINFO2, "nPos", $TrackPos2)
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)
DllStructSetData($tSCROLLINFO2, "fMask", $SIF_POS)
_GUIScrollBars_SetScrollInfo($MapBack, $SB_HORZ, $tSCROLLINFO)
_GUIScrollBars_SetScrollInfo($MiniBack, $SB_HORZ, $tSCROLLINFO2)
_GUIScrollBars_GetScrollInfo($MapBack, $SB_HORZ, $tSCROLLINFO)
_GUIScrollBars_GetScrollInfo($MiniBack, $SB_HORZ, $tSCROLLINFO2)
;// If the position has changed, scroll the window and update it
$Pos = DllStructGetData($tSCROLLINFO, "nPos")
$Pos2 = DllStructGetData($tSCROLLINFO2, "nPos")
If ($Pos <> $xPos) Then _GUIScrollBars_ScrollWindow($MapBack, $xChar * ($xPos - $Pos), 0)
If ($Pos2 <> $xPos2) Then _GUIScrollBars_ScrollWindow($MiniBack, ($xChar2 * ($xPos2 - $Pos2)) * .58567, 0) ;is = (188 / 107) / 3
If ($Pos <> $xPos) AND $special == 1 Then
$xChar2 = $xChar
$xPos2 = $xPos
$Pos2 = $Pos
$TrackPos2 = $TrackPos

_GUIScrollBars_SetScrollInfoPOS($MiniBack, $SB_HORZ, $TrackPos)
if $xPos > 0 AND $Pos > 0 Then _GUIScrollBars_ScrollWindow($MiniBack, ($xChar * ($xPos - $Pos)) * .12234, 0) ; is = ???
EndIf
EndFunc ;==>WM_HSCROLL

In addition I have made a few screenshots because they do a better job of illustrating the problem...better to see it visually.

in the first image you can see the 2 GUI interface windows, a large one with 'hexes' in it and a smaller in the top right labeled 'Mini Map Viewer'...

In the second image you can see the scrollbar in the main window has been scrolled (clicked/dragged) a bit, with the image in the smaller GUI scrolling as well...

In the third image the scrollbar in the main window has been dragged back to the left boundery, and you can see the 'over-shoot' grey area in the smaller GUI that shouldn't be there...compare with the first image...

In the fourth image this 'over-shoot' grey area can be seen quite dramaticaly...by continuing to 'click/drag' the main GUI scrollbar to the right and back to the left several times it causes the grey area in the small GUI to become more pronounced...Why is the (left) boundery in the smaller GUI seemingly being ignored??? NOTE this only happens with click/drag scrolling...by 'clicking' the scrollbar arrows OR 'clicking' in the area to the right/left of the scrollbar (Page) I do not see the over-shoot effect at all...

Thanks again.

Link to comment
Share on other sites

very hard to understand

I dont get any images

Y not make a zip of all the files

and attach it

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

You can use any image in place of the ones he has in his script, the effect is definitely noticable, but as I have no understanding of what the script is doing to match the scrolling I can't offer any insight as to what is causing it. I haven't studied the script all that much because it's over my head.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Moderators

Burgs,

I think you are overcomplicating the scrollbar position setting code. Using this simpler version, I get no "overshoot": ;

;~ // 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)
    DllStructSetData($tSCROLLINFO2, "fMask", $SIF_POS)
    _GUIScrollBars_SetScrollInfo($MapBack, $SB_HORZ, $tSCROLLINFO)
    _GUIScrollBars_SetScrollInfo($MiniBack, $SB_HORZ, $tSCROLLINFO2)
    _GUIScrollBars_GetScrollInfo($MapBack, $SB_HORZ, $tSCROLLINFO)
    _GUIScrollBars_GetScrollInfo($MiniBack, $SB_HORZ, $tSCROLLINFO2)
    ;// If the position has changed, scroll the window and update it
    $Pos = DllStructGetData($tSCROLLINFO, "nPos")
    If ($Pos <> $xPos) Then _GUIScrollBars_ScrollWindow($MapBack, $xChar * ($xPos - $Pos), 0)
    $Pos2 =  DllStructGetData($tSCROLLINFO2, "nPos")
    If ($Pos2 <> $xPos2) Then _GUIScrollBars_ScrollWindow($MiniBack, ($xChar2 * ($xPos2 - $Pos2)) * .58567, 0) ;is = (188 / 107) / 3
    If ($Pos <> $xPos) And $special = 1 Then
        $xChar2 = $xChar
        $xPos2 = $xPos
        $Pos2 = $Pos
        ; Calculate the required movement of the smaller scroll bar based on the position of the main scrollbar
        $iReq_Pos2 = Int($Pos * 1536 / 2048)
        ; And move the small scrollbar to that position
        _GUIScrollBars_SetScrollInfoPos($MiniBack, $SB_HORZ, $iReq_Pos2)
    EndIf

I now get no "overshoot" when dragging the larger scrollbar - how about you? :huh:

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

Hello, Thanks for your reply. Yes it is correct I don't get the "overshoot" anymore however there are a couple of issues with that...

1. When scrolling (click/drag) the main window all the way to the right side the scrollbar in the smaller window does not go all the way to the right (because of the " $iReq_Pos2 = Int($Pos * 1536 / 2048)" limitation I assume...

2. When using a "combination" of movements, for example moving the scrollbar a bit with click/drag, then clicking the scrollbar 'arrows' and/or to the right/left of the scrollbar (Page) the smaller window scroll adjustments are incorrect (the map image isn't scrolled correctly), and it can cause the "overshoot" issue again...

I am just trying to control the scrollbars in the 2 GUI windows using the same code so they move concurrently with one another regardless of which scrollbar the user manipulates...it's a bit surprising this is so difficult to achieve...

Thanks again for your input. It is greatly appreciated.

Link to comment
Share on other sites

  • Moderators

Burgs,

Try this with your map images and see if it works for you. It uses my GUIScrollBars_Size UDF (look in my sig) to get the scrollbars sized so that they move in synch without the nasty fractions we were using: ;)

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <WinAPI.au3>
#include <GuiScrollBars.au3>
#include <ScrollBarConstants.au3>
#include <GDIPlus.au3>

#include <GUIScrollBars_Size.au3>

Global $MainGUI = GUICreate("MAIN INTERFACE WINDOW", 1024, 768)
GUISetState(@SW_SHOW)

Global $Menu_Bar = GUICtrlCreateGraphic(0, 1, 768, 25, $SS_BLACKFRAME)

Map_Window()
Mini_Map()

GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func Map_Window()

    $aSB_Size = _GUIScrollbars_Size(2048, 2048, 768, 576)

    Global $MapBack = GUICreate("", 768, 576, 0, 28, $WS_CHILD, -1, $MainGUI)
    ; background picture
    Global $TheMap = GUICtrlCreateLabel("", 0, 0, 2048, 2048)
    GUICtrlSetBkColor(-1, 0xFFCCCC)

    _GUIScrollBars_Init($MapBack)
    _GUIScrollBars_SetScrollInfoMax($MapBack, $SB_HORZ, $aSB_Size[1])
    _GUIScrollBars_SetScrollInfoPage($MapBack, $SB_HORZ, $aSB_Size[0])

    GUISetState(@SW_SHOW)

EndFunc   ;==>Map_Window

Func Mini_Map()

    $aSB_Size = _GUIScrollbars_Size(1536, 512, 256, 256)

    Global $MiniBack = GUICreate("Mini Map Viewer", 256, 256, 768, 0, BitOR($WS_CHILD, $WS_CAPTION), -1, $MainGUI)
    ; background picture
    Global $MiniMap = GUICtrlCreateLabel("", 0, 0, 1536, 512)
    GUICtrlSetBkColor(-1, 0xCCFFCC)

    _GUIScrollBars_Init($MiniBack)
    _GUIScrollBars_SetScrollInfoMax($MiniBack, $SB_HORZ, $aSB_Size[1])
    _GUIScrollBars_SetScrollInfoPage($MiniBack, $SB_HORZ, $aSB_Size[0])

    GUISetState(@SW_SHOW)

EndFunc   ;==>Mini_Map

Func 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($aSB_WindowInfo) - 1
        If $aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $xChar = $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)

    ; Move the scrollbar
    $Pos = DllStructGetData($tSCROLLINFO, "nPos")
    If ($Pos <> $xPos) Then _GUIScrollBars_ScrollWindow($hWnd, $xChar * ($xPos - $Pos), 0)

    ; If the scrollbar belongs to the big window
    If $hWnd = $MapBack Then
        ; Reset the info for the small window
        For $x = 0 To UBound($aSB_WindowInfo) - 1
        If $aSB_WindowInfo[$x][0] = $MiniBack Then
            $iIndex = $x
            $xChar = $aSB_WindowInfo[$iIndex][2]
            ExitLoop
        EndIf
    Next
    ; If the small window exists
    If $iIndex <> -1 Then
        DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
        _GUIScrollBars_SetScrollInfo($MiniBack, $SB_HORZ, $tSCROLLINFO)
        _GUIScrollBars_GetScrollInfo($MiniBack, $SB_HORZ, $tSCROLLINFO)
        ; Move the small scrollbar to the correct place
        _GUIScrollBars_ScrollWindow($MiniBack, $xChar * ($xPos - $Pos), 0)
    EndIf

    EndIf

    Return $GUI_RUNDEFMSG

EndFunc   ;==>WM_HSCROLL

Fun things scrollbars - NOT! :D

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

Thanks Melba...I tried your script and I have a couple of questions about it please:

1. Seems to work well if both images in the 2 windows are the same size (2048x2048) for example, but can the script compensate if one image is a different size, say 512x512 for example? Please refer to the 2 images I have attached ...the "Mini Map" window now contains a 512x512 image, and I changed the line in the "Mini_Window()" function to read: $aSB_Size = _GUIScrollbars_Size(512, 512, 256, 256)

you can see in the first attachment the main scrollbar has been dragged to the right, and in the second attachment it has continued to be dragged to the right however the "Mini Map" image also continues to scroll ("over-shoot") even though the scrollbar in that window is all the way to the right and cannot be moved further...?

I guess my original question is this: Why are windows continuing to scroll even when the scrollbars can not be scrolled further and/or the "_GUIScrollBars_SetScrollInfoMax"/"_GUIScrollBars_SetScrollInfoMin" constraints have been set to supposedly prevent that...??

2. Can your script be made functional regardless if which window scrollbar is manipulated? It only is functioning with the scrollbar in the main window, if I move the scrollbar in the smaller window nothing is scrolled in the main window...

3. As an alternative to scrollbar windows (I really don't want to use them anyway) is it at all possible to scroll the GUI views without using scrollbars and without having to physically change the X/Y coordinates of the image within the window???

post-35979-0-15959500-1342186978_thumb.j

post-35979-0-74701500-1342186993_thumb.j

Link to comment
Share on other sites

  • Moderators

Burgs,

Answers to questions:

- 1. I have no idea. I did a lot of work with them to produce my UDF and I still find them hard to fathom most of the time. :wacko:

- 2. I think so - let me have a play this afernoon. :)

- 3. The only "non-scrollbar" solution I can think of is measuring the change of mouse position with a button pressed and then moving the location of the image within the GUI. I am not sure how easy that would be but I will have a play around and see what I can come up with. ;)

Finally, rather than use my own images, could you let me have the ones you want to use - then at least we are starting from the same point. :)

M23

Moving both scrollbars together is as easy as I thought: :D

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <WinAPI.au3>
#include <GuiScrollBars.au3>
#include <ScrollBarConstants.au3>
#include <GDIPlus.au3>

#include <GUIScrollBars_Size.au3>

Global $MainGUI = GUICreate("MAIN INTERFACE WINDOW", 1024, 768)
GUISetState(@SW_SHOW)

Global $Menu_Bar = GUICtrlCreateGraphic(0, 1, 768, 25, $SS_BLACKFRAME)

Map_Window()
Mini_Map()

GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func Map_Window()

    $aSB_Size = _GUIScrollbars_Size(2048, 2048, 768, 576)

    Global $MapBack = GUICreate("", 768, 576, 0, 28, $WS_CHILD, -1, $MainGUI)
    ; background picture
    Global $TheMap = GUICtrlCreateLabel("", 0, 0, 2048, 2048)
    GUICtrlSetBkColor(-1, 0xFFCCCC)

    _GUIScrollBars_Init($MapBack)
    _GUIScrollBars_SetScrollInfoMax($MapBack, $SB_HORZ, $aSB_Size[1])
    _GUIScrollBars_SetScrollInfoPage($MapBack, $SB_HORZ, $aSB_Size[0])

    GUISetState(@SW_SHOW)

EndFunc   ;==>Map_Window

Func Mini_Map()

    $aSB_Size = _GUIScrollbars_Size(1536, 512, 256, 256)

    Global $MiniBack = GUICreate("Mini Map Viewer", 256, 256, 768, 0, BitOR($WS_CHILD, $WS_CAPTION), -1, $MainGUI)
    ; background picture
    Global $MiniMap = GUICtrlCreateLabel("", 0, 0, 1536, 512)
    GUICtrlSetBkColor(-1, 0xCCFFCC)

    _GUIScrollBars_Init($MiniBack)
    _GUIScrollBars_SetScrollInfoMax($MiniBack, $SB_HORZ, $aSB_Size[1])
    _GUIScrollBars_SetScrollInfoPage($MiniBack, $SB_HORZ, $aSB_Size[0])

    GUISetState(@SW_SHOW)

EndFunc   ;==>Mini_Map

Func 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($aSB_WindowInfo) - 1
        If $aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $xChar = $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)

    ; Move the scrollbar
    $Pos = DllStructGetData($tSCROLLINFO, "nPos")
    If ($Pos <> $xPos) Then _GUIScrollBars_ScrollWindow($hWnd, $xChar * ($xPos - $Pos), 0)

    ; If the scrollbar belongs to the big window
    If $hWnd = $MapBack Then
        ; Reset the info for the small window
        For $x = 0 To UBound($aSB_WindowInfo) - 1
            If $aSB_WindowInfo[$x][0] = $MiniBack Then
                $iIndex = $x
                $xChar = $aSB_WindowInfo[$iIndex][2]
                ExitLoop
            EndIf
        Next
        ; If the small window exists
        If $iIndex <> -1 Then
            DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
            _GUIScrollBars_SetScrollInfo($MiniBack, $SB_HORZ, $tSCROLLINFO)
            _GUIScrollBars_GetScrollInfo($MiniBack, $SB_HORZ, $tSCROLLINFO)
            ; Move the small scrollbar to the correct place
            _GUIScrollBars_ScrollWindow($MiniBack, $xChar * ($xPos - $Pos), 0)
        EndIf
    ElseIf $hWnd = $MiniBack Then
        ; Reset the info for the large window
        For $x = 0 To UBound($aSB_WindowInfo) - 1
            If $aSB_WindowInfo[$x][0] = $MapBack Then
                $iIndex = $x
                $xChar = $aSB_WindowInfo[$iIndex][2]
                ExitLoop
            EndIf
        Next
        ; If the large window exists
        If $iIndex <> -1 Then
            DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
            _GUIScrollBars_SetScrollInfo($MapBack, $SB_HORZ, $tSCROLLINFO)
            _GUIScrollBars_GetScrollInfo($MapBack, $SB_HORZ, $tSCROLLINFO)
            ; Move the large scrollbar to the correct place
            _GUIScrollBars_ScrollWindow($MapBack, $xChar * ($xPos - $Pos), 0)
        EndIf

    EndIf

    Return $GUI_RUNDEFMSG

EndFunc   ;==>WM_HSCROLL

You could use a function to shorten the code - I have left it expanded for clarity. ;)

Edited by Melba23
Added example

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

Yes thanks Melba that seems to work nicely, thank you very much.

For a "non-scrollbar" solution would it be possible to have the scrollbars hidden from view and then use a button or perhaps the 'arrow keys' to send 'controlclick' commands to the (hidden) scrollbar so as to make the view within the GUI move around? Just a thought but I don't know if feasable.

Attached are the 2 images I'm using...one a 2048x2048 and the other 512x512...I seem to not have enough space to upload both of them here...is there an email I can send them to? Thanks again for all your input...

Edited by Burgs
Link to comment
Share on other sites

  • Moderators

Burgs,

Go to your user-name at top-right and open the dropdown menu. Select "My Settings" and then "Manage Attachments" to the left of the next page. Then you can remove any uploads that you no longer need - that might give you space enough. ;)

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

OK thanks...here are the images...I had to substitute another image for the 2048x2048 one since the actual image I am using is too big to upload (1.63MB)...but at least the substitute is the same dimensions at 2048x2048...

Basically the 2048x2048 is 4 times larger than the 512x512...and conversely the 512x512 is .25 times the size of the 2048x2048...I want the scrollbars to 'correctly' scroll to the proper positions in each window. Thus for example if the scrollbar in the 'larger' window is moved all the way to the right then it should also in the 'smaller' window, and for example if the scrollbar in the 'smaller' window is moved about half-way then so should the scrollbar in the 'larger' window be moved half-way...the 'smaller' window is intended to be a larger scale (more distant 'bird's eye) view of the 'larger' window

I almost had that working except for that "over-shoot" issue is screwing it up...

post-35979-0-52262500-1342195338_thumb.j

post-35979-0-00141200-1342195423_thumb.j

Link to comment
Share on other sites

  • Moderators

Burgs,

I think I might have a solution here: :)

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <WinAPI.au3>
#include <GuiScrollBars.au3>
#include <ScrollBarConstants.au3>
#include <GDIPlus.au3>

#include <GUIScrollBars_Size.au3>

Global $aSB_Size_MapBack, $aSB_Size_MiniBack

Global $MainGUI = GUICreate("MAIN INTERFACE WINDOW", 1024, 768)
GUISetState(@SW_SHOW)

Global $Menu_Bar = GUICtrlCreateGraphic(0, 1, 768, 25, $SS_BLACKFRAME)

Map_Window()
Mini_Map()

GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL")
GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func Map_Window()

    ; get parameters for this GUI
    $aSB_Size_MapBack = _GUIScrollbars_Size(2048, 2048, 768, 576)

    Global $MapBack = GUICreate("", 768, 576, 0, 28, $WS_CHILD, -1, $MainGUI)
    ; background picture
    Global $TheMap = GUICtrlCreatePic("M:ProgramAu3 ScriptsFalkland_SAT.JPG", 0, 0, 2048, 2048)

    _GUIScrollBars_Init($MapBack)
    _GUIScrollBars_SetScrollInfoMax($MapBack, $SB_HORZ, $aSB_Size_MapBack[1])
    _GUIScrollBars_SetScrollInfoPage($MapBack, $SB_HORZ, $aSB_Size_MapBack[0])
    _GUIScrollBars_SetScrollInfoMax($MapBack, $SB_VERT, $aSB_Size_MapBack[3])
    _GUIScrollBars_SetScrollInfoPage($MapBack, $SB_VERT, $aSB_Size_MapBack[2])

    GUISetState(@SW_SHOW)

EndFunc   ;==>Map_Window

Func Mini_Map()

    ; get parameters for this GUI
    $aSB_Size_MiniBack = _GUIScrollbars_Size(512, 512, 256, 256)

    Global $MiniBack = GUICreate("Mini Map Viewer", 256, 256, 768, 0, BitOR($WS_CHILD, $WS_CAPTION), -1, $MainGUI)
    ; background picture
    Global $MiniMap = GUICtrlCreatePic("M:ProgramAu3 ScriptsFalkX512.jpg", 0, 0, 512, 512)

    _GUIScrollBars_Init($MiniBack)
    _GUIScrollBars_SetScrollInfoMax($MiniBack, $SB_HORZ, $aSB_Size_MiniBack[1])
    _GUIScrollBars_SetScrollInfoPage($MiniBack, $SB_HORZ, $aSB_Size_MiniBack[0])
    _GUIScrollBars_SetScrollInfoMax($MiniBack, $SB_VERT, $aSB_Size_MiniBack[3])
    _GUIScrollBars_SetScrollInfoPage($MiniBack, $SB_VERT, $aSB_Size_MiniBack[2])

    GUISetState(@SW_SHOW)

EndFunc   ;==>Mini_Map

Func 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($aSB_WindowInfo) - 1
        If $aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $xChar = $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)

    ; Move the scrollbar
    $Pos = DllStructGetData($tSCROLLINFO, "nPos")
    If ($Pos <> $xPos) Then _GUIScrollBars_ScrollWindow($hWnd, $xChar * ($xPos - $Pos), 0)

    ; Now move other scrollbar
    Switch $hWnd
        Case $MapBack
            ; get fractional position of scrollbar in moved GUI
            $nPos_HORZ = _GUIScrollBars_GetScrollInfoPos($MapBack, $SB_HORZ)
            $nFraction_HORZ = $nPos_HORZ / ($aSB_Size_MapBack[1] - $aSB_Size_MapBack[0])
            ; And set other scrollbar to same fraction
            _GUIScrollBars_SetScrollInfoPos($MiniBack, $SB_HORZ, ($aSB_Size_MiniBack[1] - $aSB_Size_MiniBack[0]) * $nFraction_HORZ)
        Case $MiniBack
            $nPos_HORZ = _GUIScrollBars_GetScrollInfoPos($MiniBack, $SB_HORZ)
            $nFraction_HORZ = $nPos_HORZ / ($aSB_Size_MiniBack[1] - $aSB_Size_MiniBack[0])
            _GUIScrollBars_SetScrollInfoPos($MapBack, $SB_HORZ, ($aSB_Size_MapBack[1] - $aSB_Size_MapBack[0]) * $nFraction_HORZ)
    EndSwitch

    Return $GUI_RUNDEFMSG

EndFunc   ;==>WM_HSCROLL

Func WM_VSCROLL($hWnd, $Msg, $wParam, $lParam)

    #forceref $Msg, $lParam
    Local $nScrollCode = BitAND($wParam, 0x0000FFFF)
    Local $iIndex = -1, $yChar, $yPos
    Local $Page, $Pos, $TrackPos
    For $x = 0 To UBound($aSB_WindowInfo) - 1
        If $aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $yChar = $aSB_WindowInfo[$iIndex][3]
            ExitLoop
        EndIf
    Next
    If $iIndex = -1 Then Return 0
    Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)
    $Page = DllStructGetData($tSCROLLINFO, "nPage")
    $yPos = DllStructGetData($tSCROLLINFO, "nPos")
    $Pos = $yPos
    $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")
    Switch $nScrollCode
        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)

    ; Move the scrollbar
    $Pos = DllStructGetData($tSCROLLINFO, "nPos")
    If ($Pos <> $yPos) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos))

    ; Now move other scrollbar
    Switch $hWnd
        Case $MapBack
            ; get fractional position of scrollbar in moved GUI
            $nPos_VERT = _GUIScrollBars_GetScrollInfoPos($MapBack, $SB_VERT)
            $nFraction_VERT = $nPos_VERT / ($aSB_Size_MapBack[1] - $aSB_Size_MapBack[0])
            ; And set other scrollbar to same fraction
            _GUIScrollBars_SetScrollInfoPos($MiniBack, $SB_VERT, ($aSB_Size_MiniBack[1] - $aSB_Size_MiniBack[0]) * $nFraction_VERT)
        Case $MiniBack
            $nPos_VERT = _GUIScrollBars_GetScrollInfoPos($MiniBack, $SB_VERT)
            $nFraction_VERT = $nPos_VERT / ($aSB_Size_MiniBack[1] - $aSB_Size_MiniBack[0])
            _GUIScrollBars_SetScrollInfoPos($MapBack, $SB_VERT, ($aSB_Size_MapBack[1] - $aSB_Size_MapBack[0]) * $nFraction_VERT)
    EndSwitch

    Return $GUI_RUNDEFMSG

EndFunc   ;==>WM_VSCROLL

Does that do it for you? :huh:

M23

P.S. Interesting choice of images, by the way - I have not been there for a very long time! :D

Edited by Melba23
Added P.S.

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

You are quite the genious...I have only time to look at it very quickly today but it seems almost perfect. I did notice on the vertical scroll of the "Mini" window all the way down the scrollbar in the"'Main" window doesn't quite scroll all the way...and maybe some of the "arrow" scrollbar clicks are a little off...but that is brilliant. I will work more with it tomorrow. Thank you again so much for your help and time.

--You have been there? ...wow I am sure not many people have been...

Best regards

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...