Jump to content

[Solved] Unable to hide the scroll bar of a child window


strate
 Share

Recommended Posts

I'm trying to make three GUIs look like one. I wanna simulate a part of the window scrolling up.

The sample code below is a parent GUI with two children in it. One child is setup to scroll vertically, and the other is setup to hide the vertical scroll bar that is created by the first GUI.

I need the vertical scrollbar eliminated but I can't figure out how, _GUIScrollBars_Show($inside, $SB_VERT, False) seems to do nothing for me.

#include <GUIConstants.au3>
#include <GUIScrollBars.au3>
#Include <GuiStatusBar.au3>
;
Opt("GUIOnEventMode", 1)
;
#region ; Stationary Pane
$h_Main_GUI = GUICreate("Label Application",700,400,-1,-1)
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")

$Label8 = GUICtrlCreateLabel("This side of the window remains unchanged." , 256, 112, 300, 16)

$ok1 = GUICtrlCreateButton ("OK",  580, 30, 50, 20)
GUICtrlSetOnEvent(-1, "OKPressed")

$cancel1 = GUICtrlCreateButton ( "Cancel",640,30,50,20)
GUICtrlSetOnEvent(-1, "CancelPressed")

GUISetState()
#endregion ; Stationary Pane
;
#region ; "Scrolling" Pane
$i_SliderWidth = 200
$i_SliderHeight = 400
$inside = GuiCreate( "GUI 1",$i_SliderWidth, $i_SliderHeight, 0, 0,$WS_POPUP)   ; CREATE GUI 1
_SetParent( "GUI", "Label Application" )

_GUIScrollBars_Init($inside)
_GUIScrollBars_Show($inside, $SB_HORZ, False)

$Labe20 = GUICtrlCreateLabel("Scrolling pane", 24, 112, 113, 16)
$Label3 = GUICtrlCreateLabel("This side of the window scrolls.", 24, 160, 200, 16)
$Label1 = GUICtrlCreateLabel('Select "OK" to slide window up.',24, 208, 200, 16)

_GUIScrollBars_Enable ($inside, $SB_VERT, False)
_GUIScrollBars_SetRange ($inside, $SB_VERT, 0,30)
_GUIScrollBars_SetPos ($inside, $SB_VERT, 30)

$Label4 = GUICtrlCreateLabel("Everything is okay until you", 24, 40,200, 16)
$Label5 = GUICtrlCreateLabel("Type something in the input:", 24, 80,200, 16)
$DueDate = GUICtrlCreateInput("", 24,120, 49, 21,$ES_NUMBER)
$Label5 = GUICtrlCreateLabel("After doing so the scroll bar is"&@cr&"visable.", 24, 180,180,30)


_GUIScrollBars_Show ($inside, $SB_HORZ, False)
_GUIScrollBars_SetPos ($inside, $SB_VERT, 0)

GUISetState(@SW_SHOW)
#endregion ; "Scrolling" Pane
;
#region ; Scroll Bar "Hider"
$Hidescrollbar = GuiCreate( "Hide scrollbar",17,$i_SliderHeight,$i_SliderWidth-17,0,$WS_POPUP)
_SetParent( "Hide scrollbar", "Label Application" )
;~ GUISetBkColor(0xbf9ffa)
GUISetState(@SW_SHOW)
#endregion ; Scroll Bar "Hider"
;
_GUIScrollBars_Enable ($inside, $SB_VERT, False)
;
While 1
    Sleep(10)
Wend

Exit

;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;; Functions ;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;

Func OKPressed()
    For $i = 1 to 30
        _GUIScrollBars_SetPos ($inside, $SB_VERT,$i)
        Sleep(5)
    Next
EndFunc

Func CancelPressed()
    For $i = 30 to 0 Step -1
        _GUIScrollBars_SetPos ($inside, $SB_VERT,$i)
        Sleep(5)
    Next
EndFunc

Func SpecialEvents()
    Select
        Case @GUI_CTRLID = $GUI_EVENT_CLOSE
            Exit
        Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE
            MsgBox(0, "Window Minimized", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)
        Case @GUI_CTRLID = $GUI_EVENT_RESTORE
            MsgBox(0, "Window Restored", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)
    EndSelect
EndFunc

Func _SetParent($TitleP, $TitleC)
    If WinExists($TitleP) Then
        If WinExists($TitleC) Then
            $HwndP = WinGetHandle($TitleP)
            $HwndC = WinGetHandle($TitleC)
            $user32 = DllOpen("user32.dll")
            DllCall($user32, "str", "SetParent", "HWnd", $HwndP, "HWnd", $HwndC)
            DllClose( $user32 )
            Return 1
        Else
            Return -1
        EndIf
    Else
        Return -1
    EndIf
EndFunc   ;==>_SetParent
Edited by strate
INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...
Link to comment
Share on other sites

This should be the only line that needs changing to make it work.

$inside = GuiCreate( "GUI 1",$i_SliderWidth, $i_SliderHeight, 0, 0,BitOR($WS_CHILD,$WS_HSCROLL,$WS_VSCROLL), -1, $h_Main_GUI)   ; CREATE GUI 1

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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