Sign in to follow this  
Followers 0
jaberwacky

[SOLVED] Problem with scrolling, minimizing and restoring

8 posts in this topic

#1 ·  Posted (edited)

I have a window with a vertical scrollbar. The bottom of the window is cut off when you scroll down, minimize the window, and then restore the window. I have some screen shots that demonstrate this.

I used Melba23's ScrollBar UDF which did alert me to another problem which I corrected. Because the UDF didn't seem to help with this problem I went back to my old scroll code which I lifted from the helpfile.

Any ideas as to why this might happen?

This is how it looks before:

Posted Image

This is how it looks after:

Posted Image

This is how it should look:

Posted Image

Here is my scroll bar code just in case because I feel this is where the problem lies. I just realized that this probably isn't the problem because I took this from the helpfile and no one else seems to have an issue with it so far.

#region - Scrollbar
GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")
GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL")

_GUIScrollBars_Init($main_gui, 0, 40)

#region -- Gui Register Messages
Func WM_MOUSEWHEEL(Const $hWnd, Const $iMsg, Const $iwParam, Const $ilParam)
    #forceref $hwnd, $iMsg, $ilParam
    Local Const $iDelta = BitShift($iwParam, 16)

    If $iDelta > 0 Then
        _SendMessage($main_gui, $WM_VSCROLL, $SB_LINEUP)
    Else
        _SendMessage($main_gui, $WM_VSCROLL, $SB_LINEDOWN)
    EndIf

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOUSEWHEEL

Func WM_VSCROLL(Const $hWnd, Const $Msg, Const $wParam, Const $lParam)
    #forceref $Msg, $wParam, $lParam

    Local $index = -1
    Local $yChar = ''
    Local Const $upbound =(UBound($aSB_WindowInfo) - 1)

    For $x = 0 To $upbound
        If $aSB_WindowInfo[$x][0] = $hWnd Then
            $index = $x
            $yChar = $aSB_WindowInfo[$index][3]
            ExitLoop
        EndIf
    Next

    If $index = -1 Then Return $GUI_RUNDEFMSG

    ; Get all the vertical scroll bar information
    Local      $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)
    Local Const $yPos       = DllStructGetData($tSCROLLINFO, "nPos")

    Local Const $nScrollCode = BitAND($wParam, 0x0000FFFF)

    Switch $nScrollCode
        Case $SB_TOP ; user clicked the HOME keyboard key
            Local Const $Min = DllStructGetData($tSCROLLINFO, "nMin")
            DllStructSetData($tSCROLLINFO, "nPos", $Min)

        Case $SB_BOTTOM ; user clicked the END keyboard key
            Local Const $Max = DllStructGetData($tSCROLLINFO, "nMax")
            DllStructSetData($tSCROLLINFO, "nPos", $Max)

        Case $SB_LINEUP ; user clicked the top arrow
            DllStructSetData($tSCROLLINFO, "nPos",($yPos - 1))

        Case $SB_LINEDOWN ; user clicked the bottom arrow
            DllStructSetData($tSCROLLINFO, "nPos",($yPos + 1))

        Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box
            Local Const $Page1 = DllStructGetData($tSCROLLINFO, "nPage")
            DllStructSetData($tSCROLLINFO, "nPos",($yPos - $Page1))

        Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box
            Local Const $Page2 = DllStructGetData($tSCROLLINFO, "nPage")
            DllStructSetData($tSCROLLINFO, "nPos",($yPos + $Page2))

        Case $SB_THUMBTRACK ; user dragged the scroll box
            Local Const $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")
            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
    Local Const $Pos = DllStructGetData($tSCROLLINFO, "nPos")
    If ($Pos <> $yPos) Then _GUIScrollBars_ScrollWindow($hWnd, 0,($yChar *($yPos - $Pos)))

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_VSCROLL
#endregion -- Gui Register Messages
#endregion - Scrollbar

Yes, I know I should just not minimize the window.

Edited by LaCastiglione

Share this post


Link to post
Share on other sites



I don't know why that might happen, but if you have the script check the GUIGetMsg function for $GUI_EVENT_RESTORE (i think that's what it is), then just have the script completely re-do the scrollbars.

Share this post


Link to post
Share on other sites

Try having your script execute Melba23's scrollbar function each time the GUI windows is restored. That might solve it.

Share this post


Link to post
Share on other sites

czardas came up with a solution to this:

child GUI scrollbar breaks - when changing desktop background preferences

;modified from a Melba23 scrollbar UDF example - GUIScrollbars_Size_Example_2.au3
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIScrollBars.au3>
#include <ScrollBarConstants.au3>
#include "GUIScrollbars_Size.au3"
#include <SendMessage.au3>
Global $hGUI, $aRet
$hGUI = GUICreate("Test", 300, 300)
$aRet = _GUIScrollbars_Size(0, 550, 300, 300)
_GUIScrollBars_Init($hGUI)
_GUIScrollBars_ShowScrollBar($hGUI, $SB_VERT, True)
_GUIScrollBars_ShowScrollBar($hGUI, $SB_HORZ, False)
_GUIScrollBars_SetScrollInfoPage($hGUI, $SB_VERT, $aRet[2])
_GUIScrollBars_SetScrollInfoMax($hGUI, $SB_VERT, $aRet[3])
_Draw_Labels(10)
GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")
GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL")
GUISetState()
While 1
Switch GUIGetMsg()
  Case $GUI_EVENT_RESTORE
   _Refresh($hGUI)
  Case $GUI_EVENT_CLOSE
   Exit
EndSwitch
WEnd
Func _Refresh($hWnd)
_GUIScrollBars_ShowScrollBar($hWnd, $SB_BOTH, True)
    Local $nPos = _GUIScrollBars_GetScrollPos($hWnd, $SB_VERT) ; Get current position
    _GUIScrollBars_SetScrollInfoPos($hWnd, $SB_VERT, 0) ; Set the scroll to zero
    ;Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)
    _GUIScrollBars_ShowScrollBar($hWnd,  $SB_HORZ, False)
    ;_GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO);seems to work without this
    _GUIScrollBars_SetScrollInfoPos($hWnd, $SB_VERT, $nPos)
EndFunc

Func _Draw_labels($iCount)
GUISwitch($hGUI)
For $i = 0 To 10
  GUICtrlCreateLabel($i, 10, $i * 50 +10, 265, 40)
  GUICtrlSetBkColor(-1, 0xFF8080)
  GUICtrlSetFont(-1, 18)
Next
EndFunc   ;==>_Draw_labels

Func WM_MOUSEWHEEL(Const $hWnd, Const $iMsg, Const $iwParam, Const $ilParam)
    #forceref $hwnd, $iMsg, $ilParam
    Local Const $iDelta = BitShift($iwParam, 16)
    If $iDelta > 0 Then
        _SendMessage($hGUI, $WM_VSCROLL, $SB_LINEUP)
    Else
        _SendMessage($hGUI, $WM_VSCROLL, $SB_LINEDOWN)
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOUSEWHEEL
Func WM_VSCROLL(Const $hWnd, Const $Msg, Const $wParam, Const $lParam)
    #forceref $Msg, $wParam, $lParam
    Local $index = -1
    Local $yChar = ''
    Local Const $upbound =(UBound($aSB_WindowInfo) - 1)
    For $x = 0 To $upbound
        If $aSB_WindowInfo[$x][0] = $hWnd Then
            $index = $x
            $yChar = $aSB_WindowInfo[$index][3]
            ExitLoop
        EndIf
    Next
    If $index = -1 Then Return $GUI_RUNDEFMSG
    ; Get all the vertical scroll bar information
    Local     $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)
    Local Const $yPos      = DllStructGetData($tSCROLLINFO, "nPos")
    Local Const $nScrollCode = BitAND($wParam, 0x0000FFFF)
    Switch $nScrollCode
        Case $SB_TOP ; user clicked the HOME keyboard key
            Local Const $Min = DllStructGetData($tSCROLLINFO, "nMin")
            DllStructSetData($tSCROLLINFO, "nPos", $Min)
        Case $SB_BOTTOM ; user clicked the END keyboard key
            Local Const $Max = DllStructGetData($tSCROLLINFO, "nMax")
            DllStructSetData($tSCROLLINFO, "nPos", $Max)
        Case $SB_LINEUP ; user clicked the top arrow
            DllStructSetData($tSCROLLINFO, "nPos",($yPos - 1))
        Case $SB_LINEDOWN ; user clicked the bottom arrow
            DllStructSetData($tSCROLLINFO, "nPos",($yPos + 1))
        Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box
            Local Const $Page1 = DllStructGetData($tSCROLLINFO, "nPage")
            DllStructSetData($tSCROLLINFO, "nPos",($yPos - $Page1))
        Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box
            Local Const $Page2 = DllStructGetData($tSCROLLINFO, "nPage")
            DllStructSetData($tSCROLLINFO, "nPos",($yPos + $Page2))
        Case $SB_THUMBTRACK ; user dragged the scroll box
            Local Const $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")
            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
    Local Const $Pos = DllStructGetData($tSCROLLINFO, "nPos")
    If ($Pos <> $yPos) Then _GUIScrollBars_ScrollWindow($hWnd, 0,($yChar *($yPos - $Pos)))
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_VSCROLL

I see fascists...

Share this post


Link to post
Share on other sites

rover,

Hi there! ;)

I missed that the first time round - I will look to to see if I can get that into the UDF. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0