Jump to content

Recommended Posts

I'm having a little trouble with a GDI arrow i'm using in a script I'm playing with.

It worked fine before~

#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>

#Include <WinAPIEx.au3>
#include <Array.au3>
#include <gdiplus.au3>
#include <GuiTab.au3>

Global Const $tagSCNotification = "hwnd hWndFrom;" & _; You might wan't to use another structure, because this ones has things not used for this but I don't feel like adding the right one atm
"int IDFrom;" & _
"int Code;" & _
"int position;" & _
"int ch;" & _
"int modifiers;" & _
"int modificationType;" & _
"ptr text;" & _
"int length;" & _
"int linesAdded;" & _
"int message;" & _
"dword wParam;" & _
"dword lParam;" & _
"int line;" & _
"int foldLevelNow;" & _
"int foldLevelPrev;" & _
"int margin;" & _
"int listType;" & _
"int x;" & _
"int y;"

Global $Editor_UI
Global $Editor_UI_Style = BitOR($WS_CAPTION, $WS_SYSMENU, $WS_THICKFRAME, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_CLIPCHILDREN); Take note about $WS_CLIPCHILDREN, we will remove it when needed because this style interferes with normal operation
Global $Editor_UI_StyleEx = -1

Global $UI_WIDTH = 600
Global $UI_HIGHT = 350

#region - Tabs

Global $Tabs[55][5]; Sci control, tabs and file info array
#cs
$Tabs[n][0] = hTab; Note to self, this is not even needed
$Tabs[n][1] = hSci; scintilla handle
$Tabs[n][2] = sFile; loaded file path
$Tabs[n][3] = Sci modification indicator for saving status true/fale
$Tabs[n][4] = Tab name, file name
#ce
Global $DragCtrl

Global $CatchIt = 0;Used as a switch for capturing tab relocations
Global $Dropped, $Clicked, $Current; tab identifiers for relocation process
Global $TimeUp, $TimeDown; used to prevent unwanted tab relocations
Global $Rec_Old[4]; indicator to detect tab navigation
Global $hGraphic; the red arrow
Global $hPen; the red arrow
Global $hEndCap; the red arrow
Global $TabMarker = 0xB055; Action identifier used in the mouse tracker code _UI_TrackMouse
Global $Last; unused
Global $Timer = TimerInit()
Global $OldTime = TimerDiff($Timer); Timing stuff for incresed action speeds to avoid doing unecessary things

#endregion - Tabs

AutoItSetOption("MouseCoordMode", 2)
AutoItSetOption("GUIOnEventMode", 1)
AutoItSetOption("GUIEventOptions", 1)

$Editor_UI = GUICreate("(Untitled) - ASciTE", 300, 300, -1, -1, $Editor_UI_Style, $Editor_UI_StyleEx)
Global $htab = _GUICtrlTab_Create($Editor_UI, 0, 0, $UI_HIGHT, $UI_WIDTH, BitOR($WS_CHILD, $WS_VISIBLE, $TCS_HOTTRACK, $TCS_MULTILINE))

_GDIPlus_Startup()

$hPen = _GDIPlus_PenCreate(0xFFFF0000, 2); create the red pen
$hEndCap = _GDIPlus_ArrowCapCreate(3, 6); little arrow marker
_GDIPlus_PenSetCustomEndCap($hPen, $hEndCap);boom!

Global $Tab = _GUICtrlTab_GetDisplayRect($htab); get client size of tabs
Global $Lable = GUICtrlCreateLabel("",$Tab[0], $Tab[1], $Tab[2] - $Tab[0], $Tab[3] - $Tab[1]); fit inside the tabs

For $I = 0 To 54
$Tabs[$I][0] = _GUICtrlTab_InsertItem($htab, $I, $I & " Test");useless random data, this is where you will hold things relevent to the current tab
$Tabs[$I][1] = $I; fill with whatever
$Tabs[$I][2] = 0
$Tabs[$I][3] = 0
$Tabs[$I][4] = $I & " Test"
Next

Global $tRegion = DllStructCreate("struct;long Left;long Top;long Right;long Bottom;endstruct"); structure used to indicate what tab will be repainted so we don't leave little red arrows everywhere

GUISetOnEvent($GUI_EVENT_PRIMARYUP, "_UI_PrimaryUp")
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_UI_PrimaryDown")
GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "_UI_TrackMouse")
GUISetOnEvent($GUI_EVENT_CLOSE, "_UI_Terminate")

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUIRegisterMsg($WM_SIZE, "WM_SIZE")

GUISetState()

Sleep(700000)



Func _UI_TrackMouse()
Switch $DragCtrl
Case $TabMarker

_UI_MouseDetails($Current)

Local $aRect = _GUICtrlTab_GetItemRect($htab, $Current)
If $Rec_Old[0] <> $aRect[0] Or $Rec_Old[1] <> $aRect[1] Or $Rec_Old[2] <> $aRect[2] Or $Rec_Old[3] <> $aRect[3] And $CatchIt Then;Only enter if the $CatchIt var was set to something positive by _UI_PrimaryDown function
Local $iTopMargin = $aRect[1] + 10; adjust position so it looks pretty
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($Editor_UI);I'm tempted to find an alternate method to clear the red arrow but my GDIP exp is limited
Local $Margin; = left/right position of tab move indicator

DllStructSetData($tRegion, 1, $Rec_Old[0])
DllStructSetData($tRegion, 2, $Rec_Old[1])
DllStructSetData($tRegion, 3, $Rec_Old[0] + $Rec_Old[2])
DllStructSetData($tRegion, 4, $Rec_Old[1] + $Rec_Old[3])

DllCall("user32.dll", "int", "RedrawWindow", "hwnd", $htab, "struct*", $tRegion, "int", 0, "int", $RDW_INVALIDATE)

Select
;Create left or right red arrow marker
;Take note of how we create the left/right marker
;do this by adding +1 to the left or right side
Case $Clicked > $Current
$Margin = $aRect[0] + 3
_GDIPlus_GraphicsDrawLine($hGraphic, $aRect[0] + 1, $iTopMargin, $aRect[0], $iTopMargin, $hPen)
Case $Clicked < $Current
$Margin = $aRect[2] - 3
_GDIPlus_GraphicsDrawLine($hGraphic, $Margin, $iTopMargin, $Margin + 1, $iTopMargin, $hPen)
EndSelect

_GDIPlus_GraphicsDispose($hGraphic)

$Rec_Old[0] = $aRect[0];Save old positions so we know when they change
$Rec_Old[1] = $aRect[1]
$Rec_Old[2] = $aRect[2]
$Rec_Old[3] = $aRect[3]

EndIf

EndSwitch
Return
EndFunc ;==>_UI_TrackMouse



Func _UI_PrimaryDown()
_UI_MouseDetails($Clicked)
If Not @error Then
GUISetStyle(BitAND($Editor_UI_Style, BitNOT($WS_CLIPCHILDREN)), -1, $Editor_UI);remove clip children style or things wont work
$DragCtrl = $TabMarker
$TimeDown = TimerDiff($Timer)
$CatchIt = 1
EndIf
EndFunc ;==>_UI_PrimaryDown

Func _UI_PrimaryUp()
GUISetStyle($Editor_UI_Style, -1, $Editor_UI); Restore normal styles
$CatchIt = 0
EndFunc ;==>_UI_PrimaryUp

Func _UI_MouseDetails(ByRef $State)
Local $tPOINT = _WinAPI_GetMousePos(True, $Editor_UI)
Local $iX = DllStructGetData($tPOINT, "X")
Local $iY = DllStructGetData($tPOINT, "Y")
Local $aPos = ControlGetPos($Editor_UI, "", $htab)
Local $aHit = _GUICtrlTab_HitTest($htab, $iX - $aPos[0], $iY - $aPos[1])
If Not ($aHit[0] > -1) Then Return SetError(1, 0, 0)
$State = $aHit[0]
EndFunc ;==>_UI_MouseDetails


Func WM_NOTIFY($hWndGUI, $MsgID, $WPARAM, $LPARAM)
#forceref $hWndGUI, $MsgID, $WPARAM

Local $structNMHDR = DllStructCreate($tagSCNotification, $LPARAM)
Local $hWndFrom = DllStructGetData($structNMHDR, 1)
Local $iCode = DllStructGetData($structNMHDR, 3)
;Local $position = DllStructGetData($structNMHDR, 4)

Switch $hWndFrom
Case $htab
Switch $iCode
Case $NM_CLICK
Switch $CatchIt
Case 1
Local $Selected = _GUICtrlTab_GetCurFocus($htab)
_UI_MouseDetails($Dropped)
If @error Then
$Clicked = ''
$Dropped = ''
Return $GUI_RUNDEFMSG
EndIf
$TimeUp = TimerDiff($Timer)
Local $Time = Int($TimeUp - $TimeDown)
If $Time > 1000 And $Selected == $Clicked And $Selected <> $Dropped Then
Local $temp[UBound($Tabs, 2)]
;This handles the tab switching
If $Dropped < $Clicked Then

For $I = 0 To UBound($temp) - 1
$temp[$I] = $Tabs[$Clicked][$I]
Next
For $I = $Clicked To $Dropped + 1 Step -1
If $I < 0 Then ExitLoop
$Tabs[$I][1] = $Tabs[$I - 1][1]
$Tabs[$I][2] = $Tabs[$I - 1][2]
$Tabs[$I][3] = $Tabs[$I - 1][3]
$Tabs[$I][4] = $Tabs[$I - 1][4]
Next
For $I = 0 To UBound($temp) - 1
$Tabs[$Dropped][$I] = $temp[$I]
Next

Else

For $I = 0 To UBound($temp) - 1
$temp[$I] = $Tabs[$Clicked][$I]
Next
For $I = $Clicked To $Dropped - 1
If $I < 0 Then ExitLoop
$Tabs[$I][1] = $Tabs[$I + 1][1]
$Tabs[$I][2] = $Tabs[$I + 1][2]
$Tabs[$I][3] = $Tabs[$I + 1][3]
$Tabs[$I][4] = $Tabs[$I + 1][4]
Next
For $I = 0 To UBound($temp) - 1
$Tabs[$Dropped][$I] = $temp[$I]
Next

EndIf
For $I = 0 To UBound($Tabs, 1) - 1
_GUICtrlTab_SetItemText($htab, $I, $Tabs[$I][4])
Next
$Selected = $Dropped
Else
_GUICtrlTab_SetCurSel($hWndFrom, _GUICtrlTab_GetCurSel($hWndFrom))
EndIf
$Clicked = 0
$DragCtrl = 0
$Dropped = 0
Case 0
$Selected = _GUICtrlTab_GetCurSel($hWndFrom)
_GUICtrlTab_SetCurSel($hWndFrom, $Selected)
EndSwitch
$Tab = _GUICtrlTab_GetDisplayRect($htab)
_GUICtrlTab_SetCurSel($hWndFrom, $Selected)
GUICtrlSetData($Lable, $Tabs[$Selected][1])
GUICtrlSetPos($Lable, $Tab[0], $Tab[1], $Tab[2] - $Tab[0], $Tab[3] - $Tab[1]); here's where

Return 'GUI_RUNDEFMSG'
EndSwitch
EndSwitch
EndFunc ;==>WM_NOTIFY

Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iWParam, $ilParam

_UI_SavePosition(); save UI size, getting it this way seems more reliable
_UI_AdjustPositions()

Return $GUI_RUNDEFMSG
EndFunc ;==>WM_SIZE

Func _UI_SavePosition()
Local $Size = WinGetClientSize($Editor_UI)
If @error Then Return
$UI_WIDTH = $Size[0]
$UI_HIGHT = $Size[1]
EndFunc ;==>_UI_SavePosition

Func _UI_AdjustPositions(); reposition controls here
Local $tabpos = ControlGetPos($Editor_UI, "", $htab)

_WinAPI_SetWindowPos($htab, $HWND_BOTTOM, $tabpos[0], $tabpos[1], $UI_WIDTH, $UI_HIGHT, $SWP_SHOWWINDOW); tab goes in low z order

Local $Tab = _GUICtrlTab_GetDisplayRect($htab)
GUICtrlSetData($Lable, _GUICtrlTab_GetCurFocus($htab))
GUICtrlSetPos($Lable, $Tab[0], $Tab[1], $Tab[2] - $Tab[0], $Tab[3] - $Tab[1])
EndFunc

Func _UI_Terminate()
Exit
EndFunc

But ever since I decided to track the mouse using a mouse hook, the arrow is randomly painted. Meaning that it will only appear if you move the mouse around in a certain way..

#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>

#include <WinAPIEx.au3>
#include <Array.au3>
#include <gdiplus.au3>
#include <GuiTab.au3>

Global Const $hUSER32 = DllOpen("user32.dll")

#region - Hooks -

Global $hMouseHook = -1; We will register mouse movment dllcallback
Global $hMouseProc = -1; = DllCallbackRegister("WM_MOUSEMOVE", "int", "int;ptr;ptr"); this way our UI stays lightning fast...
; used to detect window focus, enabling us to disable/enable the mouse capture, which is a little CPU intemsive :P
Global $hWinEventProc = -1; = DllCallbackRegister("_WinEventProc", "none", "hwnd;int;hwnd;long;long;int;int")
Global $hWindowsHook = -1

#endregion - Hooks -


Global Const $tagSCNotification = "hwnd hWndFrom;" & _; You might wan't to use another structure, because this ones has things not used for this but I don't feel like adding the right one atm
"int IDFrom;" & _
"int Code;" & _
"int position;" & _
"int ch;" & _
"int modifiers;" & _
"int modificationType;" & _
"ptr text;" & _
"int length;" & _
"int linesAdded;" & _
"int message;" & _
"dword wParam;" & _
"dword lParam;" & _
"int line;" & _
"int foldLevelNow;" & _
"int foldLevelPrev;" & _
"int margin;" & _
"int listType;" & _
"int x;" & _
"int y;"

Global $Editor_UI
Global $Editor_UI_Style = BitOR($WS_CAPTION, $WS_SYSMENU, $WS_THICKFRAME, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_CLIPCHILDREN); Take note about $WS_CLIPCHILDREN, we will remove it when needed because this style interferes with normal operation
Global $Editor_UI_StyleEx = -1

Global $UI_WIDTH = 600
Global $UI_HIGHT = 350

#region - Tabs

Global $Tabs[55][5]; Sci control, tabs and file info array
#cs
$Tabs[n][0] = hTab; Note to self, this is not even needed
$Tabs[n][1] = hSci; scintilla handle
$Tabs[n][2] = sFile; loaded file path
$Tabs[n][3] = Sci modification indicator for saving status true/fale
$Tabs[n][4] = Tab name, file name
#ce
Global $DragCtrl

Global $CatchIt = 0;Used as a switch for capturing tab relocations
Global $Dropped, $Clicked, $Current; tab identifiers for relocation process
Global $TimeUp, $TimeDown; used to prevent unwanted tab relocations
Global $Rec_Old[4]; indicator to detect tab navigation
Global $hGraphic; the red arrow
Global $hPen; the red arrow
Global $hEndCap; the red arrow
Global $TabMarker = 0xB055; Action identifier used in the mouse tracker code _UI_TrackMouse
Global $Last; unused
Global $Timer = TimerInit()
Global $OldTime = TimerDiff($Timer); Timing stuff for incresed action speeds to avoid doing unecessary things

#endregion - Tabs

AutoItSetOption("MouseCoordMode", 2)

$Editor_UI = GUICreate("(Untitled) - ASciTE", 300, 300, -1, -1, $Editor_UI_Style, $Editor_UI_StyleEx)
Global $htab = _GUICtrlTab_Create($Editor_UI, 0, 0, $UI_HIGHT, $UI_WIDTH, BitOR($WS_CHILD, $WS_VISIBLE, $TCS_HOTTRACK, $TCS_MULTILINE))

_GDIPlus_Startup()

$hPen = _GDIPlus_PenCreate(0xFFFF0000, 2); create the red pen
$hEndCap = _GDIPlus_ArrowCapCreate(3, 6); little arrow marker
_GDIPlus_PenSetCustomEndCap($hPen, $hEndCap);boom!

Global $Tab = _GUICtrlTab_GetDisplayRect($htab); get client size of tabs
Global $Lable = GUICtrlCreateLabel("", $Tab[0], $Tab[1], $Tab[2] - $Tab[0], $Tab[3] - $Tab[1]); fit inside the tabs

For $I = 0 To 54
$Tabs[$I][0] = _GUICtrlTab_InsertItem($htab, $I, $I & " Test");useless random data, this is where you will hold things relevent to the current tab
$Tabs[$I][1] = $I; fill with whatever
$Tabs[$I][2] = 0
$Tabs[$I][3] = 0
$Tabs[$I][4] = " Test"
Next

Global $tRegion = DllStructCreate("struct;long Left;long Top;long Right;long Bottom;endstruct"); structure used to indicate what tab will be repainted so we don't leave little red arrows everywhere

GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND")
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUIRegisterMsg($WM_SIZE, "WM_SIZE")

GUISetState()

_UI_SetMouseHook(1)
_UI_SetWindowHook(1)

Sleep(700000)



Func _UI_SetMouseHook($DoWhat = 0)
If Not IsDeclared("DoWhat") Then $DoWhat = 1
AdlibUnRegister("_UI_SetMouseHook")
Switch $DoWhat
Case 1
If $hMouseProc = -1 Then
$hMouseProc = DllCallbackRegister("WM_MOUSEMOVE", "int", "uint;wparam;lparam")
EndIf
If $hMouseHook = -1 Then
Local $hM_Module = _WinAPI_GetModuleHandle(0)
$hMouseHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($hMouseProc), $hM_Module, 0)
EndIf

Case 0

If $hMouseHook <> -1 Then
_WinAPI_UnhookWindowsHookEx($hMouseHook)
$hMouseHook = -1
EndIf

If $hMouseProc <> -1 Then
DllCallbackFree($hMouseProc)
$hMouseProc = -1
EndIf

EndSwitch
EndFunc ;==>_UI_SetMouseHook

Func _UI_SetWindowHook($DoWhat = 0); Thanks to rasim for this
If Not IsDeclared("DoWhat") Then $DoWhat = 1
Switch $DoWhat
Case 1
If $hWinEventProc = -1 Then
$hWinEventProc = DllCallbackRegister("_WinEventProc", "none", "hwnd;int;hwnd;long;long;int;int")
EndIf
If $hWindowsHook = -1 Then
Local Const $EVENT_SYSTEM_FOREGROUND = 0x0003 ;An MSAA event indicating that the foreground window changed.
Local Const $WINEVENT_OUTOFCONTEXT = 0x0
$hWindowsHook = DllCall($hUSER32, "hwnd", "SetWinEventHook", _
"uint", $EVENT_SYSTEM_FOREGROUND, _; Event Min
"uint", $EVENT_SYSTEM_FOREGROUND, _; Event Max
"hwnd", 0, _
"ptr", DllCallbackGetPtr($hWinEventProc), _
"int", 0, _
"int", 0, _
"uint", $WINEVENT_OUTOFCONTEXT)
If @error Then Return SetError(@error, 0, 0)
$hWindowsHook = $hWindowsHook[0]
EndIf
Case 0
If $hWindowsHook <> -1 Then
DllCall($hUSER32, "int", "UnhookWinEvent", "hwnd", $hWindowsHook)
EndIf
If $hWinEventProc <> -1 Then
DllCallbackFree($hWinEventProc)
EndIf
EndSwitch
EndFunc ;==>_UI_SetWindowHook

Func _WinEventProc($hHook, $iEvent, $hWnd, $idObject, $idChild, $iEventThread, $iEventTime)
#forceref $hHook, $iEvent, $idObject, $idChild, $iEventThread, $iEventTime

Switch $hWnd
Case $Editor_UI
_UI_SetMouseHook(1)
;ConsoleWrite(">Hooked mouse.")
Case Else
_UI_SetMouseHook()
;ConsoleWrite(">Unhooked mouse.")
EndSwitch

Return
EndFunc ;==>_WinEventProc

Func WM_MOUSEMOVE($nCode, $wParam, $lParam)
#forceref $nCode, $wParam, $lParam
If $nCode < 0 Then
Return _WinAPI_CallNextHookEx($hMouseHook, $nCode, $wParam, $lParam) ;Continue processing
EndIf
;If $nCode <> 0 Then ConsoleWrite($nCode & @CR)
;If $BlockMessages Then Return 'GUI_RUNDEFMSG'

Switch BitAND($wParam, 0xFFFF)
Case 513; mouse down, mouse down event of drag bar is caught in the WM_COMMAND function an not here due to complications
_UI_MouseDetails($Clicked)
If Not @error Then; Tab was clicked, $clicked has tab index that was clicked
GUISetStyle(BitAND($Editor_UI_Style, BitNOT($WS_CLIPCHILDREN)), -1, $Editor_UI);remove clip children style or things wont work
$DragCtrl = $TabMarker
$TimeDown = TimerDiff($Timer)
$CatchIt = 1
EndIf

Case 514; mouse up
_UI_SavePosition()
Switch $DragCtrl; the tab repositions are handled in WM_NOTIFY
Case $TabMarker
Local $Selected = _GUICtrlTab_GetCurFocus($htab)
If $CatchIt Then
GUISetStyle($Editor_UI_Style, -1, $Editor_UI)
_UI_MouseDetails($Dropped)
If @error Then
$Clicked = ''
$Dropped = ''
Return $GUI_RUNDEFMSG
EndIf
$TimeUp = TimerDiff($Timer)
Local $Time = Int($TimeUp - $TimeDown)
If $Time > 1000 And $Selected == $Clicked And $Selected <> $Dropped Then
Local $temp[UBound($Tabs, 2)]
;This handles the tab switching
If $Dropped < $Clicked Then

For $I = 0 To UBound($temp) - 1
$temp[$I] = $Tabs[$Clicked][$I]
Next
For $I = $Clicked To $Dropped + 1 Step -1
;ConsoleWrite($I & @CR)
If $I < 0 Then ExitLoop
$Tabs[$I][1] = $Tabs[$I - 1][1]
$Tabs[$I][2] = $Tabs[$I - 1][2]
$Tabs[$I][3] = $Tabs[$I - 1][3]
$Tabs[$I][4] = $Tabs[$I - 1][4]
Next
For $I = 0 To UBound($temp) - 1
$Tabs[$Dropped][$I] = $temp[$I]
Next

Else

For $I = 0 To UBound($temp) - 1
$temp[$I] = $Tabs[$Clicked][$I]
Next
For $I = $Clicked To $Dropped - 1
If $I < 0 Then ExitLoop
$Tabs[$I][1] = $Tabs[$I + 1][1]
$Tabs[$I][2] = $Tabs[$I + 1][2]
$Tabs[$I][3] = $Tabs[$I + 1][3]
$Tabs[$I][4] = $Tabs[$I + 1][4]
Next
For $I = 0 To UBound($temp) - 1
$Tabs[$Dropped][$I] = $temp[$I]
Next

EndIf
For $I = 0 To UBound($Tabs, 1) - 1
_GUICtrlTab_SetItemText($htab, $I, $I & " " & $Tabs[$I][4])
Next
$Selected = $Dropped
Else
_GUICtrlTab_SetCurSel($htab, _GUICtrlTab_GetCurSel($htab))
EndIf
$Clicked = 0
$DragCtrl = 0
$Dropped = 0
_GUICtrlTab_SetCurSel($htab, $Selected)
EndIf
EndSwitch
$Tab = _GUICtrlTab_GetDisplayRect($htab)
GUICtrlSetData($Lable, $Tabs[$Selected][1])
GUICtrlSetPos($Lable, $Tab[0], $Tab[1], $Tab[2] - $Tab[0], $Tab[3] - $Tab[1]); here's where

#Region - PROBLEM AREA -

Case 512; mouse moving
Switch $DragCtrl
Case $TabMarker; something seems to be happening here that causes the arrow to be removed
_UI_MouseDetails($Current)
If Not @error Then
Local $aRect = _GUICtrlTab_GetItemRect($htab, $Current)
If $Rec_Old[0] <> $aRect[0] Or $Rec_Old[1] <> $aRect[1] Or $Rec_Old[2] <> $aRect[2] Or $Rec_Old[3] <> $aRect[3] And $CatchIt Then;Only enter if the $CatchIt var was set to something positive by _UI_PrimaryDown function

;Repaint the previously hovered button to remove any leftover arrows
DllCall _
( _
"user32.dll", _
"int", "RedrawWindow", _
"hwnd", $htab, _
"struct*", _WinAPI_CreateRectRgn($Rec_Old[0], $Rec_Old[1], $Rec_Old[0] + $Rec_Old[2], $Rec_Old[1] + $Rec_Old[3]), _
"int", 0, _
"int", $RDW_INVALIDATE _
)

Local $iTopMargin = $aRect[1] + 10
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($Editor_UI);I'm tempted to find an alternate method to clear the red arrow but my GDIP exp is limited
Local $Margin; = left/right position of tab move indicator

Select
;Create left or right red arrow marker
;Take note of how we create the left/right marker
;do this by adding +1 to the left or right side
Case $Clicked > $Current
$Margin = $aRect[0] + 3
_GDIPlus_GraphicsDrawLine($hGraphic, $aRect[0] + 1, $iTopMargin, $aRect[0], $iTopMargin, $hPen)
Case $Clicked < $Current
$Margin = $aRect[2] - 3
_GDIPlus_GraphicsDrawLine($hGraphic, $Margin, $iTopMargin, $Margin + 1, $iTopMargin, $hPen)
EndSelect

_GDIPlus_GraphicsDispose($hGraphic)

$Rec_Old[0] = $aRect[0];Save old positions so we know when they change
$Rec_Old[1] = $aRect[1]
$Rec_Old[2] = $aRect[2]
$Rec_Old[3] = $aRect[3]

EndIf
EndIf
EndSwitch

#EndRegion - PROBLEM AREA -

EndSwitch
Return _WinAPI_CallNextHookEx($hMouseHook, $nCode, $wParam, $lParam) ;Continue processing
EndFunc ;==>WM_MOUSEMOVE

Func _UI_MouseDetails(ByRef $State)
Local $tPOINT = _WinAPI_GetMousePos(True, $Editor_UI)
Local $iX = DllStructGetData($tPOINT, "X")
Local $iY = DllStructGetData($tPOINT, "Y")
Local $aPos = ControlGetPos($Editor_UI, "", $htab)
Local $aHit = _GUICtrlTab_HitTest($htab, $iX - $aPos[0], $iY - $aPos[1])
If Not ($aHit[0] > -1) Then Return SetError(1, 0, 0)
$State = $aHit[0]
EndFunc ;==>_UI_MouseDetails


Func WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam)
#forceref $hWndGUI, $MsgID, $WPARAM

Local $structNMHDR = DllStructCreate($tagSCNotification, $lParam)
Local $hWndFrom = DllStructGetData($structNMHDR, 1)
Local $iCode = DllStructGetData($structNMHDR, 3)
;Local $position = DllStructGetData($structNMHDR, 4)

Switch $hWndFrom
Case $htab
Switch $iCode
Case $NM_CLICK
Switch $CatchIt
Case 0
_GUICtrlTab_SetCurSel($htab, _GUICtrlTab_GetCurSel($htab))
;Case 1
EndSwitch
EndSwitch
EndSwitch
EndFunc ;==>WM_NOTIFY

Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iWParam, $ilParam

_UI_SavePosition(); save UI size, getting it this way seems more reliable
_UI_AdjustPositions()

Return $GUI_RUNDEFMSG
EndFunc ;==>WM_SIZE

Func _UI_SavePosition()
Local $Size = WinGetClientSize($Editor_UI)
If @error Then Return
$UI_WIDTH = $Size[0]
$UI_HIGHT = $Size[1]
EndFunc ;==>_UI_SavePosition

Func _UI_AdjustPositions(); reposition controls here
Local $tabpos = ControlGetPos($Editor_UI, "", $htab)

_WinAPI_SetWindowPos($htab, $HWND_BOTTOM, $tabpos[0], $tabpos[1], $UI_WIDTH, $UI_HIGHT, $SWP_SHOWWINDOW); tab goes in low z order

Local $Tab = _GUICtrlTab_GetDisplayRect($htab)
GUICtrlSetData($Lable, _GUICtrlTab_GetCurFocus($htab))
GUICtrlSetPos($Lable, $Tab[0], $Tab[1], $Tab[2] - $Tab[0], $Tab[3] - $Tab[1])
EndFunc ;==>_UI_AdjustPositions

Func WM_SYSCOMMAND($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam, $ilParam
Switch $hWnd
Case $Editor_UI
Switch BitAND($iwParam, 0xFFF0)
Case 0xF060
_UI_SetMouseHook()
_UI_SetWindowHook()
Exit
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_SYSCOMMAND

What could it be?

P.S. You need to click a tab and drag it around.

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

    No registered users viewing this page.

×
×
  • Create New...