Jump to content

How to drag the tabitem and change theirs indexs?


Recommended Posts

  • Moderators

powerofos,

Welcome to the AutoIt forum. :)

As far as I know you cannot drag tab headers like that in AutoIt, although martin has suggested a possible way to code a work-around here. ;)

And my GUIListViewEx UDF only allows you to drag rows in a ListView - nothing at all to do with tabs! ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

powerofos,

Welcome to the AutoIt forum. :)

As far as I know you cannot drag tab headers like that in AutoIt, although martin has suggested a possible way to code a work-around here. ;)

And my GUIListViewEx UDF only allows you to drag rows in a ListView - nothing at all to do with tabs! :D

M23

I see...thanks for your reply. I apreciate for your UDF-GUIListViewEx ;)

Kim.Y

Link to comment
Share on other sites

  • Moderators

Powerofos,

That was fun! :D

Here is a working script to allow you to drag tabs based on martin's suggestion in the link I posted above:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>
#include <StaticConstants.au3>

#include <Array.au3>

Global $aTab_Title[5] = ["Tab 0", "Tab  1", "Tab   2", "Tab    3", "Tab      4"]
Global $aTab_CID[5]
Global $aChild_GUI[5]
Global $aTab_Order[5] = [0, 1, 2, 3, 4]
Global $aTab_Block[4], $aTab_Coords[5]
Global $fTabbed = False

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

; Create tab
Global $hTab = GUICtrlCreateTab(5, 5,390, 290)
Global $hTab_Handle = GUICtrlGetHandle($hTab)

; Create Tab items and child GUIs
For $i = 0 To 4

    $aTab_CID[$i] = GUICtrlCreateTabItem ($aTab_Title[$i])

    $aChild_GUI[$i] = GUICreate($i, 350, 210, 20, 40, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
    ; Add label to show which GUI is displayed
    GUICtrlCreateLabel($i, 0, 0, 350, 210)
    GUICtrlSetFont(-1, 96)
    GUISetState(@SW_HIDE, $aChild_GUI[$i])
    ; Reset to main GUI
    GUISwitch($hGUI)

Next
GUICtrlCreateTabItem ("")

GUISetState(@SW_SHOW, $hGUI)

; Show GUI 0
WinSetState($aChild_GUI[0], "", @SW_SHOW)
$iLastGUI = 0

; Get coordinates of tab block
_Get_Tab_Coords()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hTab
            ; Set flag to show tab selected and not drag
            $fTabbed = True
            ; Which tab index?
            $iIndex = GUICtrlRead($hTab)
            ; Which GUI do we need to show
            $iGUI = $aTab_Order[$iIndex]
            ; Swap GUIs
            WinSetState($aChild_GUI[$iGUI], "", @SW_SHOW)
            WinSetState($aChild_GUI[$iLastGUI], "", @SW_HIDE)
            $iLastGUI = $iGUI
        Case $GUI_EVENT_PRIMARYDOWN
            ; If the press was a tab then ignore
            If $fTabbed Then
                $fTabbed = False
            Else
                ; Get tab
                $iCurr_Tab = GUICtrlRead($hTab)
                ; Use client coordinates
                $iOldOpt = Opt("MouseCoordMode", 2)
                ; Cretae the label to drag
                $hLabel = GUICtrlCreateLabel("", 0, 0, 10, 26, $SS_BLACKFRAME)
                GUICtrlSetState(-1, $GUI_HIDE)
                ; Allow dragging
                While 1
                    ; get mouse position
                    $aMPos = MouseGetPos()
                    ; If it is over the tab block
                    If $aMPos[0] > $aTab_Block[0] - 5 And $aMPos[0] < $aTab_Block[2] + 10 And $aMPos[1] > $aTab_Block[1] And $aMPos[1] < $aTab_Block[3] Then
                        ; Show the label
                        GUICtrlSetState($hLabel, $GUI_SHOW)
                        ; Move the label with the mouse
                        GUICtrlSetPos($hLabel, $aMPos[0] - 5, $aTab_Block[1] + 2)
                    EndIf
                    ; Wait until the mouse button ir released
                    If GUIGetMsg() = $GUI_EVENT_PRIMARYUP Then ExitLoop
                WEnd
                ; Get final position of label and delete it
                $aLabel_Pos = ControlGetPos($hGUI, "", $hLabel)
                GUICtrlDelete($hLabel)
                ; Check mouse was over the tab block
                If $aMPos[1] > $aTab_Block[1] And $aMPos[1] < $aTab_Block[3] Then
                    ; Now see which tab the label was over
                    Switch $aLabel_Pos[0]
                        Case $aTab_Block[0] To $aTab_Coords[0]
                            _Reset_Tabs($iCurr_Tab, 0)
                        Case $aTab_Coords[0] To $aTab_Coords[1]
                            _Reset_Tabs($iCurr_Tab, 1)
                        Case $aTab_Coords[1] To $aTab_Coords[2]
                            _Reset_Tabs($iCurr_Tab, 2)
                        Case $aTab_Coords[2] To $aTab_Coords[3]
                            _Reset_Tabs($iCurr_Tab, 3)
                        Case $aTab_Coords[3] To $aTab_Coords[4]
                            _Reset_Tabs($iCurr_Tab, 4)
                        Case $aTab_Coords[4] To $aTab_Coords[4] + 20
                            _Reset_Tabs($iCurr_Tab, 5)
                    EndSwitch
                    ; Reset the tab edge coordinates as the reordered tabs could be of different sizes
                    _Get_Tab_Coords()
                EndIf
                ; Reset normal mouse coords
                Opt("MouseCoordMode", $iOldOpt)
            EndIf
    EndSwitch

WEnd

Func _Reset_Tabs($iCurrTab, $iDropTab)

    ; Do nothing if tab moved to same place (on itself or next up)
    Switch $iCurrTab
        Case $iDropTab - 1 To $iDropTab
            Return
    EndSwitch
    ; Which real tab is moving
    $iMoving_Tab = $aTab_Order[$iCurrTab]
    ; Reset order of real tabs
    If $iDropTab < $iCurrTab Then
        ; Move tabs down
        For $i = $iCurrTab To $iDropTab + 1 Step -1
            ConsoleWrite($i & @CRLF)
            $aTab_Order[$i] = $aTab_Order[$i - 1]
        Next
        ; Insert current
        $aTab_Order[$iDropTab] = $iMoving_Tab
        ; Set focus to moved tab
        _GUICtrlTab_SetCurSel($hTab_Handle, $iDropTab)
        _GUICtrlTab_SetCurFocus($hTab_Handle, $iDropTab)
    Else
        ; Move tabs up
        For $i = $iCurrTab To $iDropTab - 2
            ConsoleWrite($i & @CRLF)
            $aTab_Order[$i] = $aTab_Order[$i + 1]
        Next
        ; Insert current
        $aTab_Order[$iDropTab - 1] = $iMoving_Tab
        ; Set focus to moved tab
        _GUICtrlTab_SetCurSel($hTab_Handle, $iDropTab - 1)
        _GUICtrlTab_SetCurFocus($hTab_Handle, $iDropTab - 1)
    EndIf
    ; Rename tabs
    For $i = 0 To 4
        GUICtrlSetData($aTab_CID[$i], $aTab_Title[$aTab_Order[$i]])
    Next

EndFunc

Func _Get_Tab_Coords()

    ; Get coords of tab rectangles
    $aTab_0_Pos = _GUICtrlTab_GetItemRect($hTab_Handle, 0)
    For $i = 1 To 4
        $aTab_Pos = _GUICtrlTab_GetItemRect($hTab_Handle, $i)
        ; Set coords for intertab joins
        $aTab_Coords[$i - 1] = $aTab_Pos[0]
    Next
    $aTab_Coords[4] = $aTab_Pos[2]
    ; Adjust tab 1 array to get tab block size
    $aTab_0_Pos[2] = $aTab_Pos[2]
    $aTab_Block = $aTab_0_Pos

EndFunc

A bit rough, but it works! ;)

You can only move the currently selected tab - select the tab first and then repress the mousebutton to start the drag. The tab is reinserted above the tab on which you have the drag box - or at the end if you go past the final tab. The various coordinates work for me - you may have to adjust them to match your particular theme. I hope you can use it as it is - I shall try to improve it when I have a spare moment over the next few days. ;)

Thanks again for the question - worked the little grey cells quite nicely! :D

M23

P.S. And credit to martin for the basic idea. :)

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Powerofos,

That was fun! :D

Here is a working script to allow you to drag tabs based on martin's suggestion in the link I posted above:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>
#include <StaticConstants.au3>

#include <Array.au3>

Global $aTab_Title[5] = ["Tab 0", "Tab  1", "Tab   2", "Tab    3", "Tab      4"]
Global $aTab_CID[5]
Global $aChild_GUI[5]
Global $aTab_Order[5] = [0, 1, 2, 3, 4]
Global $aTab_Block[4], $aTab_Coords[5]
Global $fTabbed = False

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

; Create tab
Global $hTab = GUICtrlCreateTab(5, 5,390, 290)
Global $hTab_Handle = GUICtrlGetHandle($hTab)

; Create Tab items and child GUIs
For $i = 0 To 4

    $aTab_CID[$i] = GUICtrlCreateTabItem ($aTab_Title[$i])

    $aChild_GUI[$i] = GUICreate($i, 350, 210, 20, 40, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
    ; Add label to show which GUI is displayed
    GUICtrlCreateLabel($i, 0, 0, 350, 210)
    GUICtrlSetFont(-1, 96)
    GUISetState(@SW_HIDE, $aChild_GUI[$i])
    ; Reset to main GUI
    GUISwitch($hGUI)

Next
GUICtrlCreateTabItem ("")

GUISetState(@SW_SHOW, $hGUI)

; Show GUI 0
WinSetState($aChild_GUI[0], "", @SW_SHOW)
$iLastGUI = 0

; Get coordinates of tab block
_Get_Tab_Coords()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hTab
            ; Set flag to show tab selected and not drag
            $fTabbed = True
            ; Which tab index?
            $iIndex = GUICtrlRead($hTab)
            ; Which GUI do we need to show
            $iGUI = $aTab_Order[$iIndex]
            ; Swap GUIs
            WinSetState($aChild_GUI[$iGUI], "", @SW_SHOW)
            WinSetState($aChild_GUI[$iLastGUI], "", @SW_HIDE)
            $iLastGUI = $iGUI
        Case $GUI_EVENT_PRIMARYDOWN
            ; If the press was a tab then ignore
            If $fTabbed Then
                $fTabbed = False
            Else
                ; Get tab
                $iCurr_Tab = GUICtrlRead($hTab)
                ; Use client coordinates
                $iOldOpt = Opt("MouseCoordMode", 2)
                ; Cretae the label to drag
                $hLabel = GUICtrlCreateLabel("", 0, 0, 10, 26, $SS_BLACKFRAME)
                GUICtrlSetState(-1, $GUI_HIDE)
                ; Allow dragging
                While 1
                    ; get mouse position
                    $aMPos = MouseGetPos()
                    ; If it is over the tab block
                    If $aMPos[0] > $aTab_Block[0] - 5 And $aMPos[0] < $aTab_Block[2] + 10 And $aMPos[1] > $aTab_Block[1] And $aMPos[1] < $aTab_Block[3] Then
                        ; Show the label
                        GUICtrlSetState($hLabel, $GUI_SHOW)
                        ; Move the label with the mouse
                        GUICtrlSetPos($hLabel, $aMPos[0] - 5, $aTab_Block[1] + 2)
                    EndIf
                    ; Wait until the mouse button ir released
                    If GUIGetMsg() = $GUI_EVENT_PRIMARYUP Then ExitLoop
                WEnd
                ; Get final position of label and delete it
                $aLabel_Pos = ControlGetPos($hGUI, "", $hLabel)
                GUICtrlDelete($hLabel)
                ; Check mouse was over the tab block
                If $aMPos[1] > $aTab_Block[1] And $aMPos[1] < $aTab_Block[3] Then
                    ; Now see which tab the label was over
                    Switch $aLabel_Pos[0]
                        Case $aTab_Block[0] To $aTab_Coords[0]
                            _Reset_Tabs($iCurr_Tab, 0)
                        Case $aTab_Coords[0] To $aTab_Coords[1]
                            _Reset_Tabs($iCurr_Tab, 1)
                        Case $aTab_Coords[1] To $aTab_Coords[2]
                            _Reset_Tabs($iCurr_Tab, 2)
                        Case $aTab_Coords[2] To $aTab_Coords[3]
                            _Reset_Tabs($iCurr_Tab, 3)
                        Case $aTab_Coords[3] To $aTab_Coords[4]
                            _Reset_Tabs($iCurr_Tab, 4)
                        Case $aTab_Coords[4] To $aTab_Coords[4] + 20
                            _Reset_Tabs($iCurr_Tab, 5)
                    EndSwitch
                    ; Reset the tab edge coordinates as the reordered tabs could be of different sizes
                    _Get_Tab_Coords()
                EndIf
                ; Reset normal mouse coords
                Opt("MouseCoordMode", $iOldOpt)
            EndIf
    EndSwitch

WEnd

Func _Reset_Tabs($iCurrTab, $iDropTab)

    ; Do nothing if tab moved to same place (on itself or next up)
    Switch $iCurrTab
        Case $iDropTab - 1 To $iDropTab
            Return
    EndSwitch
    ; Which real tab is moving
    $iMoving_Tab = $aTab_Order[$iCurrTab]
    ; Reset order of real tabs
    If $iDropTab < $iCurrTab Then
        ; Move tabs down
        For $i = $iCurrTab To $iDropTab + 1 Step -1
            ConsoleWrite($i & @CRLF)
            $aTab_Order[$i] = $aTab_Order[$i - 1]
        Next
        ; Insert current
        $aTab_Order[$iDropTab] = $iMoving_Tab
        ; Set focus to moved tab
        _GUICtrlTab_SetCurSel($hTab_Handle, $iDropTab)
        _GUICtrlTab_SetCurFocus($hTab_Handle, $iDropTab)
    Else
        ; Move tabs up
        For $i = $iCurrTab To $iDropTab - 2
            ConsoleWrite($i & @CRLF)
            $aTab_Order[$i] = $aTab_Order[$i + 1]
        Next
        ; Insert current
        $aTab_Order[$iDropTab - 1] = $iMoving_Tab
        ; Set focus to moved tab
        _GUICtrlTab_SetCurSel($hTab_Handle, $iDropTab - 1)
        _GUICtrlTab_SetCurFocus($hTab_Handle, $iDropTab - 1)
    EndIf
    ; Rename tabs
    For $i = 0 To 4
        GUICtrlSetData($aTab_CID[$i], $aTab_Title[$aTab_Order[$i]])
    Next

EndFunc

Func _Get_Tab_Coords()

    ; Get coords of tab rectangles
    $aTab_0_Pos = _GUICtrlTab_GetItemRect($hTab_Handle, 0)
    For $i = 1 To 4
        $aTab_Pos = _GUICtrlTab_GetItemRect($hTab_Handle, $i)
        ; Set coords for intertab joins
        $aTab_Coords[$i - 1] = $aTab_Pos[0]
    Next
    $aTab_Coords[4] = $aTab_Pos[2]
    ; Adjust tab 1 array to get tab block size
    $aTab_0_Pos[2] = $aTab_Pos[2]
    $aTab_Block = $aTab_0_Pos

EndFunc

A bit rough, but it works! :D

You can only move the currently selected tab - select the tab first and then repress the mousebutton to start the drag. The tab is reinserted above the tab on which you have the drag box - or at the end if you go past the final tab. The various coordinates work for me - you may have to adjust them to match your particular theme. I hope you can use it as it is - I shall try to improve it when I have a spare moment over the next few days. ;)

Thanks again for the question - worked the little grey cells quite nicely! :D

M23

P.S. And credit to martin for the basic idea. :)

Wow!!! That's what i am working for!!!

Thanks Martin,

Thanks M23, you just do me a favor!!!

;)

Kim.Y

Link to comment
Share on other sites

@melba23

I find it worrying when people actually try to do something that I suggest. What are they? Crazy or something?

I'm amazed that you actually got it to work. What are you? On drugs?

I prefer this slight variation. Once the mouse starts dragging it doesn't matter what the Y coord is, and the new position for the tab is more obvious to me.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>
#include <StaticConstants.au3>

#include <Array.au3>

Global $aTab_Title[5] = ["Tab 0", "Tab  1", "Tab   2", "Tab 3", "Tab    4"]
Global $aTab_CID[5]
Global $aChild_GUI[5]
Global $aTab_Order[5] = [0, 1, 2, 3, 4]
Global $aTab_Block[4], $aTab_Coords[5]
Global $fTabbed = False
Global $firstrun = True

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

; Create tab
Global $hTab = GUICtrlCreateTab(5, 5, 390, 290);, BitOR($GUI_SS_DEFAULT_TAB, $WS_CLIPSIBLINGS))
Global $hTab_Handle = GUICtrlGetHandle($hTab)

; Create Tab items and child GUIs
For $i = 0 To 4

    $aTab_CID[$i] = GUICtrlCreateTabItem($aTab_Title[$i])


    $aChild_GUI[$i] = GUICreate($i, 350, 210, 20, 40, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
    GUISetBkColor(0xffffff)
    ; Add label to show which GUI is displayed
    GUICtrlCreateLabel($i, 0, 0, 350, 210)
    GUICtrlSetFont(-1, 96)
    GUISetState(@SW_HIDE, $aChild_GUI[$i])
    ; Reset to main GUI
    GUISwitch($hGUI)

Next
GUICtrlCreateTabItem("")

GUISetState(@SW_SHOW, $hGUI)

; Show GUI 0
WinSetState($aChild_GUI[0], "", @SW_SHOW)
$iLastGUI = 0

; Get coordinates of tab block
_Get_Tab_Coords()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hTab
            ; Set flag to show tab selected and not drag
            $fTabbed = True
            ; Which tab index?
            $iIndex = GUICtrlRead($hTab)
            ; Which GUI do we need to show
            $iGUI = $aTab_Order[$iIndex]
            ; Swap GUIs
            WinSetState($aChild_GUI[$iGUI], "", @SW_SHOW)
            WinSetState($aChild_GUI[$iLastGUI], "", @SW_HIDE)
            $iLastGUI = $iGUI
        Case $GUI_EVENT_PRIMARYDOWN
            ; If the press was a tab then ignore
            If $fTabbed Then
                $fTabbed = False
            Else
                ; Get tab
                $iCurr_Tab = GUICtrlRead($hTab)
                ; Use client coordinates
                $iOldOpt = Opt("MouseCoordMode", 2)
                ; Cretae the label to drag
                ;$hLabel = GUICtrlCreateLabel("", 0, 0, 10, 26, $SS_BLACKFRAME)
                ;GUICtrlSetState(-1, $GUI_HIDE)
                $hLabel = GUICtrlCreateLabel("", 0, 0, 4, 18)
                GUICtrlSetBkColor(-1, 0xFF0000)
                GUICtrlSetState(-1, $GUI_HIDE)
                ; Allow dragging
                ;While 1
                $aMPos = GUIGetCursorInfo($hGUI)
                If $aMPos[0] > $aTab_Block[0] - 5 And $aMPos[0] < $aTab_Block[2] + 10 And $aMPos[1] > $aTab_Block[1] And $aMPos[1] < $aTab_Block[3] Then
                Do
                    ; get mouse position
                    $aMPos = GUIGetCursorInfo($hGUI);MouseGetPos()
                    ; If it is over the tab block
                    If $aMPos[0] > $aTab_Block[0] - 5 And $aMPos[0] < $aTab_Block[2] + 10 Then; And $aMPos[1] > $aTab_Block[1] And $aMPos[1] < $aTab_Block[3] Then
                        ; Show the label
                        $divpos = $aTab_Block[0]
                        If $aMPos[0] > $aTab_Block[2] Then
                            $divpos = $aTab_Block[2]
                        Else
                            For $tc = 3 To 0 Step -1
                                If $aMPos[0] > $aTab_Coords[$tc] Then
                                    $divpos = $aTab_Coords[$tc]
                                    ExitLoop
                                EndIf
                            Next
                        EndIf

                        GUICtrlSetState($hLabel, $GUI_SHOW)
                        ; Move the label with the mouse
                        GUICtrlSetPos($hLabel, $divpos+3, $aTab_Block[1] + 5);$aMPos[0] - 5
                    EndIf
                    ; Wait until the mouse button ir released
                    If GUIGetMsg() = $GUI_EVENT_PRIMARYUP Then ExitLoop
                    ;WEnd
                Until $aMPos[2] = 0
                EndIf
                ; Get final position of label and delete it
                $aLabel_Pos = ControlGetPos($hGUI, "", $hLabel)
                GUICtrlDelete($hLabel)
                ; Check mouse was over the tab block
                If $aMPos[1] > $aTab_Block[1] And $aMPos[1] < $aTab_Block[3] Then
                    ; Now see which tab the label was over
                    Switch $aLabel_Pos[0] + 10
                        Case $aTab_Block[0] To $aTab_Coords[0]
                            _Reset_Tabs($iCurr_Tab, 0)
                        Case $aTab_Coords[0] To $aTab_Coords[1]
                            _Reset_Tabs($iCurr_Tab, 1)
                        Case $aTab_Coords[1] To $aTab_Coords[2]
                            _Reset_Tabs($iCurr_Tab, 2)
                        Case $aTab_Coords[2] To $aTab_Coords[3]
                            _Reset_Tabs($iCurr_Tab, 3)
                        Case $aTab_Coords[3] To $aTab_Coords[4]
                            _Reset_Tabs($iCurr_Tab, 4)
                        Case $aTab_Coords[4] To $aTab_Coords[4] + 20
                            _Reset_Tabs($iCurr_Tab, 5)
                    EndSwitch
                    ; Reset the tab edge coordinates as the reordered tabs could be of different sizes
                    _Get_Tab_Coords()
                EndIf
                ; Reset normal mouse coords
                Opt("MouseCoordMode", $iOldOpt)
            EndIf
    EndSwitch

WEnd

Func _Reset_Tabs($iCurrTab, $iDropTab)

    ; Do nothing if tab moved to same place (on itself or next up)
    Switch $iCurrTab
        Case $iDropTab - 1 To $iDropTab
            Return
    EndSwitch
    ; Which real tab is moving
    $iMoving_Tab = $aTab_Order[$iCurrTab]
    ; Reset order of real tabs
    If $iDropTab < $iCurrTab Then
        ; Move tabs down
        For $i = $iCurrTab To $iDropTab + 1 Step -1
            ConsoleWrite($i & @CRLF)
            $aTab_Order[$i] = $aTab_Order[$i - 1]
        Next
        ; Insert current
        $aTab_Order[$iDropTab] = $iMoving_Tab
        ; Set focus to moved tab
        _GUICtrlTab_SetCurSel($hTab_Handle, $iDropTab)
        _GUICtrlTab_SetCurFocus($hTab_Handle, $iDropTab)
    Else
        ; Move tabs up
        For $i = $iCurrTab To $iDropTab - 2
            ConsoleWrite($i & @CRLF)
            $aTab_Order[$i] = $aTab_Order[$i + 1]
        Next
        ; Insert current
        $aTab_Order[$iDropTab - 1] = $iMoving_Tab
        ; Set focus to moved tab
        _GUICtrlTab_SetCurSel($hTab_Handle, $iDropTab - 1)
        _GUICtrlTab_SetCurFocus($hTab_Handle, $iDropTab - 1)
    EndIf
    ; Rename tabs
    For $i = 0 To 4
        GUICtrlSetData($aTab_CID[$i], $aTab_Title[$aTab_Order[$i]])
    Next

EndFunc   ;==>_Reset_Tabs

Func _Get_Tab_Coords()

    ; Get coords of tab rectangles
    $aTab_0_Pos = _GUICtrlTab_GetItemRect($hTab_Handle, 0)
    For $i = 1 To 4
        $aTab_Pos = _GUICtrlTab_GetItemRect($hTab_Handle, $i)
        ; Set coords for intertab joins
        $aTab_Coords[$i - 1] = $aTab_Pos[0]
    Next
    $aTab_Coords[4] = $aTab_Pos[2]
    ; Adjust tab 1 array to get tab block size
    $aTab_0_Pos[2] = $aTab_Pos[2]
    $aTab_Block = $aTab_0_Pos
 
EndFunc   ;==>_Get_Tab_Coords

I couldn't stopt the label flicker when it is between tabs, maybe you can work it out.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • Moderators

martin,

What are you?

Stubborn and obstinate when I want to do something! :D

On drugs?

Just a bottle of good red wine followed by a night's sleep. ;)

I like your changes (such as using GUIGetCursorInfo rather than changing the MouseCoordMode). Here is a slightly amended version with no (or at least very little) flicker:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>
#include <StaticConstants.au3>

#include <Array.au3>

; Set tab titles to different lengths
Global $aTab_Title[5] = ["Tab_0", "Tab__1", "Tab___2", "Tab____3", "Tab_____4"]
Global $aTab_CID[5], $aChild_GUI[5], $aTab_Block[4], $aTab_Coords[5], $aTab_Order[5] = [0, 1, 2, 3, 4]
Global $iDivider_Curr = -1

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

; Create tab
Global $hTab = GUICtrlCreateTab(5, 5, 390, 290)
Global $hTab_Handle = GUICtrlGetHandle($hTab)

; Create Tab items and child GUIs
For $i = 0 To 4

    $aTab_CID[$i] = GUICtrlCreateTabItem($aTab_Title[$i])

    $aChild_GUI[$i] = GUICreate($i, 350, 210, 20, 40, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
    GUISetBkColor(0xffffff)
    ; Add label to show which GUI is displayed
    GUICtrlCreateLabel($i, 0, 0, 350, 210)
    GUICtrlSetFont(-1, 96)
    GUISetState(@SW_HIDE, $aChild_GUI[$i])
    ; Reset to main GUI
    GUISwitch($hGUI)

Next
GUICtrlCreateTabItem("")

GUISetState(@SW_SHOW, $hGUI)

; Show GUI 0
WinSetState($aChild_GUI[0], "", @SW_SHOW)
$iLastGUI = 0

; Get coordinates of tab block
_Get_Tab_Coords()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hTab
            ; Determine correct GUI and sho w
            $iGUI = $aTab_Order[GUICtrlRead($hTab)]
            WinSetState($aChild_GUI[$iGUI], "", @SW_SHOW)
            WinSetState($aChild_GUI[$iLastGUI], "", @SW_HIDE)
            $iLastGUI = $iGUI
        Case $GUI_EVENT_PRIMARYDOWN
            $aCInfo = GUIGetCursorInfo($hGUI)
            If $aCInfo[4] = $hTab Then
                _Drag_Tab()
            EndIf
    EndSwitch

WEnd

Func _Drag_Tab()

    ; Get mouse position
    $aCInfo = GUIGetCursorInfo($hGUI)
    ; Return if not over the tab block
    If $aCInfo[0] < $aTab_Block[0] Or $aCInfo[0] > $aTab_Block[2] Or $aCInfo[1] < $aTab_Block[1] Or $aCInfo[1] > $aTab_Block[3] Then
        Return
    EndIf
    ; Get current tab
    $iCurr_Tab = GUICtrlRead($hTab)
    ; Create the label to indicate the new tab position
    $hLabel = GUICtrlCreateLabel("", 0, 0, 4, 18)
    GUICtrlSetBkColor(-1, 0xFF0000)
    GUICtrlSetState(-1, $GUI_HIDE)
    ; Allow drag position indication
    While 1
        ; Get mouse position
        $aCInfo = GUIGetCursorInfo($hGUI)
        ; If it is over the tab block
        If $aCInfo[0] > $aTab_Block[0] - 5 And $aCInfo[0] < $aTab_Block[2] + 10 And $aCInfo[1] > $aTab_Block[1] And $aCInfo[1] < $aTab_Block[3] Then
            ; Set divider postion based on mouse position
            Switch $aCInfo[0]
                Case 0 To $aTab_Coords[0]
                    $iDivider_X = 0
                Case $aTab_Coords[0] To $aTab_Coords[1]
                    $iDivider_X = $aTab_Coords[0]
                Case $aTab_Coords[1] To $aTab_Coords[2]
                    $iDivider_X = $aTab_Coords[1]
                Case $aTab_Coords[2] To $aTab_Coords[3]
                    $iDivider_X = $aTab_Coords[2]
                Case $aTab_Coords[3] To $aTab_Coords[4]
                    $iDivider_X = $aTab_Coords[3]
                Case $aTab_Coords[4] To 10000
                    $iDivider_X = $aTab_Block[2]
            EndSwitch
            ; If the position has changed or if the mouse is close to the boundary
            If $iDivider_X <> $iDivider_Curr Or $aCInfo[0] < $iDivider_X + 7 Then
                ; Move the label
                GUICtrlSetPos($hLabel, $iDivider_X + 3, $aTab_Block[1] + 5)
                ; Show the label - needed as when the tab changes focus it hides the label
                GUICtrlSetState($hLabel, $GUI_SHOW)
            EndIf
            ; Store current label position
            $iDivider_Curr = $iDivider_X
        EndIf
        ; Wait until the mouse button is released
        If GUIGetMsg() = $GUI_EVENT_PRIMARYUP Then ExitLoop
    WEnd
    ; Delete label
    GUICtrlDelete($hLabel)
    ; Check mouse was over the tab block
    If $aCInfo[1] > $aTab_Block[1] And $aCInfo[1] < $aTab_Block[3] Then
        ; Determine new position for tab
        Switch $iDivider_Curr
            Case 0
                _Reset_Tabs($iCurr_Tab, 0)
            Case $aTab_Coords[0]
                _Reset_Tabs($iCurr_Tab, 1)
            Case $aTab_Coords[1]
                _Reset_Tabs($iCurr_Tab, 2)
            Case $aTab_Coords[2]
                _Reset_Tabs($iCurr_Tab, 3)
            Case $aTab_Coords[3]
                _Reset_Tabs($iCurr_Tab, 4)
            Case $aTab_Coords[4]
                _Reset_Tabs($iCurr_Tab, 5)
        EndSwitch
        ; Reset the tab edge coordinates as the reordered tabs could be of different sizes
        _Get_Tab_Coords()
    EndIf

EndFunc

Func _Reset_Tabs($iCurrTab, $iDropTab)

    ; Do nothing if tab moved to same place (on itself or next up)
    Switch $iCurrTab
        Case $iDropTab - 1 To $iDropTab
            Return
    EndSwitch
    ; Which real tab is moving
    $iMoving_Tab = $aTab_Order[$iCurrTab]
    ; Reset order of real tabs
    If $iDropTab < $iCurrTab Then
        ; Move tabs down
        For $i = $iCurrTab To $iDropTab + 1 Step -1
            $aTab_Order[$i] = $aTab_Order[$i - 1]
        Next
        ; Insert current
        $aTab_Order[$iDropTab] = $iMoving_Tab
        ; Set focus to moved tab
        _GUICtrlTab_SetCurSel($hTab_Handle, $iDropTab)
        _GUICtrlTab_SetCurFocus($hTab_Handle, $iDropTab)
    Else
        ; Move tabs up
        For $i = $iCurrTab To $iDropTab - 2
            $aTab_Order[$i] = $aTab_Order[$i + 1]
        Next
        ; Insert current
        $aTab_Order[$iDropTab - 1] = $iMoving_Tab
        ; Set focus to moved tab
        _GUICtrlTab_SetCurSel($hTab_Handle, $iDropTab - 1)
        _GUICtrlTab_SetCurFocus($hTab_Handle, $iDropTab - 1)
    EndIf
    ; Rename tabs
    For $i = 0 To 4
        GUICtrlSetData($aTab_CID[$i], $aTab_Title[$aTab_Order[$i]])
    Next

EndFunc   ;==>_Reset_Tabs

Func _Get_Tab_Coords()

    ; Get coords of tab rectangles
    $aTab_0_Pos = _GUICtrlTab_GetItemRect($hTab_Handle, 0)
    For $i = 1 To 4
        $aTab_Pos = _GUICtrlTab_GetItemRect($hTab_Handle, $i)
        ; Set coords for intertab joins
        $aTab_Coords[$i - 1] = $aTab_Pos[0]
    Next
    $aTab_Coords[4] = $aTab_Pos[2]
    ; Adjust tab 1 array to get tab block size
    $aTab_0_Pos[2] = $aTab_Pos[2]
    $aTab_Block = $aTab_0_Pos

EndFunc   ;==>_Get_Tab_Coords

The trick was, as always, to only call the $GUI_SHOW when you need to. But I found that when the tab focus changed as you ran the mouse along the titles from left to right you needed to reshow the label or it was hidden - hence the rather peculiar conditions in the If statement around the $GUI_SHOW command. ;)

I think that is a good as I can get - thanks for the idea and the suggestions. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Defintely better.

The label doesn't flicker any more, but sometimes it disappears for me. I tried this variation and I couldn't get it to disappear. Reverted to your version and it would vanish again sometimes, so maybe it is a fix.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>
#include <StaticConstants.au3>
#include <APIConstants.au3>
#include <winapi.au3>
#include <Array.au3>

#include <constants.au3>

; Set tab titles to different lengths
Global $aTab_Title[5] = ["Tab_0", "Tab__1", "Tab___2", "Tab____3", "Tab_____4"]
Global $aTab_CID[5], $aChild_GUI[5], $aTab_Block[4], $aTab_Coords[5], $aTab_Order[5] = [0, 1, 2, 3, 4]
Global $iDivider_Curr = -1

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

; Create tab
Global $hTab = GUICtrlCreateTab(5, 5, 390, 290)
Global $hTab_Handle = GUICtrlGetHandle($hTab)

; Create Tab items and child GUIs
For $i = 0 To 4

    $aTab_CID[$i] = GUICtrlCreateTabItem($aTab_Title[$i])

    $aChild_GUI[$i] = GUICreate($i, 350, 210, 20, 40, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
    GUISetBkColor(0xffffff)
    ; Add label to show which GUI is displayed
    GUICtrlCreateLabel($i, 0, 0, 350, 210)
    GUICtrlSetFont(-1, 96)
    GUISetState(@SW_HIDE, $aChild_GUI[$i])
    ; Reset to main GUI
    GUISwitch($hGUI)

Next
GUICtrlCreateTabItem("")

GUISetState(@SW_SHOW, $hGUI)

; Show GUI 0
WinSetState($aChild_GUI[0], "", @SW_SHOW)
$iLastGUI = 0

; Get coordinates of tab block
_Get_Tab_Coords()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hTab
            ; Determine correct GUI and sho w
            $iGUI = $aTab_Order[GUICtrlRead($hTab)]
            WinSetState($aChild_GUI[$iGUI], "", @SW_SHOW)
            WinSetState($aChild_GUI[$iLastGUI], "", @SW_HIDE)
            $iLastGUI = $iGUI
        Case $GUI_EVENT_PRIMARYDOWN
            $aCInfo = GUIGetCursorInfo($hGUI)
            If $aCInfo[4] = $hTab Then
                _Drag_Tab()
            EndIf
    EndSwitch

WEnd

Func _Drag_Tab()

    ; Get mouse position
    $aCInfo = GUIGetCursorInfo($hGUI)
    ; Return if not over the tab block
    If $aCInfo[0] < $aTab_Block[0] Or $aCInfo[0] > $aTab_Block[2] Or $aCInfo[1] < $aTab_Block[1] Or $aCInfo[1] > $aTab_Block[3] Then
        Return
    EndIf
    ; Get current tab
    $iCurr_Tab = GUICtrlRead($hTab)
    ; Create the label to indicate the new tab position
    $hLabel = GUICtrlCreateLabel("", 0, 0, 4, 18)
    GUICtrlSetBkColor(-1, 0xFF0000)
    GUICtrlSetState(-1, $GUI_HIDE)
    ; Allow drag position indication
    While 1
        ; Get mouse position
        $aCInfo = GUIGetCursorInfo($hGUI)
        ; If it is over the tab block
        If $aCInfo[0] > $aTab_Block[0] - 5 And $aCInfo[0] < $aTab_Block[2] + 10 And $aCInfo[1] > $aTab_Block[1] And $aCInfo[1] < $aTab_Block[3] Then
            ; Set divider postion based on mouse position
            Switch $aCInfo[0]
                Case 0 To $aTab_Coords[0]
                    $iDivider_X = 0
                Case $aTab_Coords[0] To $aTab_Coords[1]
                    $iDivider_X = $aTab_Coords[0]
                Case $aTab_Coords[1] To $aTab_Coords[2]
                    $iDivider_X = $aTab_Coords[1]
                Case $aTab_Coords[2] To $aTab_Coords[3]
                    $iDivider_X = $aTab_Coords[2]
                Case $aTab_Coords[3] To $aTab_Coords[4]
                    $iDivider_X = $aTab_Coords[3]
                Case $aTab_Coords[4] To 10000
                    $iDivider_X = $aTab_Block[2]
            EndSwitch
            ; If the position has changed or if the mouse is close to the boundary
            If $iDivider_X <> $iDivider_Curr Or $aCInfo[0] < $iDivider_X + 7 Then
                ; Move the label
                GUICtrlSetPos($hLabel, $iDivider_X + 3, $aTab_Block[1] + 5)
                ; Show the label - needed as when the tab changes focus it hides the label
                ;GUICtrlSetState($hLabel, $GUI_SHOW);<---------------------replaced with next 2 lines
                $iFlags = BitOR($SWP_SHOWWINDOW, $SWP_NOSIZE, $SWP_NOMOVE)
            _WinAPI_SetWindowPos(GUICtrlGetHandle($hLabel), $HWND_TOP, 0, 0, 0, 0, $iFlags);
            EndIf
            ; Store current label position
            $iDivider_Curr = $iDivider_X
        EndIf
        ; Wait until the mouse button is released
        If GUIGetMsg() = $GUI_EVENT_PRIMARYUP Then ExitLoop
    WEnd
    ; Delete label
    GUICtrlDelete($hLabel)
    ; Check mouse was over the tab block
    If $aCInfo[1] > $aTab_Block[1] And $aCInfo[1] < $aTab_Block[3] Then
        ; Determine new position for tab
        Switch $iDivider_Curr
            Case 0
                _Reset_Tabs($iCurr_Tab, 0)
            Case $aTab_Coords[0]
                _Reset_Tabs($iCurr_Tab, 1)
            Case $aTab_Coords[1]
                _Reset_Tabs($iCurr_Tab, 2)
            Case $aTab_Coords[2]
                _Reset_Tabs($iCurr_Tab, 3)
            Case $aTab_Coords[3]
                _Reset_Tabs($iCurr_Tab, 4)
            Case $aTab_Coords[4]
                _Reset_Tabs($iCurr_Tab, 5)
        EndSwitch
        ; Reset the tab edge coordinates as the reordered tabs could be of different sizes
        _Get_Tab_Coords()
    EndIf

EndFunc

Func _Reset_Tabs($iCurrTab, $iDropTab)

    ; Do nothing if tab moved to same place (on itself or next up)
    Switch $iCurrTab
        Case $iDropTab - 1 To $iDropTab
            Return
    EndSwitch
    ; Which real tab is moving
    $iMoving_Tab = $aTab_Order[$iCurrTab]
    ; Reset order of real tabs
    If $iDropTab < $iCurrTab Then
        ; Move tabs down
        For $i = $iCurrTab To $iDropTab + 1 Step -1
            $aTab_Order[$i] = $aTab_Order[$i - 1]
        Next
        ; Insert current
        $aTab_Order[$iDropTab] = $iMoving_Tab
        ; Set focus to moved tab
        _GUICtrlTab_SetCurSel($hTab_Handle, $iDropTab)
        _GUICtrlTab_SetCurFocus($hTab_Handle, $iDropTab)
    Else
        ; Move tabs up
        For $i = $iCurrTab To $iDropTab - 2
            $aTab_Order[$i] = $aTab_Order[$i + 1]
        Next
        ; Insert current
        $aTab_Order[$iDropTab - 1] = $iMoving_Tab
        ; Set focus to moved tab
        _GUICtrlTab_SetCurSel($hTab_Handle, $iDropTab - 1)
        _GUICtrlTab_SetCurFocus($hTab_Handle, $iDropTab - 1)
    EndIf
    ; Rename tabs
    For $i = 0 To 4
        GUICtrlSetData($aTab_CID[$i], $aTab_Title[$aTab_Order[$i]])
    Next

EndFunc   ;==>_Reset_Tabs

Func _Get_Tab_Coords()

    ; Get coords of tab rectangles
    $aTab_0_Pos = _GUICtrlTab_GetItemRect($hTab_Handle, 0)
    For $i = 1 To 4
        $aTab_Pos = _GUICtrlTab_GetItemRect($hTab_Handle, $i)
        ; Set coords for intertab joins
        $aTab_Coords[$i - 1] = $aTab_Pos[0]
    Next
    $aTab_Coords[4] = $aTab_Pos[2]
    ; Adjust tab 1 array to get tab block size
    $aTab_0_Pos[2] = $aTab_Pos[2]
    $aTab_Block = $aTab_0_Pos

EndFunc   ;==>_Get_Tab_Coords
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • Moderators

martin,

Very nice. :)

My final effort for tonight (at least) - I tried using the $WS_EX_TOPMOST extended style when creating the label. Here are the relevant lines:

; Create the label to indicate the new tab position
$hLabel = GUICtrlCreateLabel("", 0, 0, 4, 18, Default, $WS_EX_TOPMOST)
GUICtrlSetBkColor(-1, 0xFF0000)
GUICtrlSetState(-1, $GUI_HIDE)


; If the position has changed
If $iDivider_X <> $iDivider_Curr Or $aCInfo[0] < $iDivider_X + 7 Then
    ; Move the label
    GUICtrlSetPos($hLabel, $iDivider_X + 3, $aTab_Block[1] + 5)
    ; Make sure label is visible - only really needed the first time
    GUICtrlSetState($hLabel, $GUI_SHOW)
EndIf

I get no flicker and no "hiding" and it is no longer necessary to look at the cursor position. Does it work for you? ;)

M23

Edit: You do need to check the cursor position if you move the mouse at anything other than a crawl - so I have put the check back in. ;)

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

martin,

Very nice. :)

My final effort for tonight (at least) - I tried using the $WS_EX_TOPMOST extended style when creating the label. Here are the relevant lines:

; Create the label to indicate the new tab position
$hLabel = GUICtrlCreateLabel("", 0, 0, 4, 18, Default, $WS_EX_TOPMOST)
GUICtrlSetBkColor(-1, 0xFF0000)
GUICtrlSetState(-1, $GUI_HIDE)


; If the position has changed
If $iDivider_X <> $iDivider_Curr Or $aCInfo[0] < $iDivider_X + 7 Then
    ; Move the label
    GUICtrlSetPos($hLabel, $iDivider_X + 3, $aTab_Block[1] + 5)
    ; Make sure label is visible - only really needed the first time
    GUICtrlSetState($hLabel, $GUI_SHOW)
EndIf

I get no flicker and no "hiding" and it is no longer necessary to look at the cursor position. Does it work for you? ;)

M23

Edit: You do need to check the cursor position if you move the mouse at anything other than a crawl - so I have put the check back in. ;)

With

$hLabel = GUICtrlCreateLabel("", 0, 0, 4, 18, Default, $WS_EX_TOPMOST)

the label still disappears for me just as before.Posted Image

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • Moderators

martin,

Best to stick with your idea then. What OS/theme are you running? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

martin,

Best to stick with your idea then. What OS/theme are you running? :)

M23

XP SP3. I haven't tried on W7.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...