Jump to content

Recommended Posts

Posted

I was looking at something like this a couple of days back and found this (a post by you) and now you release this, awesome! Thanks.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Very good, but if i am a “less experienced user”, then i will have a difficulties to save all these scripts to correct files and make it work. Why you guys don't post an attached zip-file with all needed UDFs/Examples, so lazy users as my self could just download the archive, unpack it and check the great stuff you have there :idea:

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

  • Moderators
Posted

MrCreatoR,

  Quote

post an attached zip-file

Done - see first post. :idea:

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:

  Reveal hidden contents

 

Posted
  Quote

Done - see first post

Thank you!

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

  • Moderators
Posted

Hi,

I realised that there was not a really simple example to show how easy GUIScrollbars_Ex is to use - so here it is:

#include <GUIConstantsEx.au3>
#include <GUIScrollbars_Ex.au3>

; Create GUI with red background
$hGUI = GUICreate("Test", 500, 500)
GUISetBkColor(0xFF0000, $hGUI)

; Create a 1000x1000 green label
GUICtrlCreateLabel("", 0, 0, 1000, 1000)
GUICtrlSetBkColor(-1, 0x00FF00)

GUISetState()

; Generate scrollbars - yes this is all you have to do!!!!!!!!!!!!!!
_GUIScrollbars_Generate($hGUI, 1000, 1000)

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

WEnd

I have added it to the zip above and amended the first post. :idea:

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:

  Reveal hidden contents

 

Posted

  Quote

I realised that there was not a really simple example to show how easy GUIScrollbars_Ex is to use - so here it is:

Nice, but i think that you can make more usefull example. Many users need the scrollable GUI for the settings window, so this window could include more options in one place (reachable by the scroll).

Here is the example:

#include <GUIConstantsEx.au3>
#include <GUIScrollbars_Ex.au3>

; Create GUI
$hGUI = GUICreate("_GUIScrollbars_Generate Demo", 500, 500)

$iTop = 20

For $i = 1 To 100
    GUICtrlCreateCheckbox("Option " & $i & "-a", 20, $iTop)
    GUICtrlCreateCheckbox("Option " & $i & "-b", 500, $iTop)
    
    $iTop += 20
Next

; Generate scrollbars
_GUIScrollbars_Generate($hGUI, 600, $iTop)

GUISetState()

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

P.S

I have one small(?) feature request: Add an ability to scroll the window by mouse wheel.

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

  • Moderators
Posted

MrCreatoR,

  Quote

Add an ability to scroll the window by mouse wheel

I have never been able to get my mouse to scroll an AutoIt scrollbar. And yes I have tried your MouseOnEvent UDF. :idea: Everything works except the scroll wheel.

So if you would like to work at it, be my guest. :)

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:

  Reveal hidden contents

 

Posted

Hi Melba,

I'm drawing custom window, at least the title bar is custom. However I'm unable to make the scrollbars ignore the top region and only scroll an area beneath it.

#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>
#include <Constants.au3>
#include <WinApi.au3>
#include <GUIScrollBars.au3>
#include <ScrollBarConstants.au3>

#include "../GUIScrollbars_Size.au3"


Global Const $SC_DRAGMOVE = 0xF012
Opt("MouseCoordMode", 2)

Local $tMsg
Opt("TrayMenuMode", 1)

$frmMain = GUICreate("frmMain", 333, 441, -1, -1, $WS_POPUP, 0)
GUISetState(@SW_SHOW)
GUISetBkColor(0xe9eff5, $frmMain)

; Scrollbars
$aRet = _GUIScrollbars_Size(0, 500, 1, 441)
GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL")

_GUIScrollBars_Init($frmMain)
_GUIScrollBars_ShowScrollBar($frmMain, $SB_VERT, True)
_GUIScrollBars_ShowScrollBar($frmMain, $SB_HORZ, False)
_GUIScrollBars_SetScrollInfoPage($frmMain, $SB_VERT, $aRet[2])
_GUIScrollBars_SetScrollInfoMax($frmMain, $SB_VERT, $aRet[3])

$rgn = _WinAPI_CreateRoundRectRgn(0, 0, 333, 441, 3, 3)
_WinAPI_SetWindowRgn($frmMain, $rgn)
DrawBar()

While 1
    $tMsg = TrayGetMsg()
    Switch $tMsg
        Case $TRAY_EVENT_PRIMARYDOWN
            GUISetState(@SW_SHOW)
            DrawBar()
            WinSetState("frmMain", "", @SW_RESTORE)
            Opt("TrayIconHide", 1)
    EndSwitch

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_PRIMARYDOWN
            $mPos = MouseGetPos()
            If $mPos[1] <= 20 Then
                If $mPos[0] >= 295 And $mPos[0] <= 316 Then
                    GUISetState(@SW_HIDE)
                    Opt("TrayIconHide", 0)
                ElseIf $mPos[0] >= 313 And $mPos[0] <= 322 Then
                    Exit
                Else
                    _SendMessage($frmMain, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
                EndIf
            EndIf
    EndSwitch
WEnd

Func DrawBar()
    Local $aDim = WinGetClientSize($frmMain)
    Local $hDC = _WinAPI_GetDC($frmMain)
    ; Bar
    Local $hBrush = _WinAPI_CreateSolidBrush(0xf5d997) ; 0x97d9f5
    Local $hRect = DllStructCreate($tagRECT)
    DllStructSetData($hRect, "Left", 0)
    DllStructSetData($hRect, "Top", 0)
    DllStructSetData($hRect, "Right", $aDim[0])
    DllStructSetData($hRect, "Bottom", 20)
    _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)
    _WinAPI_DeleteObject($hBrush)
    ; Bar text
    Local $sTitle = WinGetTitle($frmMain)
    Local $hBrush = _WinAPI_CreateSolidBrush(0x000000) ; 0xe9eff5
    DllStructSetData($hRect, "Left", 4)
    DllStructSetData($hRect, "Top", 2)
    DllStructSetData($hRect, "Right", $aDim[0] - 40)
    DllStructSetData($hRect, "Bottom", 20)
    _WinAPI_SetBkMode($hDC, $TRANSPARENT)
    _WinAPI_SetTextColor($hDC, 0xFFFFFF)
    _WinAPI_DrawText($hDC, $sTitle, $hRect, $DT_LEFT)
    _WinAPI_DeleteObject($hBrush)
    ; Minimize
    $hBrush = _WinAPI_CreateSolidBrush(0x000000)
    DllStructSetData($hRect, "Left", $aDim[0] - 37)
    DllStructSetData($hRect, "Top", 12)
    DllStructSetData($hRect, "Right", $aDim[0] - 28)
    DllStructSetData($hRect, "Bottom", 14)
    _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)
    _WinAPI_DeleteObject($hBrush)
    ; Close
    Local $hPen = _WinAPI_CreatePen($PS_SOLID, 2, 0x000000)
    Local $hSelected = _WinAPI_SelectObject($hDC, $hPen)
    _WinAPI_DrawLine($hDC, $aDim[0] - 20, 5, $aDim[0] - 11, 14)
    _WinAPI_DrawLine($hDC, $aDim[0] - 20, 14, $aDim[0] - 11, 5)
    _WinAPI_SelectObject($hDC, $hSelected)
    _WinAPI_DeleteObject($hPen)
    $hBrush = _WinAPI_CreateSolidBrush(0xd8ded3)
    ; Frame Edge
    ;$hBrush = _WinAPI_CreateSolidBrush(0x000000)
    DllStructSetData($hRect, "Left", 0)
    DllStructSetData($hRect, "Top", 20)
    DllStructSetData($hRect, "Right", 1)
    DllStructSetData($hRect, "Bottom", 1)
    _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)
    DllStructSetData($hRect, "Left", $aDim[0] - 2)
    DllStructSetData($hRect, "Top", 20)
    DllStructSetData($hRect, "Right", $aDim[0])
    DllStructSetData($hRect, "Bottom", $aDim[1])
    _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)
    DllStructSetData($hRect, "Left", 0)
    DllStructSetData($hRect, "Top", 20)
    DllStructSetData($hRect, "Right", 1)
    DllStructSetData($hRect, "Bottom", $aDim[1])
    _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)
    DllStructSetData($hRect, "Left", 0)
    DllStructSetData($hRect, "Top", $aDim[1] - 2)
    DllStructSetData($hRect, "Right", $aDim[0])
    DllStructSetData($hRect, "Bottom", $aDim[1])
    _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)
    _WinAPI_DeleteObject($hBrush)
    _WinAPI_ReleaseDC($frmMain, $hDC)
    AdlibRegister("DrawBar")
EndFunc   ;==>DrawBar

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

    #forceref $Msg, $wParam, $lParam
    Local $nScrollCode = BitAND($wParam, 0x0000FFFF)
    Local $iIndex = -1, $yChar, $yPos
    Local $Min, $Max, $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)
    $Min = DllStructGetData($tSCROLLINFO, "nMin")
    $Max = DllStructGetData($tSCROLLINFO, "nMax")
    $Page = DllStructGetData($tSCROLLINFO, "nPage")
    $yPos = DllStructGetData($tSCROLLINFO, "nPos")
    $Pos = $yPos
    $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")

    Switch $nScrollCode
        Case $SB_TOP
            DllStructSetData($tSCROLLINFO, "nPos", $Min)
        Case $SB_BOTTOM
            DllStructSetData($tSCROLLINFO, "nPos", $Max)
        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)

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

    Return $GUI_RUNDEFMSG

EndFunc   ;==>_Scrollbars_WM_VSCROLL

James

  • Moderators
Posted

james,

As far as I know Windows draws the scrollbars to fill the client area - which is what is happening here. :)

However, nothing is impossible: :(

#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>
#include <Constants.au3>
#include <WinApi.au3>
#include <GUIScrollBars.au3>
#include <ScrollBarConstants.au3>

#include <GUIScrollbars_Size.au3>


Global Const $SC_DRAGMOVE = 0xF012
Opt("MouseCoordMode", 2)

Local $tMsg
Opt("TrayMenuMode", 1)

$frmMain = GUICreate("frmMain", 333, 421, -1, -1, $WS_POPUP, 0)
GUISetState(@SW_SHOW)
GUISetBkColor(0xe9eff5, $frmMain)

$frmBar = GUICreate("frmBar", 333, 20, -1, -1, $WS_POPUP, 0)
GUISetState(@SW_SHOW)

$aPos = WinGetPos($frmMain)
WinMove($frmBar, "", $aPos[0], $aPos[1] - 20)

GUIRegisterMsg($WM_MOVE, "StickTogether")

; Scrollbars
$aRet = _GUIScrollbars_Size(0, 500, 1, 441)
GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL")

_GUIScrollBars_Init($frmMain)
_GUIScrollBars_ShowScrollBar($frmMain, $SB_VERT, True)
_GUIScrollBars_ShowScrollBar($frmMain, $SB_HORZ, False)
_GUIScrollBars_SetScrollInfoPage($frmMain, $SB_VERT, $aRet[2])
_GUIScrollBars_SetScrollInfoMax($frmMain, $SB_VERT, $aRet[3])

$rgn = _WinAPI_CreateRoundRectRgn(0, 0, 333, 441, 3, 3)
_WinAPI_SetWindowRgn($frmMain, $rgn)
DrawBar()

While 1
    $tMsg = TrayGetMsg()
    Switch $tMsg
        Case $TRAY_EVENT_PRIMARYDOWN
            GUISetState(@SW_SHOW)
            DrawBar()
            WinSetState("frmMain", "", @SW_RESTORE)
            Opt("TrayIconHide", 1)
    EndSwitch

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_PRIMARYDOWN
            $mPos = MouseGetPos()
            If $mPos[1] <= 20 Then
                If $mPos[0] >= 295 And $mPos[0] <= 316 Then
                    GUISetState(@SW_HIDE)
                    Opt("TrayIconHide", 0)
                ElseIf $mPos[0] >= 313 And $mPos[0] <= 322 Then
                    Exit
                Else
                    _SendMessage($frmBar, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
                EndIf
            EndIf
    EndSwitch
WEnd

Func StickTogether($hWnd, $iMsg, $wParam, $lParam)

    #forceref $iMsg, $wParam, $lParam

    Switch $hWnd
        Case $frmBar
            Local $aPos = WinGetPos($frmBar)
            WinMove($frmMain, "", $aPos[0], $aPos[1] + 20)
    EndSwitch

EndFunc

Func DrawBar()
    Local $aDim = WinGetClientSize($frmBar)
    Local $hDC = _WinAPI_GetDC($frmBar)
    ; Bar
    Local $hBrush = _WinAPI_CreateSolidBrush(0xf5d997) ; 0x97d9f5
    Local $hRect = DllStructCreate($tagRECT)
    DllStructSetData($hRect, "Left", 0)
    DllStructSetData($hRect, "Top", 0)
    DllStructSetData($hRect, "Right", $aDim[0])
    DllStructSetData($hRect, "Bottom", 20)
    _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)
    _WinAPI_DeleteObject($hBrush)
    ; Bar text
    Local $sTitle = WinGetTitle($frmBar)
    Local $hBrush = _WinAPI_CreateSolidBrush(0x000000) ; 0xe9eff5
    DllStructSetData($hRect, "Left", 4)
    DllStructSetData($hRect, "Top", 2)
    DllStructSetData($hRect, "Right", $aDim[0] - 40)
    DllStructSetData($hRect, "Bottom", 20)
    _WinAPI_SetBkMode($hDC, $TRANSPARENT)
    _WinAPI_SetTextColor($hDC, 0xFFFFFF)
    _WinAPI_DrawText($hDC, $sTitle, $hRect, $DT_LEFT)
    _WinAPI_DeleteObject($hBrush)
    ; Minimize
    $hBrush = _WinAPI_CreateSolidBrush(0x000000)
    DllStructSetData($hRect, "Left", $aDim[0] - 37)
    DllStructSetData($hRect, "Top", 12)
    DllStructSetData($hRect, "Right", $aDim[0] - 28)
    DllStructSetData($hRect, "Bottom", 14)
    _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)
    _WinAPI_DeleteObject($hBrush)
    ; Close
    Local $hPen = _WinAPI_CreatePen($PS_SOLID, 2, 0x000000)
    Local $hSelected = _WinAPI_SelectObject($hDC, $hPen)
    _WinAPI_DrawLine($hDC, $aDim[0] - 20, 5, $aDim[0] - 11, 14)
    _WinAPI_DrawLine($hDC, $aDim[0] - 20, 14, $aDim[0] - 11, 5)
    _WinAPI_SelectObject($hDC, $hSelected)
    _WinAPI_DeleteObject($hPen)
    $hBrush = _WinAPI_CreateSolidBrush(0xd8ded3)
    ; Frame Edge
    ;$hBrush = _WinAPI_CreateSolidBrush(0x000000)
    DllStructSetData($hRect, "Left", 0)
    DllStructSetData($hRect, "Top", 20)
    DllStructSetData($hRect, "Right", 1)
    DllStructSetData($hRect, "Bottom", 1)
    _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)
    DllStructSetData($hRect, "Left", $aDim[0] - 2)
    DllStructSetData($hRect, "Top", 20)
    DllStructSetData($hRect, "Right", $aDim[0])
    DllStructSetData($hRect, "Bottom", $aDim[1])
    _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)
    DllStructSetData($hRect, "Left", 0)
    DllStructSetData($hRect, "Top", 20)
    DllStructSetData($hRect, "Right", 1)
    DllStructSetData($hRect, "Bottom", $aDim[1])
    _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)
    DllStructSetData($hRect, "Left", 0)
    DllStructSetData($hRect, "Top", $aDim[1] - 2)
    DllStructSetData($hRect, "Right", $aDim[0])
    DllStructSetData($hRect, "Bottom", $aDim[1])
    _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)
    _WinAPI_DeleteObject($hBrush)
    _WinAPI_ReleaseDC($frmBar, $hDC)
    AdlibRegister("DrawBar")
EndFunc   ;==>DrawBar

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

    #forceref $Msg, $wParam, $lParam
    Local $nScrollCode = BitAND($wParam, 0x0000FFFF)
    Local $iIndex = -1, $yChar, $yPos
    Local $Min, $Max, $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)
    $Min = DllStructGetData($tSCROLLINFO, "nMin")
    $Max = DllStructGetData($tSCROLLINFO, "nMax")
    $Page = DllStructGetData($tSCROLLINFO, "nPage")
    $yPos = DllStructGetData($tSCROLLINFO, "nPos")
    $Pos = $yPos
    $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")

    Switch $nScrollCode
        Case $SB_TOP
            DllStructSetData($tSCROLLINFO, "nPos", $Min)
        Case $SB_BOTTOM
            DllStructSetData($tSCROLLINFO, "nPos", $Max)
        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)

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

    Return $GUI_RUNDEFMSG

EndFunc   ;==>_Scrollbars_WM_VSCROLL

You work out how I did it! :idea:

M23

P.S. There is some work to do still, I have only done the bare minimum. After all it is nothing to do with my UDF! :)

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:

  Reveal hidden contents

 

  • Moderators
Posted

James,

"dirty"? :idea:

"Inspired lateral thinking" would be my preferred comment! :)

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:

  Reveal hidden contents

 

Posted

Any reason not to make the content window an MDI child (WS_EX_MDICHILD)? Then moving the window takes care of itself. Here's an example. You might have to play with the window placement slightly, but it looks pretty good.

#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>
#include <Constants.au3>
#include <WinApi.au3>
#include <GUIScrollBars.au3>
#include <ScrollBarConstants.au3>

#include <GUIScrollbars_Size.au3>


Global Const $SC_DRAGMOVE = 0xF012
Opt("MouseCoordMode", 2)

Local $tMsg
Opt("TrayMenuMode", 1)

$frmBar = GUICreate("frmBar", 333, 441, -1, -1, $WS_POPUP, 0)
GUISetState(@SW_SHOW)

$frmMain = GUICreate("frmMain", 333, 421, 4, 24, $WS_POPUP, $WS_EX_MDICHILD, $frmBar)
GUISetState(@SW_SHOW)

; Scrollbars
$aRet = _GUIScrollbars_Size(0, 500, 1, 441)
GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL")

_GUIScrollBars_Init($frmMain)
_GUIScrollBars_ShowScrollBar($frmMain, $SB_VERT, True)
_GUIScrollBars_ShowScrollBar($frmMain, $SB_HORZ, False)
_GUIScrollBars_SetScrollInfoPage($frmMain, $SB_VERT, $aRet[2])
_GUIScrollBars_SetScrollInfoMax($frmMain, $SB_VERT, $aRet[3])

$rgn = _WinAPI_CreateRoundRectRgn(0, 0, 333, 441, 3, 3)
_WinAPI_SetWindowRgn($frmMain, $rgn)
DrawBar()

While 1
    $tMsg = TrayGetMsg()
    Switch $tMsg
        Case $TRAY_EVENT_PRIMARYDOWN
            GUISetState(@SW_SHOW, $frmBar)
            GUISetState(@SW_SHOW, $frmMain)
            WinActivate($frmBar)
            DrawBar()
            Opt("TrayIconHide", 1)
    EndSwitch

    $nMsg = GUIGetMsg(1)
    Switch $nMsg[1] ; window
        Case $frmBar
            Switch $nMsg[0] ; event ID
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $GUI_EVENT_PRIMARYDOWN
                    If $nMsg[4] <= 20 Then
                        If $nMsg[3] >= 295 And $nMsg[3] <= 316 Then
                            GUISetState(@SW_HIDE, $frmMain)
                            GUISetState(@SW_HIDE, $frmBar)
                            Opt("TrayIconHide", 0)
                        ElseIf $nMsg[3] >= 313 And $nMsg[3] <= 322 Then
                            Exit
                        Else
                            _SendMessage($frmBar, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
                        EndIf
                    EndIf
            EndSwitch
    EndSwitch
WEnd

Func DrawBar()
    Local $aDim = WinGetClientSize($frmBar)
    Local $hDC = _WinAPI_GetDC($frmBar)
    ; Bar
    Local $hBrush = _WinAPI_CreateSolidBrush(0xf5d997) ; 0x97d9f5
    Local $hRect = DllStructCreate($tagRECT)
    DllStructSetData($hRect, "Left", 0)
    DllStructSetData($hRect, "Top", 0)
    DllStructSetData($hRect, "Right", $aDim[0])
    DllStructSetData($hRect, "Bottom", 20)
    _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)
    _WinAPI_DeleteObject($hBrush)
    ; Bar text
    Local $sTitle = WinGetTitle($frmBar)
    Local $hBrush = _WinAPI_CreateSolidBrush(0x000000) ; 0xe9eff5
    DllStructSetData($hRect, "Left", 4)
    DllStructSetData($hRect, "Top", 2)
    DllStructSetData($hRect, "Right", $aDim[0] - 40)
    DllStructSetData($hRect, "Bottom", 20)
    _WinAPI_SetBkMode($hDC, $TRANSPARENT)
    _WinAPI_SetTextColor($hDC, 0xFFFFFF)
    _WinAPI_DrawText($hDC, $sTitle, $hRect, $DT_LEFT)
    _WinAPI_DeleteObject($hBrush)
    ; Minimize
    $hBrush = _WinAPI_CreateSolidBrush(0x000000)
    DllStructSetData($hRect, "Left", $aDim[0] - 37)
    DllStructSetData($hRect, "Top", 12)
    DllStructSetData($hRect, "Right", $aDim[0] - 28)
    DllStructSetData($hRect, "Bottom", 14)
    _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)
    _WinAPI_DeleteObject($hBrush)
    ; Close
    Local $hPen = _WinAPI_CreatePen($PS_SOLID, 2, 0x000000)
    Local $hSelected = _WinAPI_SelectObject($hDC, $hPen)
    _WinAPI_DrawLine($hDC, $aDim[0] - 20, 5, $aDim[0] - 11, 14)
    _WinAPI_DrawLine($hDC, $aDim[0] - 20, 14, $aDim[0] - 11, 5)
    _WinAPI_SelectObject($hDC, $hSelected)
    _WinAPI_DeleteObject($hPen)
    $hBrush = _WinAPI_CreateSolidBrush(0xd8ded3)
    ; Frame Edge
    ;$hBrush = _WinAPI_CreateSolidBrush(0x000000)
    DllStructSetData($hRect, "Left", 0)
    DllStructSetData($hRect, "Top", 20)
    DllStructSetData($hRect, "Right", 1)
    DllStructSetData($hRect, "Bottom", 1)
    _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)
    DllStructSetData($hRect, "Left", $aDim[0] - 2)
    DllStructSetData($hRect, "Top", 20)
    DllStructSetData($hRect, "Right", $aDim[0])
    DllStructSetData($hRect, "Bottom", $aDim[1])
    _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)
    DllStructSetData($hRect, "Left", 0)
    DllStructSetData($hRect, "Top", 20)
    DllStructSetData($hRect, "Right", 1)
    DllStructSetData($hRect, "Bottom", $aDim[1])
    _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)
    DllStructSetData($hRect, "Left", 0)
    DllStructSetData($hRect, "Top", $aDim[1] - 2)
    DllStructSetData($hRect, "Right", $aDim[0])
    DllStructSetData($hRect, "Bottom", $aDim[1])
    _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)
    _WinAPI_DeleteObject($hBrush)
    _WinAPI_ReleaseDC($frmBar, $hDC)
    AdlibRegister("DrawBar")
EndFunc   ;==>DrawBar

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

    #forceref $Msg, $wParam, $lParam
    Local $nScrollCode = BitAND($wParam, 0x0000FFFF)
    Local $iIndex = -1, $yChar, $yPos
    Local $Min, $Max, $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)
    $Min = DllStructGetData($tSCROLLINFO, "nMin")
    $Max = DllStructGetData($tSCROLLINFO, "nMax")
    $Page = DllStructGetData($tSCROLLINFO, "nPage")
    $yPos = DllStructGetData($tSCROLLINFO, "nPos")
    $Pos = $yPos
    $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")

    Switch $nScrollCode
        Case $SB_TOP
            DllStructSetData($tSCROLLINFO, "nPos", $Min)
        Case $SB_BOTTOM
            DllStructSetData($tSCROLLINFO, "nPos", $Max)
        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)

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

    Return $GUI_RUNDEFMSG

EndFunc   ;==>_Scrollbars_WM_VSCROLL
  • Moderators
Posted

wraithdu,

I like a multi-brain solution to a problem! :idea:

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:

  Reveal hidden contents

 

Posted

  On 4/30/2010 at 6:09 PM, 'JamesBrooks said:

Posted Image

Two windows, one for title bar and one for client area? What were you inspired by, crack? :idea:

James

One of my favorite tricks for solving many GUI problems is to use multiple windows. It can save me having to create multiple controls for example and in some cases I even change the text for a button when a window is shown and then change it back when that Window is hidden and the original Child restored.

George

  Reveal hidden contents
Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Posted

  On 4/30/2010 at 4:28 PM, 'Melba23 said:

MrCreatoR,

I have never been able to get my mouse to scroll an AutoIt scrollbar. And yes I have tried your MouseOnEvent UDF. :idea: Everything works except the scroll wheel.

So if you would like to work at it, be my guest. :)

M23

It's easy, you just add this to the UDF:

#include <SendMessage.au3>

....

GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL")

....

Func WM_MOUSEWHEEL($hWnd, $nMsg, $wParam, $lParam)
    Local $nKeys = BitAnd($wParam, 0x0000FFFF)
    Local $nDistance = BitShift($wParam, 16)
    
    If $nDistance > 0 Then
        _SendMessage($hWnd, $WM_VSCROLL, $SB_LINEUP, 0)
    Else
        _SendMessage($hWnd, $WM_VSCROLL, $SB_LINEDOWN, 0)
    EndIf
EndFunc

At least for the vertical scroll this is usefull.

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

And this one will enable the horizontal scroll by holding Shift or Ctrl key:

Func _Scrollbars_WM_MOUSEWHEEL($hWnd, $nMsg, $wParam, $lParam)
    Local $nKeys = BitAND($wParam, 0x0000FFFF)
    Local $nDistance = BitShift($wParam, 16)
    
    If $nKeys = 0 Then
        If $nDistance > 0 Then
            _SendMessage($hWnd, $WM_VSCROLL, $SB_LINEUP, 0)
        Else
            _SendMessage($hWnd, $WM_VSCROLL, $SB_LINEDOWN, 0)
        EndIf
    Else
        If $nDistance > 0 Then
            _SendMessage($hWnd, $WM_HSCROLL, $SB_LINELEFT, 0)
        Else
            _SendMessage($hWnd, $WM_HSCROLL, $SB_LINERIGHT, 0)
        EndIf
    EndIf
EndFunc

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...