Jump to content
Sign in to follow this  
Grasoft

Moving two Edits togather

Recommended Posts

Grasoft
Posted (edited)

Hi every one,

I wrote this code and I want both the edit boxes scroll vertically together.

I used the form v scroll does not help.

Then I grouped them together with  v scroll does not help.

Then inserted radios along side the group also does not help.

This is a sample code:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$TitleEdit = GUICreate("Title Editor", 1107, 691, 232, 75, BitOR($GUI_SS_DEFAULT_GUI,$WS_VSCROLL))
$Group1 = GUICtrlCreateGroup("Group1", 8, 40, 1081, 1500, BitOR($GUI_SS_DEFAULT_GROUP,$BS_CENTER,$BS_FLAT,$WS_TABSTOP,$WS_HSCROLL,$WS_VSCROLL,$WS_CLIPSIBLINGS))
GUIStartGroup()
$Edit1 = GUICtrlCreateEdit("", 16, 56, 50, 1450)
GUICtrlSetData(-1, StringFormat(" 1:\r\n 2:\r\n 3:\r\n 4:\r\n 5:\r\n 6:\r\n 7:\r\n 8:\r\n 9:\r\n10:\r\n11:\r\n12:\r\n13:\r\n14:\r\n15:\r\n16:\r\n17:\r\n18:\r\n19:\r\n20:\r\n21:\r\n22:\r\n23:\r\n24:\r\n25:\r\n26:\r\n27:\r\n28:\r\n29:\r\n30:\r\n31:\r\n32:\r\n33:\r\n34:\r\n35:\r\n36:\r\n37:\r\n38:\r\n39:\r\n40:\r\n41:\r\n42:\r\n43:\r\n44:\r\n45:\r\n46:\r\n47:\r\n48:\r\n49:\r\n50:\r\n51:\r\n52:\r\n53:\r\n54:\r\n55:\r\n56:\r\n57:\r\n58:\r\n59:\r\n60:\r\n61:\r\n62:\r\n63:\r\n64:\r\n65:\r\n66:\r\n67:\r\n68:\r\n69:\r\n70:"))
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Edit2 = GUICtrlCreateEdit("", 73, 56, 960, 1450)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Radio0 = GUICtrlCreateRadio("1", 1040, 100, 20, 17)
$Radio1 = GUICtrlCreateRadio("1", 1040, 208, 20, 17)
$Radio2 = GUICtrlCreateRadio("2", 1040, 300, 20, 17)
$Radio3 = GUICtrlCreateRadio("3", 1040, 400, 20, 17)
$Radio4 = GUICtrlCreateRadio("4", 1040, 500, 20, 17)
$Radio5 = GUICtrlCreateRadio("5", 1040, 600, 20, 17)
$Radio6 = GUICtrlCreateRadio("6", 1040, 700, 20, 17)
$Radio7 = GUICtrlCreateRadio("7", 1040, 800, 20, 17)
$Radio8 = GUICtrlCreateRadio("8", 1040, 900, 20, 17)
$Radio9 = GUICtrlCreateRadio("9", 1040, 1000, 20, 17)
$Radio10 = GUICtrlCreateRadio("10", 1040, 1100, 20, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)

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

    EndSwitch
WEnd

Any help??

Edited by Grasoft

Share this post


Link to post
Share on other sites
Bilgus
Posted (edited)

So first Checkout this UDF by Melba

That Being Said I took the Example from The Help File and Altered it to fit your needs

#include <GUIConstantsEx.au3>
#include <GuiScrollBars.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>

Global $hGuiResized = 0
Example()

Func Example()
    Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO)
    Local $iDwordSizing, $iClientX, $iClientY
    
    Local $idFileMenu, $idExititem, $hGUIMsg, $hGUI, $h_GUIC
    Local $idListview, $idButton
    Local $iHeightMax = 5000
    $hGUI = GUICreate("Title Editor", 1200, 700, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $hGuiResized = GUICtrlCreateDummy()
    $h_GUIC = GUICreate("", 1107, $iHeightMax, 0, 0, $WS_CHILD, $WS_EX_CLIENTEDGE, $hGUI)

    ;$TitleEdit = GUICreate("Title Editor", 1107, 691, 232, 75, BitOR($GUI_SS_DEFAULT_GUI,$WS_VSCROLL))
    Local $Group1 = GUICtrlCreateGroup("Group1", 8, 40, 1081, $iHeightMax, BitOR($GUI_SS_DEFAULT_GROUP, $BS_CENTER, $BS_FLAT, $WS_TABSTOP, $WS_CLIPSIBLINGS))
    GUIStartGroup()
    Local $Edit1 = GUICtrlCreateEdit("", 16, 56, 50, $iHeightMax, 0)
    GUICtrlSetData(-1, StringFormat(" 1:\r\n 2:\r\n 3:\r\n 4:\r\n 5:\r\n 6:\r\n 7:\r\n 8:\r\n 9:\r\n10:\r\n11:\r\n12:\r\n13:\r\n14:\r\n15:\r\n16:\r\n17:\r\n18:\r\n19:\r\n20:\r\n21:\r\n22:\r\n23:\r\n24:\r\n25:\r\n26:\r\n27:\r\n28:\r\n29:\r\n30:\r\n31:\r\n32:\r\n33:\r\n34:\r\n35:\r\n36:\r\n37:\r\n38:\r\n39:\r\n40:\r\n41:\r\n42:\r\n43:\r\n44:\r\n45:\r\n46:\r\n47:\r\n48:\r\n49:\r\n50:\r\n51:\r\n52:\r\n53:\r\n54:\r\n55:\r\n56:\r\n57:\r\n58:\r\n59:\r\n60:\r\n61:\r\n62:\r\n63:\r\n64:\r\n65:\r\n66:\r\n67:\r\n68:\r\n69:\r\n70:"))
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    Local $Edit2 = GUICtrlCreateEdit("", 73, 56, 960, $iHeightMax, 0)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    Local $Radio0 = GUICtrlCreateRadio("1", 1040, 100, 20, 17)
    Local $Radio1 = GUICtrlCreateRadio("1", 1040, 208, 20, 17)
    Local $Radio2 = GUICtrlCreateRadio("2", 1040, 300, 20, 17)
    Local $Radio3 = GUICtrlCreateRadio("3", 1040, 400, 20, 17)
    Local $Radio4 = GUICtrlCreateRadio("4", 1040, 500, 20, 17)
    Local $Radio5 = GUICtrlCreateRadio("5", 1040, 600, 20, 17)
    Local $Radio6 = GUICtrlCreateRadio("6", 1040, 700, 20, 17)
    Local $Radio7 = GUICtrlCreateRadio("7", 1040, 800, 20, 17)
    Local $Radio8 = GUICtrlCreateRadio("8", 1040, 900, 20, 17)
    Local $Radio9 = GUICtrlCreateRadio("9", 1040, 1000, 20, 17)
    Local $Radio10 = GUICtrlCreateRadio("10", 1040, 1100, 20, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)

    GUISetState(@SW_SHOW)
    GUICtrlSetResizing($h_GUIC, $GUI_DOCKALL)

    GUISwitch($hGUI)

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


    GUISetState(@SW_SHOW)
    _GUIScrollBars_Init($hGUI)
    Set_HScrollMax($hGUI, $iHeightMax)

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $hGuiResized
                ;This Isn't Quite Optimal really it should only reset the 
                ;Child Window X + HScroll Bar Pos if Parent Width changes
                ;and Y + VScroll if Height of the Parent Changes
                ;You could also set a minimum width/height for the child and have 
                ;it follow the parent down to that size and set up scrollbars after
                ;$iDwordSizing = GUICtrlRead ($hGuiResized)
                ;$iClientX = BitAND($iDwordSizing, 0x0000FFFF)
                ;$iClientY = BitShift($iDwordSizing, 16)
                WinMove($h_GUIC, "", 0, 0)
                DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
                DllStructSetData($tSCROLLINFO, "nPos", 0)
                _GUIScrollBars_SetScrollInfo($hGui, $SB_VERT, $tSCROLLINFO)
                _GUIScrollBars_SetScrollInfo($hGui, $SB_HORZ, $tSCROLLINFO)
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

Func Set_HScrollMax($hWnd, $iHeightMax)
    ;Set ClientMax Height to the full size of our child window
    ;You could do the same with width if you so desire
    Local $iIndex = -1, $iCharY, $iCharX, $iClientMaxX, $iClientX, $iClientY, $iMax
    For $x = 0 To UBound($__g_aSB_WindowInfo) - 1
        If $__g_aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $__g_aSB_WindowInfo[$iIndex][7] = $iHeightMax / $__g_aSB_WindowInfo[$iIndex][3]
            ExitLoop
        EndIf
    Next
    WM_SIZE($hWnd, 0, 0, 0)
EndFunc   ;==>Set_HScrollMax

Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam
    Local $iIndex = -1, $iCharY, $iCharX, $iClientMaxX, $iClientX, $iClientY, $iMax
    For $x = 0 To UBound($__g_aSB_WindowInfo) - 1
        If $__g_aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $iClientMaxX = $__g_aSB_WindowInfo[$iIndex][1]
            $iCharX = $__g_aSB_WindowInfo[$iIndex][2]
            $iCharY = $__g_aSB_WindowInfo[$iIndex][3]
            $iMax = $__g_aSB_WindowInfo[$iIndex][7]
            ExitLoop
        EndIf
    Next
    If $iIndex = -1 Then Return 0

    Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO)

    ; Retrieve the dimensions of the client area.
    $iClientX = BitAND($lParam, 0x0000FFFF)
    $iClientY = BitShift($lParam, 16)
    $__g_aSB_WindowInfo[$iIndex][4] = $iClientX
    $__g_aSB_WindowInfo[$iIndex][5] = $iClientY

    ; Set the vertical scrolling range and page size
    DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE))
    DllStructSetData($tSCROLLINFO, "nMin", 0)
    DllStructSetData($tSCROLLINFO, "nMax", $iMax)
    DllStructSetData($tSCROLLINFO, "nPage", $iClientY / $iCharY)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)

    ; Set the horizontal scrolling range and page size
    DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE))
    DllStructSetData($tSCROLLINFO, "nMin", 0)
    DllStructSetData($tSCROLLINFO, "nMax", 2 + $iClientMaxX / $iCharX)
    DllStructSetData($tSCROLLINFO, "nPage", $iClientX / $iCharX)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)
    GUICtrlSendToDummy($hGuiResized) ;Let our Gui Know when Resize is Finished
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE

Func WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $lParam
    Local $iScrollCode = BitAND($wParam, 0x0000FFFF)

    Local $iIndex = -1, $iCharX, $iPosX
    Local $iMin, $iMax, $iPage, $iPos, $iTrackPos

    For $x = 0 To UBound($__g_aSB_WindowInfo) - 1
        If $__g_aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $iCharX = $__g_aSB_WindowInfo[$iIndex][2]
            ExitLoop
        EndIf
    Next
    If $iIndex = -1 Then Return 0

    ; ; Get all the horizontal scroll bar information
    Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ)
    $iMin = DllStructGetData($tSCROLLINFO, "nMin")
    $iMax = DllStructGetData($tSCROLLINFO, "nMax")
    $iPage = DllStructGetData($tSCROLLINFO, "nPage")
    ; Save the position for comparison later on
    $iPosX = DllStructGetData($tSCROLLINFO, "nPos")
    $iPos = $iPosX
    $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")
    #forceref $iMin, $iMax
    Switch $iScrollCode

        Case $SB_LINELEFT ; user clicked left arrow
            DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1)

        Case $SB_LINERIGHT ; user clicked right arrow
            DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1)

        Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage)

        Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage)

        Case $SB_THUMBTRACK ; user dragged the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos)
    EndSwitch

    ; // Set the position and then retrieve it.  Due to adjustments
    ; //   by Windows it may not be the same as the value set.

    DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)
    _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)
    ;// If the position has changed, scroll the window and update it
    $iPos = DllStructGetData($tSCROLLINFO, "nPos")
    If ($iPos <> $iPosX) Then _GUIScrollBars_ScrollWindow($hWnd, $iCharX * ($iPosX - $iPos), 0)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_HSCROLL

Func WM_VSCROLL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam, $lParam
    Local $iScrollCode = BitAND($wParam, 0x0000FFFF)
    Local $iIndex = -1, $iCharY, $iPosY
    Local $iMin, $iMax, $iPage, $iPos, $iTrackPos

    For $x = 0 To UBound($__g_aSB_WindowInfo) - 1
        If $__g_aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $iCharY = $__g_aSB_WindowInfo[$iIndex][3]
            ExitLoop
        EndIf
    Next
    If $iIndex = -1 Then Return 0

    ; Get all the vertial scroll bar information
    Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)
    $iMin = DllStructGetData($tSCROLLINFO, "nMin")
    $iMax = DllStructGetData($tSCROLLINFO, "nMax")
    $iPage = DllStructGetData($tSCROLLINFO, "nPage")
    ; Save the position for comparison later on
    $iPosY = DllStructGetData($tSCROLLINFO, "nPos")
    $iPos = $iPosY
    $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")

    Switch $iScrollCode
        Case $SB_TOP ; user clicked the HOME keyboard key
            DllStructSetData($tSCROLLINFO, "nPos", $iMin)

        Case $SB_BOTTOM ; user clicked the END keyboard key
            DllStructSetData($tSCROLLINFO, "nPos", $iMax)

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

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

        Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage)

        Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage)

        Case $SB_THUMBTRACK ; user dragged the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos)
    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
    $iPos = DllStructGetData($tSCROLLINFO, "nPos")

    If ($iPos <> $iPosY) Then
        _GUIScrollBars_ScrollWindow($hWnd, 0, $iCharY * ($iPosY - $iPos))
        $iPosY = $iPos
    EndIf

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_VSCROLL

 

 

 

Edited by Bilgus
Added Comments
  • Thanks 1

Share this post


Link to post
Share on other sites
Grasoft

This is great, Even I don't need to group them,

@Bilgus :)Thanks a MILLION

 

Share this post


Link to post
Share on other sites
Bilgus

I just updated the code with a few comments and some resizing for the Child

Atm its not quite perfect really you should be storing the width and height and see if they change and only then reset the child position

+Scrollbars

You can see how the W/H are returned in the dummy control so at least you don't have to do anything for the final w/h but you'll need to store them 

  • Like 1

Share this post


Link to post
Share on other sites
Bilgus

Oops 

;GUICtrlSendToDummy($hGuiResized) ;Let our Gui Know when Resize is Finished
Needs to be...
GUICtrlSendToDummy($hGuiResized, $lParam) ;Let our Gui Know when Resize is Finished

 

  • Like 1

Share this post


Link to post
Share on other sites
Bilgus
Posted (edited)

Couple Other things It looks like if you get rid of the child Gui window and the group you can use

GUICtrlSetResizing() to make it scale properly with the window

That And... instead of that big long format line for line numbers replace it with something like this

For $i = 1 To 70
    $sLineNumbers &= $i & ":" & @CRLF
    Next
    GUICtrlSetData(-1, $sLineNumbers)

 

Edited by Bilgus
  • Like 1

Share this post


Link to post
Share on other sites
Grasoft

@Bilgus :) I really appreciate your help,

Thanks a gain

Share this post


Link to post
Share on other sites
Grasoft

I know this format

1 minute ago, Bilgus said:

Couple Other things It looks like if you get rid of the child Gui window and the group you can use

GUICtrlSetResizing() to make it scale properly with the window

Than And... instead of that big long format line for line numbers replace it with something like this

For $i = 1 To 70
    $sLineNumbers &= $i & ":" & @CRLF
    Next
    GUICtrlSetData(-1, $sLineNumbers)

 

Thanks a lot, I already know this formula and used it several times. As I used Koda I skipped this ftm.

Share this post


Link to post
Share on other sites
Grasoft

This is the code until Now:

#include <GUIConstantsEx.au3>
#include <GuiScrollBars.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
Global $hGuiResized = 0
Example()

Func Example()
    Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO)
    Local $iDwordSizing, $iClientX, $iClientY
    Local $idFileMenu, $idExititem, $hGUIMsg, $hGUI, $h_GUIC
    Local $idListview, $idButton
    Local $iHeightMax = 2040
    Local $sLineNumbers
    $hGUI = GUICreate("Title Editor", 1070, 700, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $hGuiResized = GUICtrlCreateDummy()
    $h_GUIC = GUICreate("", 1107, $iHeightMax, 0, 0, $WS_CHILD, $WS_EX_CLIENTEDGE, $hGUI)
    Local $EditLeft = GUICtrlCreateEdit("", 5, 55, 40, $iHeightMax, BitOR($ES_Right, $ES_READONLY, $ES_WANTRETURN))
    For $i = 1 To 99
        $sLineNumbers &= $i & ":" & @CRLF
    Next
    GUICtrlSetData(-1, $sLineNumbers)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    Local $EditRight = GUICtrlCreateEdit("", 1010, 55, 40, $iHeightMax, BitOR($ES_LEFT, $ES_READONLY, $ES_WANTRETURN))
    $sLineNumbers = ""
    For $i = 1 To 99
        $sLineNumbers &= ":" & $i & @CRLF
    Next
    GUICtrlSetData(-1, $sLineNumbers)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    Local $EditSec = GUICtrlCreateEdit("", 45, 55, 960, $iHeightMax, BitOR($ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_HSCROLL, $ES_NOHIDESEL))
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    GUICtrlSetResizing($h_GUIC, $GUI_DOCKALL)
    GUISwitch($hGUI)
    GUIRegisterMsg($WM_SIZE, "WM_SIZE")
    GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")
    GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL")
    GUISetState(@SW_SHOW)
    _GUIScrollBars_Init($hGUI)
    Set_HScrollMax($hGUI, $iHeightMax)

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $hGuiResized
                ;This Isn't Quite Optimal really it should only reset the
                ;Child Window X + HScroll Bar Pos if Parent Width changes
                ;and Y + VScroll if Height of the Parent Changes
                ;You could also set a minimum width/height for the child and have
                ;it follow the parent down to that size and set up scrollbars after
                ;$iDwordSizing = GUICtrlRead ($hGuiResized)
                ;$iClientX = BitAND($iDwordSizing, 0x0000FFFF)
                ;$iClientY = BitShift($iDwordSizing, 16)
                WinMove($h_GUIC, "", 0, 0)
                DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
                DllStructSetData($tSCROLLINFO, "nPos", 0)
                _GUIScrollBars_SetScrollInfo($hGUI, $SB_VERT, $tSCROLLINFO)
                _GUIScrollBars_SetScrollInfo($hGUI, $SB_HORZ, $tSCROLLINFO)
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

Func Set_HScrollMax($hWnd, $iHeightMax)
    ;Set ClientMax Height to the full size of our child window
    ;You could do the same with width if you so desire
    Local $iIndex = -1, $iCharY, $iCharX, $iClientMaxX, $iClientX, $iClientY, $iMax
    For $x = 0 To UBound($__g_aSB_WindowInfo) - 1
        If $__g_aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $__g_aSB_WindowInfo[$iIndex][7] = $iHeightMax / $__g_aSB_WindowInfo[$iIndex][3]
            ExitLoop
        EndIf
    Next
    WM_SIZE($hWnd, 0, 0, 0)
EndFunc   ;==>Set_HScrollMax

Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam
    Local $iIndex = -1, $iCharY, $iCharX, $iClientMaxX, $iClientX, $iClientY, $iMax
    For $x = 0 To UBound($__g_aSB_WindowInfo) - 1
        If $__g_aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $iClientMaxX = $__g_aSB_WindowInfo[$iIndex][1]
            $iCharX = $__g_aSB_WindowInfo[$iIndex][2]
            $iCharY = $__g_aSB_WindowInfo[$iIndex][3]
            $iMax = $__g_aSB_WindowInfo[$iIndex][7]
            ExitLoop
        EndIf
    Next
    If $iIndex = -1 Then Return 0

    Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO)

    ; Retrieve the dimensions of the client area.
    $iClientX = BitAND($lParam, 0x0000FFFF)
    $iClientY = BitShift($lParam, 16)
    $__g_aSB_WindowInfo[$iIndex][4] = $iClientX
    $__g_aSB_WindowInfo[$iIndex][5] = $iClientY

    ; Set the vertical scrolling range and page size
    DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE))
    DllStructSetData($tSCROLLINFO, "nMin", 0)
    DllStructSetData($tSCROLLINFO, "nMax", $iMax)
    DllStructSetData($tSCROLLINFO, "nPage", $iClientY / $iCharY)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)

    ; Set the horizontal scrolling range and page size
    DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE))
    DllStructSetData($tSCROLLINFO, "nMin", 0)
    DllStructSetData($tSCROLLINFO, "nMax", 2 + $iClientMaxX / $iCharX)
    DllStructSetData($tSCROLLINFO, "nPage", $iClientX / $iCharX)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)
    GUICtrlSendToDummy($hGuiResized, $lParam) ;Let our Gui Know when Resize is Finished
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE

Func WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $lParam
    Local $iScrollCode = BitAND($wParam, 0x0000FFFF)

    Local $iIndex = -1, $iCharX, $iPosX
    Local $iMin, $iMax, $iPage, $iPos, $iTrackPos

    For $x = 0 To UBound($__g_aSB_WindowInfo) - 1
        If $__g_aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $iCharX = $__g_aSB_WindowInfo[$iIndex][2]
            ExitLoop
        EndIf
    Next
    If $iIndex = -1 Then Return 0

    ; ; Get all the horizontal scroll bar information
    Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ)
    $iMin = DllStructGetData($tSCROLLINFO, "nMin")
    $iMax = DllStructGetData($tSCROLLINFO, "nMax")
    $iPage = DllStructGetData($tSCROLLINFO, "nPage")
    ; Save the position for comparison later on
    $iPosX = DllStructGetData($tSCROLLINFO, "nPos")
    $iPos = $iPosX
    $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")
    #forceref $iMin, $iMax
    Switch $iScrollCode

        Case $SB_LINELEFT ; user clicked left arrow
            DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1)

        Case $SB_LINERIGHT ; user clicked right arrow
            DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1)

        Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage)

        Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage)

        Case $SB_THUMBTRACK ; user dragged the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos)
    EndSwitch

    ; // Set the position and then retrieve it.  Due to adjustments
    ; //   by Windows it may not be the same as the value set.

    DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)
    _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)
    ;// If the position has changed, scroll the window and update it
    $iPos = DllStructGetData($tSCROLLINFO, "nPos")
    If ($iPos <> $iPosX) Then _GUIScrollBars_ScrollWindow($hWnd, $iCharX * ($iPosX - $iPos), 0)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_HSCROLL

Func WM_VSCROLL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam, $lParam
    Local $iScrollCode = BitAND($wParam, 0x0000FFFF)
    Local $iIndex = -1, $iCharY, $iPosY
    Local $iMin, $iMax, $iPage, $iPos, $iTrackPos

    For $x = 0 To UBound($__g_aSB_WindowInfo) - 1
        If $__g_aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $iCharY = $__g_aSB_WindowInfo[$iIndex][3]
            ExitLoop
        EndIf
    Next
    If $iIndex = -1 Then Return 0

    ; Get all the vertial scroll bar information
    Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)
    $iMin = DllStructGetData($tSCROLLINFO, "nMin")
    $iMax = DllStructGetData($tSCROLLINFO, "nMax")
    $iPage = DllStructGetData($tSCROLLINFO, "nPage")
    ; Save the position for comparison later on
    $iPosY = DllStructGetData($tSCROLLINFO, "nPos")
    $iPos = $iPosY
    $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")

    Switch $iScrollCode
        Case $SB_TOP ; user clicked the HOME keyboard key
            DllStructSetData($tSCROLLINFO, "nPos", $iMin)

        Case $SB_BOTTOM ; user clicked the END keyboard key
            DllStructSetData($tSCROLLINFO, "nPos", $iMax)

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

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

        Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage)

        Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage)

        Case $SB_THUMBTRACK ; user dragged the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos)
    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
    $iPos = DllStructGetData($tSCROLLINFO, "nPos")

    If ($iPos <> $iPosY) Then
        _GUIScrollBars_ScrollWindow($hWnd, 0, $iCharY * ($iPosY - $iPos))
        $iPosY = $iPos
    EndIf

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_VSCROLL

Any improvements??

Share this post


Link to post
Share on other sites
Bilgus
Posted (edited)

There Ya Go

#include <GUIConstantsEx.au3>
#include <GuiScrollBars.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <GuiEdit.au3>

Global $hGuiResized = 0
Example()

Func Example()
    Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO)
    Local $iDwordSizing, $iClientX;, $iClientY
    Local $idFileMenu, $idExititem, $hGUIMsg, $hGUI, $h_GUIC
    Local $idListview, $idButton
    Local $iHeightMax = 3000
    Local $iLastX;, $iLastY
    Local $sLineNumbers
    For $i = 1 To 99
        $sLineNumbers &= $i & ":" & @CRLF
    Next
    $hGUI = GUICreate("Title Editor", 1070, 700, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $hGuiResized = GUICtrlCreateDummy()

    $h_GUIC = GUICreate("", 1107, $iHeightMax, 0, 0, $WS_CHILD)
    GUICtrlSetResizing($h_GUIC, $GUI_DOCKALL)

    Local $EditLeft = GUICtrlCreateEdit($sLineNumbers, 5, 55, 40, $iHeightMax, BitOR($ES_Right, $ES_READONLY, $ES_WANTRETURN))
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")


    GUICtrlSetResizing($EditLeft, $GUI_DOCKSIZE + $GUI_DOCKTOP)

    Local $EditRight = GUICtrlCreateEdit($sLineNumbers, 1010, 55, 40, $iHeightMax, BitOR($ES_LEFT, $ES_READONLY, $ES_WANTRETURN))
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    GUICtrlSetResizing($EditRight, $GUI_DOCKSIZE + $GUI_DOCKTOP)

    Local $EditSec = GUICtrlCreateEdit("", 45, 55, 960, $iHeightMax, BitOR($ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_HSCROLL, $ES_NOHIDESEL))
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    GUICtrlSetResizing($EditSec, $GUI_DOCKBORDERS)

    GUISetState(@SW_SHOW)

    GUISwitch($hGUI)
    GUIRegisterMsg($WM_SIZE, "WM_SIZE")
    GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")
    GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL")
    GUISetState(@SW_SHOW)
    _GUIScrollBars_Init($hGUI)
    Set_HScrollMax($hGUI, $iHeightMax)

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $hGuiResized
                $iDwordSizing = GUICtrlRead($hGuiResized)
                $iClientX = BitAND($iDwordSizing, 0x0000FFFF)
                ;$iClientY = BitShift($iDwordSizing, 16)

                DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
                DllStructSetData($tSCROLLINFO, "nPos", 0)
                If $iLastX <> $iClientX Then
                    $iLastX = $iClientX
                    _GUIScrollBars_SetScrollInfo($hGUI, $SB_HORZ, $tSCROLLINFO)
                EndIf
                _GUIScrollBars_SetScrollInfo($hGUI, $SB_VERT, $tSCROLLINFO)

                If $iClientX > 0 Then WinMove($h_GUIC, "", 0, 0, $iClientX, $iHeightMax)
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

Func Set_HScrollMax($hWnd, $iHeightMax)
    ;Set ClientMax Height to the full size of our child window
    ;You could do the same with width if you so desire
    Local $iIndex = -1, $iCharY, $iCharX, $iClientMaxX, $iClientX, $iClientY, $iMax
    For $x = 0 To UBound($__g_aSB_WindowInfo) - 1
        If $__g_aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $__g_aSB_WindowInfo[$iIndex][7] = $iHeightMax / $__g_aSB_WindowInfo[$iIndex][3]
            ExitLoop
        EndIf
    Next
    WM_SIZE($hWnd, 0, 0, 0)
EndFunc   ;==>Set_HScrollMax

Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam
    Local $iIndex = -1, $iCharY, $iCharX, $iClientMaxX, $iClientX, $iClientY, $iMax
    For $x = 0 To UBound($__g_aSB_WindowInfo) - 1
        If $__g_aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $iClientMaxX = $__g_aSB_WindowInfo[$iIndex][1]
            $iCharX = $__g_aSB_WindowInfo[$iIndex][2]
            $iCharY = $__g_aSB_WindowInfo[$iIndex][3]
            $iMax = $__g_aSB_WindowInfo[$iIndex][7]
            ExitLoop
        EndIf
    Next
    If $iIndex = -1 Then Return 0

    Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO)

    ; Retrieve the dimensions of the client area.
    $iClientX = BitAND($lParam, 0x0000FFFF)
    $iClientY = BitShift($lParam, 16)
    $__g_aSB_WindowInfo[$iIndex][4] = $iClientX
    $__g_aSB_WindowInfo[$iIndex][5] = $iClientY

    ; Set the vertical scrolling range and page size
    DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE))
    DllStructSetData($tSCROLLINFO, "nMin", 0)
    DllStructSetData($tSCROLLINFO, "nMax", $iMax)
    DllStructSetData($tSCROLLINFO, "nPage", $iClientY / $iCharY)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)

    ; Set the horizontal scrolling range and page size
    DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE))
    DllStructSetData($tSCROLLINFO, "nMin", 0)
    DllStructSetData($tSCROLLINFO, "nMax", 2 + $iClientMaxX / $iCharX)
    DllStructSetData($tSCROLLINFO, "nPage", $iClientX / $iCharX)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)
    GUICtrlSendToDummy($hGuiResized, $lParam) ;Let our Gui Know when Resize is Finished
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE

Func WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $lParam
    Local $iScrollCode = BitAND($wParam, 0x0000FFFF)

    Local $iIndex = -1, $iCharX, $iPosX
    Local $iMin, $iMax, $iPage, $iPos, $iTrackPos

    For $x = 0 To UBound($__g_aSB_WindowInfo) - 1
        If $__g_aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $iCharX = $__g_aSB_WindowInfo[$iIndex][2]
            ExitLoop
        EndIf
    Next
    If $iIndex = -1 Then Return 0

    ; ; Get all the horizontal scroll bar information
    Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ)
    $iMin = DllStructGetData($tSCROLLINFO, "nMin")
    $iMax = DllStructGetData($tSCROLLINFO, "nMax")
    $iPage = DllStructGetData($tSCROLLINFO, "nPage")
    ; Save the position for comparison later on
    $iPosX = DllStructGetData($tSCROLLINFO, "nPos")
    $iPos = $iPosX
    $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")
    #forceref $iMin, $iMax
    Switch $iScrollCode

        Case $SB_LINELEFT ; user clicked left arrow
            DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1)

        Case $SB_LINERIGHT ; user clicked right arrow
            DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1)

        Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage)

        Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage)

        Case $SB_THUMBTRACK ; user dragged the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos)
    EndSwitch

    ; // Set the position and then retrieve it.  Due to adjustments
    ; //   by Windows it may not be the same as the value set.

    DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)
    _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)
    ;// If the position has changed, scroll the window and update it
    $iPos = DllStructGetData($tSCROLLINFO, "nPos")
    If ($iPos <> $iPosX) Then _GUIScrollBars_ScrollWindow($hWnd, $iCharX * ($iPosX - $iPos), 0)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_HSCROLL

Func WM_VSCROLL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam, $lParam
    Local $iScrollCode = BitAND($wParam, 0x0000FFFF)
    Local $iIndex = -1, $iCharY, $iPosY
    Local $iMin, $iMax, $iPage, $iPos, $iTrackPos

    For $x = 0 To UBound($__g_aSB_WindowInfo) - 1
        If $__g_aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $iCharY = $__g_aSB_WindowInfo[$iIndex][3]
            ExitLoop
        EndIf
    Next
    If $iIndex = -1 Then Return 0

    ; Get all the vertial scroll bar information
    Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)
    $iMin = DllStructGetData($tSCROLLINFO, "nMin")
    $iMax = DllStructGetData($tSCROLLINFO, "nMax")
    $iPage = DllStructGetData($tSCROLLINFO, "nPage")
    ; Save the position for comparison later on
    $iPosY = DllStructGetData($tSCROLLINFO, "nPos")
    $iPos = $iPosY
    $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")

    Switch $iScrollCode
        Case $SB_TOP ; user clicked the HOME keyboard key
            DllStructSetData($tSCROLLINFO, "nPos", $iMin)

        Case $SB_BOTTOM ; user clicked the END keyboard key
            DllStructSetData($tSCROLLINFO, "nPos", $iMax)

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

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

        Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage)

        Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage)

        Case $SB_THUMBTRACK ; user dragged the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos)
    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
    $iPos = DllStructGetData($tSCROLLINFO, "nPos")

    If ($iPos <> $iPosY) Then
        _GUIScrollBars_ScrollWindow($hWnd, 0, $iCharY * ($iPosY - $iPos))
        $iPosY = $iPos
    EndIf

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_VSCROLL

 

Edited by Bilgus
  • Thanks 1

Share this post


Link to post
Share on other sites
Grasoft

@Bilgus Thanks MUCH:thumbsup:

  • Like 1

Share this post


Link to post
Share on other sites
Grasoft
Posted (edited)

Added it to my QuickReplies app and worked like charm.

:thumbsup:Thaaaanks to @Bilgus and Thaaaanks to @Melba23

for the included UDF

Edited by Grasoft

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  

  • Similar Content

    • rudi
      By rudi
      Hello,
       
      from this posting of @Jos https://www.autoitscript.com/forum/topic/162005-getting-windows-users-account-type/?do=findComment&comment=1176831
      I can smoothly check, if a user is a *DIRECT* group member. Has anybody some code to check also, if a user is a *INDIRECT* member of a cascaded group construct?  Maybe with @Melba23 's AD UDF?
       
      The required rights are granted to group "Dept_B" User John is member of group "Dept_A" Group "Dept_A" is member of the group "Dept_B" So in the AD / NTFS FS environment John finally has the rights of both groups But when checking his "membership to group Dept_B" the result is "no member". The approach I can think of would be, to check all Group Members of group "Dept_B" whether they are of type group, then check again if "John" is member of than " 2nd level group"
      Func UserInGroup($InGroup,$ThisUser=@LogonDomain & "/" & @UserName) Local $objUser = ObjGet("WinNT://" & $ThisUser ) For $oGroup in $objUser.Groups If $oGroup.Name = $InGroup Then Return 1 EndIf Next Return 0 EndFunc Any suggestions appreciated, regards, Rudi.
    • Trolleule
      By Trolleule
      Hi,
      i want to display a tooltip when i hover over the listview group. It sounds not difficult but i couldn't find a solution and i searched for autoit as well as for c# :/
      So i came up with a not so pretty solution:
      #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <GuiToolTip.au3> #include <WinAPI.au3> Global $idListview, $hWndListView Global $hToolTip = _GUIToolTip_Create(0, BitOR($_TT_ghTTDefaultStyle, $TTS_BALLOON)); balloon style tooltip Global Const $LVN_GROUPINFO = ($LVN_FIRST - 88) Global Const $tagNMLVGROUP = $tagNMHDR & ";int iGroupId;uint iNewState;uint iOldState" ; $LVGS_flags $LVGS_flags Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tInfo, $tNMHDR = DllStructCreate($tagNMHDR, $lParam), $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) Local $iIDFrom = DllStructGetData($tNMHDR, "IDFrom"), $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode ; Case $of?????? ; A Group was clicked <---- I need help with this Case $LVN_GROUPINFO ConsoleWrite("hier" & @CRLF) $tInfo = DllStructCreate($tagNMLVGROUP, $lParam) _DebugPrint("$LVN_GROUPINFO" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->GroupId:" & @TAB & DllStructGetData($tInfo, "iGroupId") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "iNewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "iOldState")) Case $LVN_COLUMNCLICK ; A column was clicked $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) _DebugPrint("$LVN_COLUMNCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ "-->Param:" & @TAB & DllStructGetData($tInfo, "Param")) ; No return value Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _ "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags")) ; No return value EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber) ConsoleWrite( _ "!===========================================================" & @CRLF & _ "+======================================================" & @CRLF & _ "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _ "+======================================================" & @CRLF) EndFunc ;==>_DebugPrint If Not StringInStr($CmdLineRaw, "/ErrorStdOut") Then Exit MsgBox($MB_TOPMOST, @ScriptName, 'please run from the editor, thanks', 10) Example() Func Example() Local $aInfo, $hImage, $idListview $ghui = GUICreate("ListView Group COLLAPSIBLE", 400, 300) $idListview = GUICtrlCreateListView("", 30, 20, 354, 218);, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_REPORT, $WS_CLIPSIBLINGS)) $hWndListView = GUICtrlGetHandle($idListview) ; Load images $hImage = _GUIImageList_Create() _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16)) _GUICtrlListView_SetImageList($idListview, $hImage, 1) ; Add columns _GUICtrlListView_AddColumn($idListview, "Column 1", 100) _GUICtrlListView_AddColumn($idListview, "Column 2", 100) _GUICtrlListView_AddColumn($idListview, "Column 3", 100) ; Add items _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0) _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1) _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2) _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1) _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1) _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2) ; Build groups _GUICtrlListView_EnableGroupView($idListview) _GUICtrlListView_InsertGroup($idListview, -1, 1, "Group 1", 1) ;~ _GUICtrlListView_SetGroupInfo($idListview, 1, "Group 1", 0, $LVGS_COLLAPSIBLE + $LVGS_COLLAPSED) ; <--- _GUICtrlListView_InsertGroup($idListview, -1, 2, "Group 2") ;~ _GUICtrlListView_SetGroupInfo($idListview, 2, "Group 2", 0, $LVGS_COLLAPSIBLE + $LVGS_COLLAPSED) ; <--- _GUICtrlListView_SetItemGroupID($idListview, 0, 1) _GUICtrlListView_SetItemGroupID($idListview, 1, 2) _GUICtrlListView_SetItemGroupID($idListview, 2, 2) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") Local $apos = _GUICtrlListView_GetGroupRect($idListview, 2, $LVGGR_LABEL) Local $test = GUICtrlCreateLabel("a", 2, 2, 10, 17) Local $val = _WinAPI_GetWindowLong(GUICtrlGetHandle($test), $GWL_STYLE) Local $valex = _WinAPI_GetWindowLong(GUICtrlGetHandle($test), $GWL_EXSTYLE) Local $aha = _WinAPI_CreateWindowEx($valex+$WS_EX_LAYERED, "static", "blabla", $val, $apos[0], $apos[1], 50, 20, $hWndListView) _GUIToolTip_AddTool($hToolTip, $hWndListView, "This is a ToolTip3", $aha) GUISetState(@SW_SHOW) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Short description: I only created a label with CreateWindowEx which i can append to the listview control and layered it with the $WS_EX_Layered flag so it looks like it's transparent. Then i only added a tooltip tool to that created label.
      Hover over the Group 2 text and the Tooltip will be displayed. My question is: does someone know another perhaps much prettier solution?
      Thanks in advance
    • MrCreatoR
      By MrCreatoR
      Name: GroupCheckBox
      Description: Allows to create and manage group checkboxes.
      AutoIt: 3.3.6.1 - 3.3.12.0
       
      Example:
      Download:  GroupCheckBox.zip
    • goss34
      By goss34
      Hi Guys,
      Im having a bit of trouble with the AD UDF - I know its me and not the UDF but i thought i had this working well until i introduced a domain check before my function. It appears at that point my domain check is ignoring my commands and always going with the domain of the currently logged on user ut i dont know why. Here is my code:
      #include <File.au3> #include <MsgBoxConstants.au3> #include <AD.au3> Global $sFQDN_User, $Groups, $sUserIdParam, $sPasswordParam, $sDNSDomainParam, $sHostServerParam, $sConfigurationParam FileWrite(@ScriptDir & "\TestGroups.txt", "SoftwareInstaller-All" & @CRLF) FileWrite(@ScriptDir & "\TestGroups.txt", "SoftwareInstaller-ProfServ" & @CRLF) FileWrite(@ScriptDir & "\TestGroups.txt", "SoftwareInstaller-Sales" & @CRLF) DetectAD() Func DetectAD() If @LogonDNSDomain = "Domain.one.two" Then ADCheckOT() ElseIf @LogonDNSDomain = "Domain.three" Then ADCheckT() EndIf EndFunc ; Syntax.........: _AD_Open([$sUserIdParam = "", $sPasswordParam = ""[, $sDNSDomainParam = "", $sHostServerParam = "", $sConfigurationParam = ""[, $iSecurity = 0]]]) Func ADCheckOT() _AD_Open($sUserIdParam = "", $sPasswordParam = "", $sDNSDomainParam = "DC=domain,DC=one,DC=two", $sHostServerParam = "", $sConfigurationParam = "") ;Then ; Get the Fully Qualified Domain Name (FQDN) for the current user $sFQDN_User = _AD_SamAccountNameToFQDN() _FileReadToArray(@ScriptDir & "\TestGroups.txt", $Groups) For $i = 1 To $Groups[0] $sFQDN_Group = $Groups[$i] ; Check the group membership of the specified user for the specified group $iResult = _AD_IsMemberOf($sFQDN_Group, $sFQDN_User) Select Case $iResult = 1 If $sFQDN_Group = "SoftwareInstaller-All" Then MsgBox(0,"","SoftwareInstaller-All") ElseIf $sFQDN_Group = "SoftwareInstaller-ProfServ" Then MsgBox(0,"","SoftwareInstaller-ProfServ") ElseIf $sFQDN_Group = "SoftwareInstaller-Sales" Then MsgBox(0,"","SoftwareInstaller-Sales") EndIf EndSelect Next _AD_Close() EndFunc Func ADCheckT() _AD_Open($sUserIdParam = "", $sPasswordParam = "", $sDNSDomainParam = "DC=domain,DC=three", $sHostServerParam = "", $sConfigurationParam = "") ;Then ; Get the Fully Qualified Domain Name (FQDN) for the current user $sFQDN_User = _AD_SamAccountNameToFQDN() _FileReadToArray(@ScriptDir & "\TestGroups.txt", $Groups) For $i = 1 To $Groups[0] $sFQDN_Group = $Groups[$i] ; Check the group membership of the specified user for the specified group $iResult = _AD_IsMemberOf($sFQDN_Group, $sFQDN_User) Select Case $iResult = 1 If $sFQDN_Group = "SoftwareInstaller-All" Then MsgBox(0,"","SoftwareInstaller-All") ElseIf $sFQDN_Group = "SoftwareInstaller-ProfServ" Then MsgBox(0,"","SoftwareInstaller-ProfServ") ElseIf $sFQDN_Group = "SoftwareInstaller-Sales" Then MsgBox(0,"","SoftwareInstaller-Sales") EndIf EndSelect Next _AD_Close() EndFunc FileDelete(@ScriptDir & "\TestGroups.txt") Im pretty sure i dont understand the syntax, I dont want to specify a username or password i just want to specify which domain to check as i should be able to query groups this without having to authenticate. 
      The idea is that the script will check which domain they are on first, then connect to the correct domain to check group membership, if they are in 1 of the groups then another function will run - replaced with MsgBoxs for the reproducer.
      Can someone point me in the right direction?
      Thanks
×