Jump to content

My OwnTab-Control


Recommended Posts

I was looking for a way to hide/show tabs with radio buttons, and some1 pointed this out to me, Thanks

Great UDF!!

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.  

Link to post
Share on other sites
  • 2 months later...
  • 1 month later...

Hiya!

Relative Newbee here... First of all I Love this UDF!! However I have a problem. I have tried to embed a webpage (which works successfully) but when I click on another tab and then come back to it, I have to "click and drag" over the area to refresh the page... Also when I hide a few tabs and then un-hide them they appear to far to the left than where they are supposed to be.

Hope I'm not annoying here or this hasn't already been covered... If it has, pplease point me to the right location ;)

Cheers!

Link to post
Share on other sites
  • 4 months later...

Wow!

I just discovered this little gem of yours on 1/29/2011, searching for a way to set a tab's color (rather than just the tab's "content").

This UDF (and your demo script) is really awesome! It does things I didn't even think was possible.

Thanks much!

Dick

I made my own tab-control!

Posted Image

OwnTab-Gallery

Example

#include "OwnTab.au3"

#cs
Known Bugs:
  --> Bug mit $OwnTab_Style, da diese Variable zur Laufzeit abgefragt wird beim Verstecken und erneuten Anzeigen der Register.
  --> "Zittern" der alarmierten Register, wenn diese bereits angewählt wurden --> durch blinken mit der selben Farbe
#ce
Local $hGui = GUICreate("Funkey's OwnTab-UDF Example", 500, 350)
GUISetBkColor(0xbbbbbb)

$OwnTab_Style = Random(0, 1, 1) ;random style (only 2 styles available!!)

Local $aTabText[5] = ["Settings", "Register without icon", "Pic", "Status", "Tab in Tab"] ;Declare the regions for the OwnTab-control
Local $aTabIcons[5][2] = [["shell32.dll", 130],[""],["shell32.dll", 139],["shell32.dll", 90], ["shell32.dll", 43]]
Global $aCtrlTab = _OwnTab_Create($hGui, $aTabText, 10, 10, 480, 300, 30, 0xD5D5D5, 0xCFE0E7, 0xCFE0E7, $aTabIcons)

Local $aTabTip[5] = ["Tip Item 1", "Tip Item 2", "Tip Item 3", "Alarm-Register"]
_OwnTab_SetTip($aCtrlTab, $aTabTip) ;set the tooltips for the OwnTab-control

#Region Tab1
_OwnTab_Add($aCtrlTab) ;Start controls tab1
Global $Edit1 = GUICtrlCreateEdit("Edit in Tab1", 20, 55, 300, 50, 0)
Global $Button1 = GUICtrlCreateButton("Simulate an alarm", 20, 120, 300, 20)
Global $Box1 = GUICtrlCreateCheckbox("Switch on hover  -  set time -->", 20, 180)
GUICtrlSetBkColor(-1, 0xCFE0E7)
Global $Input1 = GUICtrlCreateInput("1", 200, 180, 50, 20)
GUICtrlCreateUpdown($Input1)
GUICtrlSetLimit(-1, 15, 1)
#EndRegion Tab1

#Region Tab2
_OwnTab_Add($aCtrlTab) ;Start controls tab2
Global $Edit2 = GUICtrlCreateEdit("Edit in Tab2", 20, 150, 300, 50, 0)
Global $Label2 = GUICtrlCreateLabel("Label in Tab2", 20, 220, 300, 20, 0x201)
GUICtrlSetBkColor(-1, -2) ;$GUI_BKCOLOR_TRANSPARENT
#EndRegion Tab2

#Region Tab3
_OwnTab_Add($aCtrlTab) ;Start controls tab3
Global $Labe3 = GUICtrlCreateLabel("If you see this label, you can change the picture-path in scriptline " [email="&@ScriptLineNumber"]&@ScriptLineNumber[/email] + 1 &  "!!", 40, 150, 400, 30, 0x201)
Global $Edit3 = GUICtrlCreatePic(@DocumentsCommonDir & '\Eigene Bilder\Beispielbilder\Winter.jpg', 20, 55, 460, 280)
#EndRegion Tab3

#Region Tab4
_OwnTab_Add($aCtrlTab) ;Start controls tab4
Global $Button4 = GUICtrlCreateButton("Acknowledge the alarm", 20, 120, 300, 20)
Global $Button5 = GUICtrlCreateButton("Enable tab 3", 20, 150, 300, 20)
Global $Button6 = GUICtrlCreateButton("Disable tab 3", 20, 180, 300, 20)
Global $Button7 = GUICtrlCreateButton("Hide tab 2", 20, 240, 300, 20)
Global $Button8 = GUICtrlCreateButton("Show tab 2", 20, 210, 300, 20)
#EndRegion Tab4

#Region Tab5 and "Tab in Tab"
_OwnTab_Add($aCtrlTab) ;Start controls tab5

GUICtrlCreateLabel("Style Black", 30, 50, 200, 20, 0x201)
$OwnTab_Style = 0
Local $aTabText[2] = ["Tab1", "New Info"] ;Declare the regions for the OwnTab-control
Local $aTabIcons[2][2] = [["shell32.dll", 20],["shell32.dll", 40]]
Global $aCtrlTab2 = _OwnTab_Create($hGui, $aTabText, 30, 80, 200, 200, 30, 0xD5D5D5, 0x00ff00, 0x00ff00, $aTabIcons)
_OwnTab_Add($aCtrlTab2) ;Start controls tab1
Global $BtnSet = GUICtrlCreateButton("Simulate", 80, 150, 100, 20)
_OwnTab_Add($aCtrlTab2) ;Start controls tab2
Global $BtnReset = GUICtrlCreateButton("Acknowledge", 80, 170, 100, 20)
_OwnTab_End($aCtrlTab2)

GUICtrlCreateLabel("Style White", 270, 50, 200, 20, 0x201)
$OwnTab_Style = 1
Local $aTabText[2] = ["Tab1", "Tab2"] ;Declare the regions for the OwnTab-control
Local $aTabIcons[2][2] = [["shell32.dll", 10],["shell32.dll", 60]]
Global $aCtrlTab3 = _OwnTab_Create($hGui, $aTabText, 270, 80, 200, 200, 30, 0xD5D5D5, 0x00ff00, 0x00ff00, $aTabIcons)
_OwnTab_Add($aCtrlTab3) ;Start controls tab1
GUICtrlCreateLabel("Just testing...", 280, 150, 100, 20)
GUICtrlSetBkColor(-1, -2)
_OwnTab_Add($aCtrlTab3) ;Start controls tab2
GUICtrlCreateLabel("Hello from tab2", 280, 150, 100, 20)
GUICtrlSetBkColor(-1, -2)
_OwnTab_End($aCtrlTab3)
#EndRegion Tab5

_OwnTab_End($aCtrlTab) ;new: end control-definition AND inizialize the OwnTab

_OwnTab_Disable($aCtrlTab, 3) ;new: disable tabitems
_OwnTab_SetFontCol($aCtrlTab, 0xFF) ;new: set font-color

GUISetState()
_OwnTab_Hover($aCtrlTab, 0xFFFF88) ;start hover-function if you want
_OwnTab_AlarmInit()

Local $msg

While 1
$msg = GUIGetMsg()
For $a = 1 To UBound($aCtrlTab, 1) - 1
  If $msg = $aCtrlTab[$a][0] Then
   _OwnTab_Switch($aCtrlTab, $a)
   If $a = 5 Then
    _OwnTab_Switch($aCtrlTab2, $aCtrlTab2[0][0], 1)
    _OwnTab_Switch($aCtrlTab3, $aCtrlTab3[0][0], 1)
   EndIf
  EndIf
Next
For $a = 1 To UBound($aCtrlTab2, 1) - 1
  If $msg = $aCtrlTab2[$a][0] Then
   _OwnTab_Switch($aCtrlTab2, $a)
  EndIf
Next
For $a = 1 To UBound($aCtrlTab3, 1) - 1
  If $msg = $aCtrlTab3[$a][0] Then
   _OwnTab_Switch($aCtrlTab3, $a)
  EndIf
Next
Switch $msg
  Case $Button1
   _OwnTab_SetAlarm($aCtrlTab, 4, 0xFF0000)
  Case $Button4
   _OwnTab_ResetAlarm($aCtrlTab, 4)
  Case $BtnSet
   _OwnTab_SetAlarm($aCtrlTab2, 2, 0x5050FF)
  Case $BtnReset
   _OwnTab_ResetAlarm($aCtrlTab2, 2)
  Case $Button5
   _OwnTab_Enable($aCtrlTab, 3)
  Case $Button6
   _OwnTab_Disable($aCtrlTab, 3)
  Case $Button7
   _OwnTab_Hide($aCtrlTab, 2)
  Case $Button8
   _OwnTab_Show($aCtrlTab, 2)
  Case $Box1
   If GUICtrlRead($Box1) = 1 Then
    _OwnTab_Hover($aCtrlTab, 0xFFFF88, GUICtrlRead($Input1))
   Else
    _OwnTab_Hover($aCtrlTab, 0xFFFF88, 0)
   EndIf
  Case $Input1
   If GUICtrlRead($Box1) = 1 Then _OwnTab_Hover($aCtrlTab, 0xFFFF88, GUICtrlRead($Input1))
  Case -3
   Exit
EndSwitch 
Sleep(10)
WEnd

OwnTab-UDF

#include-once
#include <GDIPlus.au3>
#include <Array.au3>
#include <Constants.au3>
#include <WindowsConstants.au3>
#Include <Timers.au3>

#cs
Copyrights to funkey from Autoit.de
#ce

Local $HoverArray[1], $ControlID, $Global_I = 0, $__ControlID, $HoverActive = 0, $Temp_Found = 0, $szTemp_Array[2]
Local $OwnTabHoverCol[2], $OwnTabHoverHelp[1], $OwnTabHoverSwitch, $aOwnTabHoverCount, $OwnTabHoverCtrl
Local $aOwnTabAlarm[1][3], $iOwnTabAlarm, $hOwnTabGui, $hTimerAlarm, $hTimerHover
Local $OwnTab_Style = 0 ; only 0 or 1 !

_GDIPlus_Startup()
Opt("OnExitFunc", "_OwnTab_OnExit")

Func _OwnTab_Create($hWnd, $aTabText, $xPos, $yPos, $iWidth, $iHeight, $iItemHeight = -1, $nColNoSel = -1, $nColSel = -1, $nColBg = -1, $aIcons = "")
Local $aSize, $aSize2[UBound($aTabText)][2], $xLast = 0, $aCtrl[UBound($aTabText) + 1][11], $iOffset = 0
If Not IsArray($aIcons) Then
  Local $Icons[UBound($aTabText)][2]
Else
  Local $Icons = $aIcons
EndIf
If Not IsArray($aTabText) Then Return SetError(1, 0, "")
For $i = 0 To UBound($aTabText) - 1
  If $aTabText[$i] = "" Then Return SetError(2, $i + 1, "")
  $aSize = _GetTextSize($aTabText[$i])
  $aSize[0] += Ceiling($aSize[0] / 10) ;make it 10% longer for bold text
  $aSize2[$i][0] = $aSize[0]
  $aSize2[$i][1] = $aSize[1]
  If $iItemHeight = -1 Then $iItemHeight = $aSize[1]
  If $Icons[$i][0] <> "" Then
   $iOffset = $iItemHeight
   $aTabText[$i] &= " "
  Else
   $iOffset = 0
  EndIf
  $aCtrl[$i + 1][7] = $Icons[$i][0] ;filename for icon
  $aCtrl[$i + 1][8] = $Icons[$i][1] ;index for icon
  $aCtrl[$i + 1][9] = $aSize[0] + 5 + $iOffset ;labelwidth
  $aCtrl[$i + 1][0] = GUICtrlCreateLabel($aTabText[$i], $xPos + $xLast + 5, $yPos + 2, $aCtrl[$i + 1][9], $iItemHeight, 0x411201 + ($Icons[$i][0] <> ""), $OwnTab_Style)
  _HoverAddCtrl($aCtrl[$i + 1][0])
  If $Icons[$i][0] <> "" Then
   $aCtrl[$i + 1][6] = GUICtrlCreateIcon("", 0, $xPos + $xLast + 8, $yPos + 5, $iItemHeight - 6, $iItemHeight - 6)
  Else
   $aCtrl[$i + 1][6] = GUICtrlCreateDummy()
  EndIf
;~   If $Icons[$i][0] <> "" Then _SetBkIcon($aCtrl[$i + 1][6], $nColNoSel, $aCtrl[$i + 1][7], $aCtrl[$i + 1][8], $iItemHeight - 6, $iItemHeight - 6)
  GUICtrlCreateLabel($aCtrl[$i + 1][7], -200, -200) ;For information
  GUICtrlCreateLabel($aCtrl[$i + 1][8], -200, -200) ;For information
  GUICtrlCreateLabel($iItemHeight - 6, -200, -200) ;For information
  $aCtrl[$i + 1][2] = $nColNoSel
  $aCtrl[$i + 1][3] = $nColSel
  $xLast += $aCtrl[$i + 1][9]
Next
GUICtrlCreateLabel("", $xPos, $yPos + $iItemHeight, $iWidth, $iHeight, 0x411000, $OwnTab_Style)
GUICtrlSetState(-1, 128) ;$GUI_DISABLE
GUICtrlSetBkColor(-1, $nColBg)
$xLast = 0
For $i = 0 To UBound($aTabText) - 1
  If $Icons[$i][0] <> "" Then
   $iOffset = $iItemHeight
  Else
   $iOffset = 0
  EndIf
  $aCtrl[$i + 1][1] = GUICtrlCreateLabel("", $xPos + $xLast + 6, $yPos + $iItemHeight - $OwnTab_Style, $aSize2[$i][0] + 3 + $iOffset, 2+2*$OwnTab_Style)
  GUICtrlSetBkColor(-1, $nColSel)
  $xLast += $aSize2[$i][0] + 5 + $iOffset
Next
$aCtrl[0][1] = $iItemHeight
$aCtrl[0][2] = $nColNoSel
$aCtrl[0][3] = $nColSel
$aCtrl[0][9] = $yPos + 2
$hOwnTabGui = $hWnd
Return $aCtrl
EndFunc   ;==>_OwnTab_Create

Func _OwnTab_Switch(ByRef $aOwnTab, $iIndex, $fForce = 0)
_OwnTab_UnRegisterHover($aOwnTab, $iIndex)
If _OwnTab_IsAlarmed($aOwnTab[$iIndex][0]) Then $aOwnTabAlarm[@extended][2] = $aOwnTabAlarm[@extended][1]
$HoverActive = 0
If $aOwnTab[0][0] = $iIndex And $fForce = 0 Then Return
For $s = 1 To UBound($aOwnTab, 1) - 1
  If $iIndex <> $s Then
   GUICtrlSetState($aOwnTab[$s][1], 32) ;$GUI_HIDE
   GUICtrlSetFont($aOwnTab[$s][0], -1, 400)
   If Not _OwnTab_IsAlarmed($aOwnTab[$s][0]) Then 
    GUICtrlSetBkColor($aOwnTab[$s][0], $aOwnTab[$s][2])
    If $aOwnTab[$s][7] <> "" Then _SetBkIcon($aOwnTab[$s][6], $aOwnTab[$s][2], $aOwnTab[$s][7], $aOwnTab[$s][8], GUICtrlRead($aOwnTab[$s][0] + 4), GUICtrlRead($aOwnTab[$s][0] + 4))
   EndIf
   If _ArraySearch($OwnTabHoverHelp, $aOwnTab[$s][0]) = -1 Then
    _OwnTab_RegisterHover($aOwnTab, $s)
   EndIf
  Else
   GUICtrlSetFont($aOwnTab[$iIndex][0], -1, 1000)
   If Not _OwnTab_IsAlarmed($aOwnTab[$s][0]) Then 
    GUICtrlSetBkColor($aOwnTab[$iIndex][0], $aOwnTab[$iIndex][3])
    If $aOwnTab[$s][7] <> "" Then _SetBkIcon($aOwnTab[$iIndex][6], $aOwnTab[$iIndex][3], $aOwnTab[$s][7], $aOwnTab[$s][8], GUICtrlRead($aOwnTab[$s][0] + 4), GUICtrlRead($aOwnTab[$s][0] + 4))
   EndIf
   GUICtrlSetState($aOwnTab[$iIndex][1], 16) ;$GUI_SHOW
  EndIf
Next
If $aOwnTab[0][0] = "" Or $fForce Then
  For $t = $aOwnTab[0][4] To $aOwnTab[UBound($aOwnTab, 1) - 1][4]
   GUICtrlSetState($t, 32) ;$GUI_HIDE
   If $t > $aOwnTab[$iIndex - 1][4] And $t < $aOwnTab[$iIndex][4] Then GUICtrlSetState($t, 16) ;$GUI_SHOW
  Next
Else
  For $t = $aOwnTab[$aOwnTab[0][0] - 1][4] To $aOwnTab[$aOwnTab[0][0]][4]
   GUICtrlSetState($t, 32) ;$GUI_HIDE
  Next
  For $t = $aOwnTab[$iIndex - 1][4] To $aOwnTab[$iIndex][4]
   GUICtrlSetState($t, 16) ;$GUI_SHOW
  Next
EndIf
$aOwnTab[0][0] = $iIndex
EndFunc   ;==>_OwnTab_Switch

Func _OwnTab_SetTip(ByRef $aOwnTab, $ToolTips = "", $iIndex = "")
If IsArray($ToolTips) Then
  For $i = 1 To UBound($aOwnTab, 1) - 1
   $aOwnTab[$i][5] = $ToolTips[$i - 1]
   GUICtrlSetTip($aOwnTab[$i][0], $ToolTips[$i - 1])
  Next
Else
  If $iIndex = "" Then Return SetError(1)
  $aOwnTab[$iIndex][5] = $ToolTips
  GUICtrlSetTip($aOwnTab[$iIndex][0], $ToolTips)
EndIf
EndFunc   ;==>_OwnTab_SetTip

Func _OwnTab_AlarmInit($iTime = 555)
If Not $hTimerAlarm Then
  $hTimerAlarm = _Timer_SetTimer($hOwnTabGui, $iTime, "_OwnTab_AlarmBlink")
Else
  $hTimerAlarm = _Timer_SetTimer($hOwnTabGui, $iTime, "", $hTimerAlarm)
EndIf
EndFunc   ;==>_OwnTab_AlarmInit

Func _OwnTab_AlarmBlink($hWnd, $Msg, $iIDTimer, $dwTime)
Local $AlarmColAct
$iOwnTabAlarm = Not $iOwnTabAlarm
For $i = 1 To UBound($aOwnTabAlarm, 1) - 1
  If $iOwnTabAlarm Then
   $AlarmColAct = $aOwnTabAlarm[$i][2]
  Else
   $AlarmColAct = $aOwnTabAlarm[$i][1]
  EndIf
  GUICtrlSetBkColor($aOwnTabAlarm[$i][0], $AlarmColAct)
  _SetBkIcon($aOwnTabAlarm[$i][0] + 1, $AlarmColAct, GUICtrlRead($aOwnTabAlarm[$i][0] + 2), GUICtrlRead($aOwnTabAlarm[$i][0] + 3), GUICtrlRead($aOwnTabAlarm[$i][0] + 4), GUICtrlRead($aOwnTabAlarm[$i][0] + 4))
Next
EndFunc   ;==>_OwnTab_AlarmBlink

Func _OwnTab_SetAlarm(ByRef $aOwnTab, $iIndex, $nAlarmSel = 0xFF0000)
Local $hCtrl = $aOwnTab[$iIndex][0]
Local $iSearch = _ArraySearch($aOwnTabAlarm, $hCtrl)
If $iSearch <> -1 Then Return
ReDim $aOwnTabAlarm[UBound($aOwnTabAlarm, 1) + 1][3]
$aOwnTabAlarm[UBound($aOwnTabAlarm, 1) - 1][0] = $hCtrl
$aOwnTabAlarm[UBound($aOwnTabAlarm, 1) - 1][1] = $nAlarmSel
$aOwnTabAlarm[UBound($aOwnTabAlarm, 1) - 1][2] = $aOwnTab[$iIndex][2]
;~  GUICtrlSetBkColor($aOwnTab[$iIndex][1], $nAlarmSel)
EndFunc   ;==>_OwnTab_SetAlarm

Func _OwnTab_ResetAlarm(ByRef $aOwnTab, $iIndex)
Local $hCtrl = $aOwnTab[$iIndex][0]
Local $iSearch = _ArraySearch($aOwnTabAlarm, $hCtrl)
If $iSearch = -1 Then Return
_ArrayDelete($aOwnTabAlarm, $iSearch)
$aOwnTab[$iIndex][2] = $aOwnTab[0][2]
$aOwnTab[$iIndex][3] = $aOwnTab[0][3]
;~  GUICtrlSetBkColor($aOwnTab[$iIndex][1], $aOwnTab[0][3])
If $aOwnTab[0][0] <> $iIndex Then
  GUICtrlSetBkColor($aOwnTab[$iIndex][0], $aOwnTab[0][2])
Else
  _SetBkIcon($aOwnTab[$iIndex][0] + 1, $aOwnTab[$iIndex][3], $aOwnTab[$iIndex][7], $aOwnTab[$iIndex][8], GUICtrlRead($aOwnTab[$iIndex][0] + 4), GUICtrlRead($aOwnTab[$iIndex][0] + 4))
  GUICtrlSetBkColor($aOwnTab[$iIndex][0], $aOwnTab[0][3])
EndIf
EndFunc   ;==>_OwnTab_ResetAlarm

Func _OwnTab_Add(ByRef $aOwnTab)
Local $i = 0
While 1
  If $aOwnTab[$i][4] = "" Then ExitLoop
  $i += 1
WEnd
$aOwnTab[$i][4] = GUICtrlCreateDummy()
EndFunc   ;==>_OwnTab_Add

Func _OwnTab_End(ByRef $aOwnTab, $iIndex = 1)
$aOwnTab[UBound($aOwnTab, 1) - 1][4] = GUICtrlCreateDummy()
_OwnTab_Switch($aOwnTab, $iIndex)
EndFunc   ;==>_OwnTab_End

Func _OwnTab_Hover($aOwnTab, $nColHover, $fSwitch = 0, $iTime = 50)
$OwnTabHoverCol[0] = $nColHover
$OwnTabHoverCol[1] = $aOwnTab[0][2]
$OwnTabHoverSwitch = $fSwitch
If Not $hTimerHover Then
  $hTimerHover = _Timer_SetTimer($hOwnTabGui, $iTime, "_ProcessHover")
Else
  $hTimerHover = _Timer_SetTimer($hOwnTabGui, $iTime, "", $hTimerHover)
EndIf
EndFunc   ;==>_OwnTab_Hover

Func _OwnTab_RegisterHover($aOwnTab, $iIndex)
If _ArraySearch($HoverArray, $aOwnTab[$iIndex][0]) = -1 Then _HoverAddCtrl($aOwnTab[$iIndex][0])
EndFunc   ;==>_OwnTab_RegisterHover

Func _OwnTab_UnRegisterHover($aOwnTab, $iIndex)
Local $iSearch = _ArraySearch($HoverArray, $aOwnTab[$iIndex][0])
If $iSearch <> -1 Then _ArrayDelete($HoverArray, $iSearch)
EndFunc   ;==>_OwnTab_UnRegisterHover

#Region Disable and Enable Tab-Register
Func _OwnTab_Disable($aOwnTab, $iIndex)
GUICtrlSetState($aOwnTab[$iIndex][0], 128)
_OwnTab_UnRegisterHover($aOwnTab, $iIndex)
Local $iSearch = _ArraySearch($OwnTabHoverHelp, $aOwnTab[$iIndex][0])
If $iSearch = -1 Then _ArrayAdd($OwnTabHoverHelp, $aOwnTab[$iIndex][0])
EndFunc   ;==>_OwnTab_Disable

Func _OwnTab_Enable($aOwnTab, $iIndex)
GUICtrlSetState($aOwnTab[$iIndex][0], 64)
_OwnTab_RegisterHover($aOwnTab, $iIndex)
Local $iSearch = _ArraySearch($OwnTabHoverHelp, $aOwnTab[$iIndex][0])
If $iSearch <> -1 Then _ArrayDelete($OwnTabHoverHelp, $iSearch)
EndFunc   ;==>_OwnTab_Enable
#EndRegion Disable and Enable Tab-Register

Func _OwnTab_Hide(ByRef $aOwnTab, $iIndex)
If $iIndex = 0 Or $iIndex > UBound($aOwnTab, 1) - 1 Then Return SetError(1)
If BitAND(GUICtrlGetState($aOwnTab[$iIndex][0]), 32) Then Return
GUICtrlSetState($aOwnTab[$iIndex][0], 32) ;$GUI_HIDE
GUICtrlSetState($aOwnTab[$iIndex][1], 32) ;$GUI_HIDE
GUICtrlSetState($aOwnTab[$iIndex][6], 32) ;$GUI_HIDE

Local $Offset = 3
For $o = 0 To $iIndex - 1
  $Offset += $aOwnTab[$o][9] - 0
Next

For $o = $iIndex + 1 To UBound($aOwnTab, 1) - 1
  GUICtrlSetPos($aOwnTab[$o][0], $Offset, $aOwnTab[0][9])
  GUICtrlSetPos($aOwnTab[$o][1], $Offset + 1, $aOwnTab[0][9] + $aOwnTab[0][1] - 2 - $OwnTab_Style)
  GUICtrlSetPos($aOwnTab[$o][6], $Offset + 3, $aOwnTab[0][9] + 3)
  $Offset += $aOwnTab[$o][9]
Next
If $iIndex = $aOwnTab[0][0] Then
  If $iIndex = 1 Then
   _OwnTab_Switch($aOwnTab, 2)
  Else
   _OwnTab_Switch($aOwnTab, $iIndex - 1)
  EndIf
EndIf
EndFunc   ;==>_OwnTab_Hide

Func _OwnTab_Show(ByRef $aOwnTab, $iIndex, $iActivate = 0)
If $iIndex = 0 Or $iIndex > UBound($aOwnTab, 1) + 1 Then Return SetError(1)
If BitAND(GUICtrlGetState($aOwnTab[$iIndex][0]), 16) Then Return

Local $Offset = 3
For $o = 0 To UBound($aOwnTab, 1) - 2
  $Offset += $aOwnTab[$o][9] - 0
Next

For $o = UBound($aOwnTab, 1) - 1 To $iIndex + 1 Step -1
  GUICtrlSetPos($aOwnTab[$o][0], $Offset, $aOwnTab[0][9])
  GUICtrlSetPos($aOwnTab[$o][1], $Offset + 1, $aOwnTab[0][9] + $aOwnTab[0][1] - 2 - $OwnTab_Style)
  GUICtrlSetPos($aOwnTab[$o][6], $Offset + 3, $aOwnTab[0][9] + 3)
  $Offset -= $aOwnTab[$o - 1][9]
Next

GUICtrlSetState($aOwnTab[$iIndex][0], 16) ;$GUI_SHOW
GUICtrlSetState($aOwnTab[$iIndex][6], 16) ;$GUI_SHOW

If $iActivate Then
  _OwnTab_Switch($aOwnTab, $iIndex)
EndIf
EndFunc   ;==>_OwnTab_Show

Func _OwnTab_SetFontCol($aOwnTab, $nColor, $iIndex = "")
If $iIndex = "" Then
  For $i = 1 To UBound($aOwnTab, 1) - 1
   GUICtrlSetColor($aOwnTab[$i][0], $nColor)
  Next
Else
  If $iIndex < 1 Or $iIndex >= UBound($aOwnTab, 1) Then Return SetError(1)
  GUICtrlSetColor($aOwnTab[$iIndex][0], $nColor)
EndIf
EndFunc   ;==>_OwnTab_SetFontCol

Func _OwnTab_SetOnEvent($aOwnTab, $sFunc = "", $iIndex = "")
If $sFunc = "" Then $sFunc = "_OwnTab_OnEvent"
If $iIndex = "" Then
  For $f = 1 To UBound($aOwnTab, 1) -1
   GUICtrlSetOnEvent($aOwnTab[$f][0], $sFunc)
  Next
Else
  If $iIndex < 1 Or $iIndex >= UBound($aOwnTab, 1) Then Return SetError(1)
  GUICtrlSetOnEvent($aOwnTab[$iIndex][0], $sFunc)
EndIf
EndFunc

;~ Func _OwnTab_OnEvent() ;for example
;~  For $a = 1 To UBound($aCtrlTab, 1) -1
;~   If @GUI_CtrlId = $aCtrlTab[$a][0] Then ExitLoop
;~  Next
;~  If $a < UBound($aCtrlTab, 1) Then _OwnTab_Switch($aCtrlTab, $a) 
;~ EndFunc

Func _OwnTab_OnExit()
_GDIPlus_Shutdown()
If $hTimerAlarm Then _Timer_KillTimer($hOwnTabGui, $hTimerAlarm)
If $hTimerHover Then _Timer_KillTimer($hOwnTabGui, $hTimerHover)
EndFunc   ;==>_OwnTab_Exit

Func _GetTextSize($nText, $sFont = 'Microsoft Sans Serif', $iFontSize = 8.5, $iFontAttributes = 0)
;Author: Bugfix
;Modified: funkey
If $nText = '' Then Return
Local $hGui = GUICreate("Textmeter by Bugfix")
;~  _GDIPlus_Startup()
Local $hFormat = _GDIPlus_StringFormatCreate(0)
Local $hFamily = _GDIPlus_FontFamilyCreate($sFont)
Local $hFont = _GDIPlus_FontCreate($hFamily, $iFontSize, $iFontAttributes, 3)
Local $tLayout = _GDIPlus_RectFCreate(15, 171, 0, 0)
Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui)
Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $nText, $hFont, $tLayout, $hFormat)
Local $iWidth = Ceiling(DllStructGetData($aInfo[0], "Width"))
Local $iHeight = Ceiling(DllStructGetData($aInfo[0], "Height"))
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_GraphicsDispose($hGraphic)
;~  _GDIPlus_Shutdown()
GUIDelete($hGui)
Local $aSize[2] = [$iWidth, $iHeight]
Return $aSize
EndFunc   ;==>_GetTextSize

Func _ProcessHover($hWnd, $Msg, $iIDTimer, $dwTime)
If $OwnTabHoverSwitch > 1 And $OwnTabHoverCtrl <> "" Then
  If $aOwnTabHoverCount < $OwnTabHoverSwitch Then $aOwnTabHoverCount += 1
  If $aOwnTabHoverCount >= $OwnTabHoverSwitch Then
   ControlClick($hOwnTabGui, "", $OwnTabHoverCtrl)
   $aOwnTabHoverCount = 0
   $OwnTabHoverCtrl = ""
  EndIf
EndIf
$ControlID = _HoverCheck()
If IsArray($ControlID) Then
  If $ControlID[0] = "AcquiredHover" Then
   $OwnTabHoverCtrl = $ControlID[1]
   $aOwnTabHoverCount = 0
   If $OwnTabHoverSwitch = "1" Then
    Return ControlClick($hOwnTabGui, "", $OwnTabHoverCtrl)
   Else
    _HoverFound($ControlID[1])
   EndIf
  Else
   If $ControlID[1] <> "" Then
    _HoverLost($ControlID[1])
    $OwnTabHoverCtrl = ""
   EndIf
  EndIf
EndIf
EndFunc   ;==>_ProcessHover

Func _HoverLost($ControlID)
If _OwnTab_IsAlarmed($ControlID) Then Return
GUICtrlSetBkColor($ControlID, $OwnTabHoverCol[1])
If GUICtrlRead($ControlID + 2) <> "" Then _SetBkIcon($ControlID + 1, $OwnTabHoverCol[1], GUICtrlRead($ControlID + 2), GUICtrlRead($ControlID + 3), GUICtrlRead($ControlID + 4), GUICtrlRead($ControlID + 4))
EndFunc   ;==>_HoverLost

Func _HoverFound($ControlID)
If _OwnTab_IsAlarmed($ControlID) Then Return
GUICtrlSetBkColor($ControlID, $OwnTabHoverCol[0])
If GUICtrlRead($ControlID + 2) <> "" Then _SetBkIcon($ControlID + 1, $OwnTabHoverCol[0], GUICtrlRead($ControlID + 2), GUICtrlRead($ControlID + 3), GUICtrlRead($ControlID + 4), GUICtrlRead($ControlID + 4))
EndFunc   ;==>_HoverFound

Func _OwnTab_IsAlarmed($hCtrl)
Local $iSearch = _ArraySearch($aOwnTabAlarm, $hCtrl)
If $iSearch = -1 Then Return 0
Return SetExtended($iSearch, 1)
EndFunc

#Region _MouseHover.au3
;====================================================================================================================================
; UDF Name: _MouseHover.au3
;
; Author: marfdaman (Marvin)
;
; Contributions: RazerM (adding SetText parameter to _HoverFound and _HoverUndo).
;
; email: marfdaman at gmail dot com
;
; Use: Enable hover events for controls
;
; Note(s): If you want to use this i.c.w. an AdlibEnable in your current script, make your Adlib call "_HoverCheck()" as well.
; In this case, _HoverOn must NOT be called.
;====================================================================================================================================


;===============================================================================
; Description:   _HoverAddCtrl
; Parameter(s):  $___ControlID -> Control ID of control to be hoverchecked
;
; Requirement:   Array.au3
; Return Value(s): None
;===============================================================================
Func _HoverAddCtrl($___ControlID)
_ArrayAdd($HoverArray, $___ControlID)
EndFunc   ;==>_HoverAddCtrl


;===============================================================================
; Description:   Checks whether the mousecursor is hovering over any of the defined controls.
; Parameter(s):  None
; Requirement:   None
; Return Value(s): If a control has matched, an array will be returned, with $array[1] being either
;   "AcquiredHover" or "LostHover". $array[2] will contain the control ID.
;   It is recommended that you put this function in an AdlibEnable, since it's EXTREMELY
;   resource friendly.
;===============================================================================
Func _HoverCheck()
$HoverData = GUIGetCursorInfo()
If Not IsArray($HoverData) Then Return
$Temp_Found = 0
For $i = 1 To UBound($HoverArray) - 1
  If $HoverData[4] = $HoverArray[$i] Or $HoverData[4] = $HoverArray[$i] + 1 Then
   $Temp_Found = $i
  EndIf
Next
Select
  Case $Temp_Found = 0 And $HoverActive = 1 Or $Temp_Found <> 0 And $Temp_Found <> $Global_I And $HoverActive = 1
   $HoverActive = 0
   $Temp_Found = 0
   $szTemp_Array[0] = "LostHover"
   $szTemp_Array[1] = $HoverArray[$Global_I]
   Return $szTemp_Array
  Case $Temp_Found > 0 And $HoverActive = 0
   $Global_I = $Temp_Found
   $HoverActive = 1
   $Temp_Found = 0
   $szTemp_Array[0] = "AcquiredHover"
   $szTemp_Array[1] = $HoverArray[$Global_I]
   Return $szTemp_Array
EndSelect
EndFunc   ;==>_HoverCheck
#EndRegion _MouseHover.au3

Func _SetBkIcon($ControlID, $iBackground, $sIcon, $iIndex, $iWidth, $iHeight)
;Yashied
;http://www.autoitscript.com/forum/index.php?showtopic=92207&view=findpost&p=662886
Const $STM_SETIMAGE = 0x0172

Local $tIcon, $tID, $hDC, $hBackDC, $hBackSv, $hBitmap, $hImage, $hIcon, $hBkIcon

$tIcon = DllStructCreate('hwnd')
$tID = DllStructCreate('hwnd')
$hIcon = DllCall('user32.dll', 'int', 'PrivateExtractIcons', 'str', $sIcon, 'int', $iIndex, 'int', $iWidth, 'int', $iHeight, 'ptr', DllStructGetPtr($tIcon), 'ptr', DllStructGetPtr($tID), 'int', 1, 'int', 0)
If (@error) Or ($hIcon[0] = 0) Then
  Return SetError(1, 0, 0)
EndIf
$hIcon = DllStructGetData($tIcon, 1)
$tIcon = 0
$tID = 0

$hDC = _WinAPI_GetDC(0)
$hBackDC = _WinAPI_CreateCompatibleDC($hDC)
$hBitmap = _WinAPI_CreateSolidBitmap(0, $iBackground, $iWidth, $iHeight)
$hBackSv = _WinAPI_SelectObject($hBackDC, $hBitmap)
_WinAPI_DrawIconEx($hBackDC, 0, 0, $hIcon, 0, 0, 0, 0, $DI_NORMAL)

;~  _GDIPlus_Startup()

$hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
$hBkIcon = DllCall($ghGDIPDll, 'int', 'GdipCreateHICONFromBitmap', 'hWnd', $hImage, 'int*', 0)
$hBkIcon = $hBkIcon[2]
_GDIPlus_ImageDispose($hImage)

GUICtrlSendMsg($ControlID, $STM_SETIMAGE, $IMAGE_ICON, _WinAPI_CopyIcon($hBkIcon))
_WinAPI_RedrawWindow(GUICtrlGetHandle($ControlID))

;~  _GDIPlus_Shutdown()

_WinAPI_SelectObject($hBackDC, $hBackSv)
_WinAPI_DeleteDC($hBackDC)
_WinAPI_ReleaseDC(0, $hDC)
_WinAPI_DeleteObject($hBkIcon)
_WinAPI_DeleteObject($hBitmap)
_WinAPI_DeleteObject($hIcon)

Return SetError(0, 0, 1)
EndFunc   ;==>_SetBkIcon

Have fun!

Edit: Fixed a problem with the hover-function

Edit2: New version with Icon-support and hover-switch Posted Image

Edit3: New improved version!!

Link to post
Share on other sites

Very nice. Could you add parameter that would allow me to say where I want to put tabs? I mean I want to specify wether tabs are displayed at the top, bottom, left, or right side of tabview.

Image shows what I meant.

Posted Image

edited

Link to post
Share on other sites
  • 2 months later...

Hi, this script is cool!

But I see on thing, may is may wrong config...

The TAB in TAB when write in the last main TAB is work fine.

If the Tab over TAB write in the first main TAB, sometimes happening a some signal graphics wrongs around the window's program.

And in the first subtab, must be write SubMenu 01 with gray label called 1, and is appear gray labe called 6.

This is normal or is my mistake?

#include "OwnTab.au3"

Local $hGui = GUICreate("TAB (in) TAB", 800, 450)
GUISetBkColor(0xbbbbbb)

$OwnTab_Style = 1
;   "CADASTRO","RELATÓRIOS","FERRAMENTAS","LABORATÓRIO","BACKUP","SAIR"
Local $aTabText[5] = [" MENU 01 ", " MENU 02 ", " MENU 03 ", " MENU 04 ", " MENU 05 "]
Local $aTabIcons[5][2] = [[""],[""],[""],[""],[""]]
Global $aCtrlTab = _OwnTab_Create($hGui, $aTabText, 10, 10, 780, 400, 30, 0xD5D5D5, 0xCFE0E7, 0xCFE0E7, $aTabIcons)
Local $aTabTip[5] = ["Dica Menu 01", "Dica Menu 02", "Dica Menu 03", "Dica Menu 04","Dica Menu 05"]
_OwnTab_SetTip($aCtrlTab, $aTabTip) ;set the tooltips for the OwnTab-control

#Region Tab1
_OwnTab_Add($aCtrlTab) ;Start controls tab1
GUICtrlCreateLabel("Etiqueta 01", 15, 43, 769, 20)

$OwnTab_Style = 0
Local $aTabText3[5] = ["SubMenu 01", "SubMenu 02", "SubMenu 04", "SubMenu 04", "SubMenu 05"] ;Declare the regions for the OwnTab-control
Local $aTabIcons3[5][2] = [[""],[""],[""],[""],[""]]
Global $aCtrlTab3 = _OwnTab_Create($hGui, $aTabText3, 20, 70, 760, 330, 30, 0xD5D5D5, 0x00ffdd, 0x00ffdd, $aTabIcons3)
Local $aTabTip3[5] = ["...01", "...02","...03", "...04","...05"]
_OwnTab_SetTip($aCtrlTab3, $aTabTip3) ;set the tooltips for the OwnTab-control

#Region SubTab1
_OwnTab_Add($aCtrlTab3) ;Start controls tab1
GUICtrlCreateLabel("01", 30, 103, 739, 20)
#EndRegion SubTab1

#Region SubTab2
_OwnTab_Add($aCtrlTab3) ;Start controls tab2
GUICtrlCreateLabel("02", 30, 103, 739, 20)
#EndRegion SubTab2

#Region SubTab3
_OwnTab_Add($aCtrlTab3) ;Start controls tab2
GUICtrlCreateLabel("03", 30, 103, 739, 20)
#EndRegion SubTab3

#Region SubTab4
_OwnTab_Add($aCtrlTab3) ;Start controls tab2
GUICtrlCreateLabel("04", 30, 103, 739, 20)
#EndRegion SubTab4

#Region SubTab5
_OwnTab_Add($aCtrlTab3) ;Start controls tab2
GUICtrlCreateLabel("05", 30, 103, 739, 20)
#EndRegion SubTab5

_OwnTab_End($aCtrlTab3)
_OwnTab_Switch($aCtrlTab3,1,0)

#EndRegion Tab1

#Region Tab2
_OwnTab_Add($aCtrlTab) ;Start controls tab2
GUICtrlCreateLabel("Etiqueta 02", 15, 43, 769, 20)
#EndRegion Tab2

#Region Tab3
_OwnTab_Add($aCtrlTab) ;Start controls tab3
GUICtrlCreateLabel("Etiqueta 03", 15, 43, 769, 20)
#EndRegion Tab3

#Region Tab4
_OwnTab_Add($aCtrlTab) ;Start controls tab4
GUICtrlCreateLabel("Etiqueta 04", 15, 43, 769, 20)
#EndRegion Tab4

#Region Tab5
_OwnTab_Add($aCtrlTab) ;Start controls tab5
GUICtrlCreateLabel("Etiqueta 05", 15, 43, 769, 20)
$OwnTab_Style = 0
Local $aTabText2[5] = ["SubMenu 01", "SubMenu 02", "SubMenu 04", "SubMenu 04", "SubMenu 05"] ;Declare the regions for the OwnTab-control
Local $aTabIcons2[5][2] = [[""],[""],[""],[""],[""]]
Global $aCtrlTab2 = _OwnTab_Create($hGui, $aTabText2, 20, 70, 760, 330, 30, 0xD5D5D5, 0x00ff00, 0x00ff00, $aTabIcons2)
Local $aTabTip2[5] = ["...01", "...02","...03", "...04","...05"]
_OwnTab_SetTip($aCtrlTab2, $aTabTip2) ;set the tooltips for the OwnTab-control

#Region SubTab1
_OwnTab_Add($aCtrlTab2) ;Start controls tab1
GUICtrlCreateLabel("01", 30, 103, 739, 20)
#EndRegion SubTab1

#Region SubTab2
_OwnTab_Add($aCtrlTab2) ;Start controls tab2
GUICtrlCreateLabel("02", 30, 103, 739, 20)
#EndRegion SubTab2

#Region SubTab3
_OwnTab_Add($aCtrlTab2) ;Start controls tab2
GUICtrlCreateLabel("03", 30, 103, 739, 20)
#EndRegion SubTab3

#Region SubTab4
_OwnTab_Add($aCtrlTab2) ;Start controls tab2
GUICtrlCreateLabel("04", 30, 103, 739, 20)
#EndRegion SubTab4

#Region SubTab5
_OwnTab_Add($aCtrlTab2) ;Start controls tab2
GUICtrlCreateLabel("05", 30, 103, 739, 20)
#EndRegion SubTab5

_OwnTab_End($aCtrlTab2)
_OwnTab_Switch($aCtrlTab2, 1,0)
_OwnTab_Switch($aCtrlTab3, 1,0)
#EndRegion Tab5
_OwnTab_End($aCtrlTab)
_OwnTab_End($aCtrlTab) ;new: end control-definition AND inizialize the OwnTab

;_OwnTab_Disable($aCtrlTab, 3) ;new: disable tabitems
_OwnTab_SetFontCol($aCtrlTab, 0xFF) ;new: set font-color

GUISetState()
_OwnTab_Hover($aCtrlTab, 0xFFFF88,0,200) ;start hover-function if you want

Local $msg

While 1
    $msg = GUIGetMsg()
    For $a = 1 To UBound($aCtrlTab, 1) - 1
        If $msg = $aCtrlTab[$a][0] Then
            _OwnTab_Switch($aCtrlTab, $a)
            If $a = 5 Then
                _OwnTab_Switch($aCtrlTab, $aCtrlTab[0][0], 1)
                _OwnTab_Switch($aCtrlTab2, $aCtrlTab2[0][0], 1)
                _OwnTab_Switch($aCtrlTab3, $aCtrlTab3[0][0], 1)
            EndIf
        EndIf
    Next
    For $a = 1 To UBound($aCtrlTab, 1) - 1
        If $msg = $aCtrlTab[$a][0] Then
            _OwnTab_Switch($aCtrlTab, $a)
        EndIf
    Next
    For $a = 1 To UBound($aCtrlTab2, 1) - 1
        If $msg = $aCtrlTab2[$a][0] Then
            _OwnTab_Switch($aCtrlTab2, $a)
        EndIf
    Next
    For $a = 1 To UBound($aCtrlTab3, 1) - 1
        If $msg = $aCtrlTab3[$a][0] Then
            _OwnTab_Switch($aCtrlTab3, $a)
        EndIf
    Next
    Switch $msg
        ;Case $Button1
        ;   _OwnTab_SetAlarm($aCtrlTab, 4, 0xFF0000)
        ;Case $Button4
        ;   _OwnTab_ResetAlarm($aCtrlTab, 4)
        ;Case $BtnSet
        ;   _OwnTab_SetAlarm($aCtrlTab2, 2, 0x5050FF)
        ;Case $BtnReset
        ;   _OwnTab_ResetAlarm($aCtrlTab2, 2)
        ;Case $Button5
        ;   _OwnTab_Enable($aCtrlTab, 3)
        ;Case $Button6
        ;   _OwnTab_Disable($aCtrlTab, 3)
        ;Case $Button7
        ;   _OwnTab_Hide($aCtrlTab, 2)
        ;Case $Button8
        ;   _OwnTab_Show($aCtrlTab, 2)
        ;Case $Box1
        ;   If GUICtrlRead($Box1) = 1 Then
        ;       _OwnTab_Hover($aCtrlTab, 0xFFFF88, GUICtrlRead($Input1))
        ;   Else
        ;       _OwnTab_Hover($aCtrlTab, 0xFFFF88, 0)
        ;   EndIf
        ;Case $Input1
        ;   If GUICtrlRead($Box1) = 1 Then _OwnTab_Hover($aCtrlTab, 0xFFFF88, GUICtrlRead($Input1))
        Case -3
            Exit
    EndSwitch   
    Sleep(10)
WEnd

Visit my repository

Link to post
Share on other sites

It's long time ago I did something with my OwnTab-UDF. I hope now this works as expected.

Thanks for giving it a try!

#include "OwnTab.au3"

Local $hGui = GUICreate("TAB (in) TAB", 800, 450)
GUISetBkColor(0xbbbbbb)

$OwnTab_Style = 1
;   "CADASTRO","RELATÓRIOS","FERRAMENTAS","LABORATÓRIO","BACKUP","SAIR"
Local $aTabText[5] = [" MENU 01 ", " MENU 02 ", " MENU 03 ", " MENU 04 ", " MENU 05 "]
Local $aTabIcons[5][2] = [[""],[""],[""],[""],[""]]
Global $aCtrlTab = _OwnTab_Create($hGui, $aTabText, 10, 10, 780, 400, 30, 0xD5D5D5, 0xCFE0E7, 0xCFE0E7, $aTabIcons)
Local $aTabTip[5] = ["Dica Menu 01", "Dica Menu 02", "Dica Menu 03", "Dica Menu 04","Dica Menu 05"]
_OwnTab_SetTip($aCtrlTab, $aTabTip) ;set the tooltips for the OwnTab-control

#Region Tab1
_OwnTab_Add($aCtrlTab) ;Start controls tab1
GUICtrlCreateLabel("Etiqueta 01", 15, 43, 769, 20)

$OwnTab_Style = 0
Local $aTabText3[5] = ["SubMenu 01", "SubMenu 02", "SubMenu 03", "SubMenu 04", "SubMenu 05"] ;Declare the regions for the OwnTab-control
Local $aTabIcons3[5][2] = [[""],[""],[""],[""],[""]]
Global $aCtrlTab3 = _OwnTab_Create($hGui, $aTabText3, 20, 70, 760, 330, 30, 0xD5D5D5, 0x00ffdd, 0x00ffdd, $aTabIcons3)
Local $aTabTip3[5] = ["...01", "...02","...03", "...04","...05"]
_OwnTab_SetTip($aCtrlTab3, $aTabTip3) ;set the tooltips for the OwnTab-control

#Region SubTab1
_OwnTab_Add($aCtrlTab3) ;Start controls tab1
GUICtrlCreateLabel("01", 30, 103, 739, 20)
#EndRegion SubTab1

#Region SubTab2
_OwnTab_Add($aCtrlTab3) ;Start controls tab2
GUICtrlCreateLabel("02", 30, 103, 739, 20)
#EndRegion SubTab2

#Region SubTab3
_OwnTab_Add($aCtrlTab3) ;Start controls tab2
GUICtrlCreateLabel("03", 30, 103, 739, 20)
#EndRegion SubTab3

#Region SubTab4
_OwnTab_Add($aCtrlTab3) ;Start controls tab2
GUICtrlCreateLabel("04", 30, 103, 739, 20)
#EndRegion SubTab4

#Region SubTab5
_OwnTab_Add($aCtrlTab3) ;Start controls tab2
GUICtrlCreateLabel("05", 30, 103, 739, 20)
#EndRegion SubTab5

_OwnTab_End($aCtrlTab3)
_OwnTab_Switch($aCtrlTab3,1,0)

#EndRegion Tab1

#Region Tab2
_OwnTab_Add($aCtrlTab) ;Start controls tab2
GUICtrlCreateLabel("Etiqueta 02", 15, 43, 769, 20)
#EndRegion Tab2

#Region Tab3
_OwnTab_Add($aCtrlTab) ;Start controls tab3
GUICtrlCreateLabel("Etiqueta 03", 15, 43, 769, 20)
#EndRegion Tab3

#Region Tab4
_OwnTab_Add($aCtrlTab) ;Start controls tab4
GUICtrlCreateLabel("Etiqueta 04", 15, 43, 769, 20)
#EndRegion Tab4

#Region Tab5
_OwnTab_Add($aCtrlTab) ;Start controls tab5
GUICtrlCreateLabel("Etiqueta 05", 15, 43, 769, 20)
$OwnTab_Style = 0
Local $aTabText2[5] = ["SubMenu 01", "SubMenu 02", "SubMenu 03", "SubMenu 04", "SubMenu 05"] ;Declare the regions for the OwnTab-control
Local $aTabIcons2[5][2] = [[""],[""],[""],[""],[""]]
Global $aCtrlTab2 = _OwnTab_Create($hGui, $aTabText2, 20, 70, 760, 330, 30, 0xD5D5D5, 0x00ff00, 0x00ff00, $aTabIcons2)
Local $aTabTip2[5] = ["...01", "...02","...03", "...04","...05"]
_OwnTab_SetTip($aCtrlTab2, $aTabTip2) ;set the tooltips for the OwnTab-control

#Region SubTab1
_OwnTab_Add($aCtrlTab2) ;Start controls tab1
GUICtrlCreateLabel("01", 30, 103, 739, 20)
#EndRegion SubTab1

#Region SubTab2
_OwnTab_Add($aCtrlTab2) ;Start controls tab2
GUICtrlCreateLabel("02", 30, 103, 739, 20)
#EndRegion SubTab2

#Region SubTab3
_OwnTab_Add($aCtrlTab2) ;Start controls tab2
GUICtrlCreateLabel("03", 30, 103, 739, 20)
#EndRegion SubTab3

#Region SubTab4
_OwnTab_Add($aCtrlTab2) ;Start controls tab2
GUICtrlCreateLabel("04", 30, 103, 739, 20)
#EndRegion SubTab4

#Region SubTab5
_OwnTab_Add($aCtrlTab2) ;Start controls tab2
GUICtrlCreateLabel("05", 30, 103, 739, 20)
#EndRegion SubTab5

_OwnTab_End($aCtrlTab2)
_OwnTab_Switch($aCtrlTab2, 1,0)
#EndRegion Tab5

_OwnTab_End($aCtrlTab) ;new: end control-definition AND inizialize the OwnTab

_OwnTab_Switch($aCtrlTab3, 1, 1)

_OwnTab_Disable($aCtrlTab, 3) ;new: disable tabitems
_OwnTab_SetFontCol($aCtrlTab, 0xFF) ;new: set font-color

GUISetState()
_OwnTab_Hover($aCtrlTab, 0xFFFF88,0,200) ;start hover-function if you want

Local $msg

While 1
    $msg = GUIGetMsg()
    For $a = 1 To UBound($aCtrlTab, 1) - 1
        If $msg = $aCtrlTab[$a][0] Then
            _OwnTab_Switch($aCtrlTab, $a)
            If $a = 1 Then
                _OwnTab_Switch($aCtrlTab3, $aCtrlTab3[0][0], 1)
   ElseIf $a = 5 Then
                _OwnTab_Switch($aCtrlTab2, $aCtrlTab2[0][0], 1)
            EndIf
        EndIf
    Next
    For $a = 1 To UBound($aCtrlTab2, 1) - 1
        If $msg = $aCtrlTab2[$a][0] Then
            _OwnTab_Switch($aCtrlTab2, $a)
        EndIf
    Next
    For $a = 1 To UBound($aCtrlTab3, 1) - 1
        If $msg = $aCtrlTab3[$a][0] Then
            _OwnTab_Switch($aCtrlTab3, $a)
        EndIf
    Next
    Switch $msg
        ;Case $Button1
        ;   _OwnTab_SetAlarm($aCtrlTab, 4, 0xFF0000)
        ;Case $Button4
        ;   _OwnTab_ResetAlarm($aCtrlTab, 4)
        ;Case $BtnSet
        ;   _OwnTab_SetAlarm($aCtrlTab2, 2, 0x5050FF)
        ;Case $BtnReset
        ;   _OwnTab_ResetAlarm($aCtrlTab2, 2)
        ;Case $Button5
        ;   _OwnTab_Enable($aCtrlTab, 3)
        ;Case $Button6
        ;   _OwnTab_Disable($aCtrlTab, 3)
        ;Case $Button7
        ;   _OwnTab_Hide($aCtrlTab, 2)
        ;Case $Button8
        ;   _OwnTab_Show($aCtrlTab, 2)
        ;Case $Box1
        ;   If GUICtrlRead($Box1) = 1 Then
        ;       _OwnTab_Hover($aCtrlTab, 0xFFFF88, GUICtrlRead($Input1))
        ;   Else
        ;       _OwnTab_Hover($aCtrlTab, 0xFFFF88, 0)
        ;   EndIf
        ;Case $Input1
        ;   If GUICtrlRead($Box1) = 1 Then _OwnTab_Hover($aCtrlTab, 0xFFFF88, GUICtrlRead($Input1))
        Case -3
            Exit
    EndSwitch   
    Sleep(10)
WEnd
Edited by funkey

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to post
Share on other sites

Here is an other form of own tabs. It is using a ListView control. You can use for example for vertical tab controls. ust try it and tell me what you think.

#Include <WindowsConstants.au3>
#Include <Constants.au3>
#Include <GuiListView.au3>
#include <GuiImageList.au3>
#Include <Array.au3>


Global $hGui = GUICreate("OwnTab2 - vertical ListView", 600, 500)

Global $nLV = GUICtrlCreateListView("", 8, 8, 80, 484, -1, $LVS_EX_SUBITEMIMAGES)
Global $hLV = GUICtrlGetHandle(-1)

Global $iItems = Random(3, 20, 1), $Item_sel = Random(0, $iItems - 1, 1), $Item_sel_old = $Item_sel
Global $aLV_Item[$iItems], $ahChild[$iItems]

For $i = 0 To $iItems - 1
 $aLV_Item[$i] = GUICtrlCreateListViewItem("Tab_"& $i, $nLV)
 _GUICtrlListView_SetItemImage($hLV, $i, $i)
 $ahChild[$i] = GUICreate("Child" & $i, 490, 484, 100, 8, $WS_CHILD, 0, $hGui)
 GUISetBkColor(Random(0x111111, 0x999999, 1))
 GUICtrlCreateButton("Button in Register " & $i, 20 + $i*10, 20 + $i*20, 200, 30)
 GUISetState(@SW_HIDE)
Next

; Load images
Global $Bitmaps = _WinAPI_LoadBitmap(_WinAPI_LoadLibrary("shell32.dll"), 216)
Global $hImage = _GUIImageList_Create()
_GUIImageList_Add($hImage, $Bitmaps)
_GUICtrlListView_SetImageList($hLV, $hImage, 0)

_GUICtrlListView_SetView($hLV, 1)

GUISetState(@SW_SHOW, $ahChild[$Item_sel])
_GUICtrlListView_SetItemSelected($hLV, $Item_sel, 1)
_GUICtrlListView_EnsureVisible($hLV, $Item_sel)

GUISwitch($hGui)
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

 

Global $msg

While 1
 $msg = GUIGetMsg()
 If $msg = -3 Then ExitLoop
 Sleep(10)
WEnd

Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
 Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
 Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
 Local $idFrom =DllStructGetData($tNMHDR, "idFrom")
 Local $iCode = DllStructGetData($tNMHDR, "Code")
 If $hWndFrom = $hLV Then
  Switch $iCode
   Case -101
    $Item_sel = _ArraySearch($aLV_Item, GUICtrlRead($idFrom))
    If $Item_sel >= 0 And $Item_sel_old <> $Item_sel Then
     GUISetState(@SW_SHOW, $ahChild[$Item_sel])
     GUISetState(@SW_HIDE, $ahChild[$Item_sel_old])
     $Item_sel_old = $Item_sel
    EndIf
  EndSwitch 
 EndIf
 Return "GUI_RUNDEFMSG"
EndFunc

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to post
Share on other sites

funkey nice idea :>

This version has Icons working from shell32.dll :unsure:

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <Array.au3>
#include <GUIImageList.au3>
#include <GUIListView.au3>
#include <WindowsConstants.au3>

Global $hListView
Global $iItems = Random(3, 7, 1), $iItemSelection = Random(0, $iItems - 1, 1), $iItemSelection_Old = $iItemSelection
Global $aListViewItem[$iItems], $aChildGUI[$iItems]

_Main()

Func _Main()
    Local $hGUI = GUICreate("ListView Tab", 600, 500)
    Local $iListView = GUICtrlCreateListView("", 8, 8, 80, 484, -1, $LVS_EX_SUBITEMIMAGES)
    $hListView = GUICtrlGetHandle(-1)

    Local $hImageList = _GUIImageList_Create(16, 16, 5, 3)
    For $A = 1 To $iItems
        _GUIImageList_AddIcon($hImageList, @SystemDir & "\shell32.dll", Random(1, 200, 1))
    Next
    _GUICtrlListView_SetImageList($hListView, $hImageList, 0)

    For $A = 0 To $iItems - 1
        $aListViewItem[$A] = GUICtrlCreateListViewItem("Tab_" & $A, $iListView)
        _GUICtrlListView_SetItemImage($hListView, $A, $A)

        $aChildGUI[$A] = GUICreate("Child" & $A, 490, 484, 100, 8, $WS_CHILD, 0, $hGUI)
        GUISetBkColor(Random(0x111111, 0x999999, 1))
        GUICtrlCreateButton("Button In Register " & $A, 20 + $A * 10, 20 + $A * 20, 200, 30)
        GUISetState(@SW_HIDE)
    Next
    _GUICtrlListView_SetView($hListView, 1)

    GUISetState(@SW_SHOW, $aChildGUI[$iItemSelection])
    _GUICtrlListView_SetItemSelected($hListView, $iItemSelection, 1)
    _GUICtrlListView_EnsureVisible($hListView, $iItemSelection)

    GUISwitch($hGUI)
    GUISetState(@SW_SHOW)
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    While 1
        Switch GUIGetMsg()
            Case -3
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>_Main

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    Local $idFrom = DllStructGetData($tNMHDR, "idFrom")
    Local $iCode = DllStructGetData($tNMHDR, "Code")
    If $hWndFrom = $hListView Then
        Switch $iCode
            Case -101
                $iItemSelection = _ArraySearch($aListViewItem, GUICtrlRead($idFrom))
                If $iItemSelection >= 0 And $iItemSelection_Old <> $iItemSelection Then
                    GUISetState(@SW_SHOW, $aChildGUI[$iItemSelection])
                    GUISetState(@SW_HIDE, $aChildGUI[$iItemSelection_Old])
                    $iItemSelection_Old = $iItemSelection
                EndIf
        EndSwitch
    EndIf
    Return "GUI_RUNDEFMSG"
EndFunc   ;==>WM_NOTIFY

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to post
Share on other sites

Thx guiness for that. With bigger Icons it looks nicer!

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <Array.au3>
#include <GUIImageList.au3>
#include <GUIListView.au3>
#include <WindowsConstants.au3>

Global $hListView
Global $iItems = Random(3, 20, 1), $iItemSelection = Random(0, $iItems - 1, 1), $iItemSelection_Old = $iItemSelection
Global $aListViewItem[$iItems], $aChildGUI[$iItems]

_Main()

Func _Main()
    Local $hGUI = GUICreate("Vertical ListView Tab", 600, 500)
    Local $iListView = GUICtrlCreateListView("", 8, 8, 135, 484, -1, $LVS_EX_SUBITEMIMAGES)
    $hListView = GUICtrlGetHandle(-1)

    Local $hImageList = _GUIImageList_Create(32, 32, 5, 3)
    For $A = 1 To $iItems
        _GUIImageList_AddIcon($hImageList, @SystemDir & "\shell32.dll", Random(1, 200, 1), 1)
    Next
    _GUICtrlListView_SetImageList($hListView, $hImageList, 0)

    For $A = 0 To $iItems - 1
        $aListViewItem[$A] = GUICtrlCreateListViewItem("Tab description " & $A, $iListView)
        _GUICtrlListView_SetItemImage($hListView, $A, $A)

        $aChildGUI[$A] = GUICreate("Child" & $A, 440, 484, 150, 8, $WS_CHILD, 0, $hGUI)
        GUISetBkColor(Random(0x111111, 0x999999, 1))
        GUICtrlCreateButton("Button In Register " & $A, 20 + $A * 10, 20 + $A * 20, 200, 30)
        GUISetState(@SW_HIDE)
    Next
    _GUICtrlListView_SetView($hListView, 1)

    GUISetState(@SW_SHOW, $aChildGUI[$iItemSelection])
    _GUICtrlListView_SetItemSelected($hListView, $iItemSelection, 1)
    _GUICtrlListView_EnsureVisible($hListView, $iItemSelection)

    GUISwitch($hGUI)
    GUISetState(@SW_SHOW)
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    While 1
        Switch GUIGetMsg()
            Case -3
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>_Main

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    Local $idFrom = DllStructGetData($tNMHDR, "idFrom")
    Local $iCode = DllStructGetData($tNMHDR, "Code")
    If $hWndFrom = $hListView Then
        Switch $iCode
            Case -101
                $iItemSelection = _ArraySearch($aListViewItem, GUICtrlRead($idFrom))
                If $iItemSelection >= 0 And $iItemSelection_Old <> $iItemSelection Then
                    GUISetState(@SW_SHOW, $aChildGUI[$iItemSelection])
                    GUISetState(@SW_HIDE, $aChildGUI[$iItemSelection_Old])
                    $iItemSelection_Old = $iItemSelection
                EndIf
        EndSwitch
    EndIf
    Return "GUI_RUNDEFMSG"
EndFunc   ;==>WM_NOTIFY

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to post
Share on other sites
  • 2 weeks later...

You should add a $WS_EX_CONTROLPARENT to your child-GUIs. Then keyboard-navigation via tab will work.

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to post
Share on other sites

Thanks ProgAndy for your advice. Now it is a bit moe comfortable to handle. But why is WS_EX_CONTROLPARENT not in the AutoIt documentation?

@detefon: You are welcome!

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to post
Share on other sites

Thanks ProgAndy for your advice. Now it is a bit moe comfortable to handle. But why is WS_EX_CONTROLPARENT not in the AutoIt documentation?

@detefon: You are welcome!

It is on GUICreate() page, (do a search!), but not very well explained. See MSDN for details <--- link

MSDN is da :unsure:

:>

Link to post
Share on other sites
  • 4 years later...

Sorry for my bad endglisch. I hope you understand yet what I want.

This is a very nice and usefull UDF. Thanks for that :-)

But i have a big problem: Can anyone tell me why the "switch" does not work in my script below between the individual tabs to me?

 

#NoTrayIcon
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Clipboard.au3>
#include <Date.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIShellEx.au3>
#include <GuiMenu.au3>
#include <WinAPI.au3>
#include <TrayConstants.au3>
;#include ".\settings.au3"
;#include ".\newentry.au3"
;#include ".\editentry.au3"
;#include ".\delentry.au3"
;#include ".\drucken.au3"
;#include ".\update.au3"
;#include ".\ping.au3"
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <StaticConstants.au3>
#include <Array.au3>
#include <GuiListView.au3>
#include <Word.au3>
#include <String.au3>
#include <Timers.au3>
#include "OwnTab.au3"

FileInstall("hilfe.gif", @TempDir & "\")
FileInstall("sqlite3.dll", @TempDir & "\")



Opt("GUIOnEventMode", 1)
Opt('TrayOnEventMode', 1)
Opt('TrayMenuMode', 1)

Global $g_idExit, $aQuery, $aRow, $listview, $aResult, $iRows, $iColumns, $iRval, $sItem, $ttest, $setfunc, $sethkey, $manueltext, $okey, $otext, $resettings, $e_newEntry, $e_editEntry, $replace, $g_zeit, $First3Lines1, $vQuery, $vRow, $version, $guiversion
Global Enum $e_ftasten = 1000, $e_idOpen, $e_idSave, $e_idExit, $e_options, $e_idCopy, $e_idPaste, $e_idAbout, $fprint, $e_UpdateDB, $e_hilfe


_Main()

Func _Main()

    Global $hGUI = GUICreate("Smile Tool", 600, 520, -1, $WS_EX_ACCEPTFILES)
    GUISetBkColor(0x000000)

    GUICtrlSetDefBkColor(0x000000)
    GUICtrlSetDefColor(0xFFB400)

    ; Create File menu
    $hFile = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hFile, 0, "F-Tasten drucken", $e_ftasten)
    _GUICtrlMenu_InsertMenuItem($hFile, 1, "", 0)
    _GUICtrlMenu_InsertMenuItem($hFile, 2, "Beenden", $e_idExit)

    ; Create Options menu
    $hOptions = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hOptions, 0, "Optionen", $e_options)

    ; Create Help menu
    $hHelp = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hHelp, 0, "Hilfe", $e_hilfe)
    _GUICtrlMenu_InsertMenuItem($hHelp, 1, "About", $e_idAbout)

    ; Create Main menu
    $hMain = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hMain, 0, "&File", 0, $hFile)
    _GUICtrlMenu_InsertMenuItem($hMain, 1, "&Einstellungen", 0, $hOptions)
    _GUICtrlMenu_InsertMenuItem($hMain, 2, "&Help", 0, $hHelp)

    ; Set window menu
    _GUICtrlMenu_SetMenu($hGUI, $hMain)

    Local $aTabText[3] = [" Texte ", " Ping ", " Traceroute "]
    Local $aTabIcons[3][2] = [[""],[""],[""]]
    Global $aCtrlTab = _OwnTab_Create($hGui, $aTabText, 5, 5, 590, 48, 30, 0x000000, 0x000000, 0x000000, $aTabIcons)
    Local $aTabTip[3] = ["Texte", "Ping", "Traceroute"]
    _OwnTab_SetTip($aCtrlTab, $aTabTip) ;set the tooltips for the OwnTab-control

    #Region Tab1
    _OwnTab_Add($aCtrlTab) ;Start controls tab1

    GUICtrlCreateLabel("Nachfolgend werden alle bisher eingerichteten Texte mit entsprechendem HotKey angezeigt." & @CRLF & "Um die Texte nutzen zu können, einfach den entsprechenden HotKey auf der Tastatur drücken.", 10, 50)
    $listview = GUICtrlCreateListView("Name|Text|Hotkey|3Zeiler", 5, 60, 590, 400)
    GUICtrlSetColor(-1, 0xFFB400)
    GUICtrlSetBkColor(-1, 0x000000)
    _GUICtrlListView_SetColumnWidth($listview, 0, 150)
    _GUICtrlListView_SetColumnWidth($listview, 1, 295)
    _GUICtrlListView_SetColumnWidth($listview, 2, 50)
    _GUICtrlListView_SetColumnWidth($listview, 3, 50)

    ; Hilfe
    ;Global $hilfepic = GUICtrlCreatePic(@TempDir & "\hilfe.gif", 570, 5, 20, 20)
    ;GUICtrlSetOnEvent($hilfepic, "_Hilfe")
    ;GUICtrlSetCursor($hilfepic, 4)

    ; Button unten links
    $e_newEntry = GUICtrlCreateButton("Neuen Eintrag hinzufügen", 50, 450, 150, 30)
    GUICtrlSetOnEvent($e_newEntry, "o_NewEntry")
    $e_editEntry = GUICtrlCreateButton("Eintrag bearbeiten", 220, 450, 150, 30)
    GUICtrlSetOnEvent($e_editEntry, "o_EditEntry")
    $e_DelEntry = GUICtrlCreateButton("Eintrag löschen", 390, 450, 150, 30)
    GUICtrlSetOnEvent($e_DelEntry, "o_DelEntry")
    #EndRegion Tab1

    #Region Tab2
    _OwnTab_Add($aCtrlTab) ;Start controls tab2

    ; Rechte Seite, Ping und Traceroute
    GUICtrlCreateLabel("Im nachfolgenden kannst Du ein Pingtest auf einen Host oder eine IP durchführen:" & @CRLF & "(Bitte beachte, Ergebnis erscheint erst nach vollständigem Pingtest)", 10, 50, 400, 30)
    GUICtrlCreateLabel("Bitte Host oder IP eingeben", 10, 90, 200, 15)
    GUICtrlSetColor(-1, 0xFFB400)
    Global $host = GUICtrlCreateInput("", 10, 110, 200, 20)
    GUICtrlCreateLabel("Bitte Anzahl der Pings angeben", 10, 140, 200, 15)
    GUICtrlSetColor(-1, 0xFFB400)
    Global $count = GUICtrlCreateInput("", 10, 160, 200, 20)
    Global $e_pingtest = GUICtrlCreateButton("Ping ausführen", 10, 190, 150, 30)
    GUICtrlSetOnEvent($e_pingtest, "o_pingtest")
    ;Global $pingergebnis = GUICtrlCreateEdit("", 650, 190, 500, 250, $ES_AUTOVSCROLL + $WS_VSCROLL)
    GUICtrlCreateLabel("Ergebnis des Pings zu:", 10, 220, 130, 15)
    Global $e_ip = GUICtrlCreateLabel("na", 140, 220, 120, 20)
    GUICtrlSetFont(-1, 8.5, 700, 4)
    #EndRegion Tab2

    #Region Tab3
    _OwnTab_Add($aCtrlTab) ;Start controls tab3
    GUICtrlCreateLabel("Etiqueta 03", 15, 43, 400, 20)
    #EndRegion Tab3

    _OwnTab_End($aCtrlTab) ;new: end control-definition AND inizialize the OwnTab
    _OwnTab_SetFontCol($aCtrlTab, 0xFFB400) ;new: set font-color


    ; Copyright
    GUICtrlCreateLabel("© 2015 - Erstellt von: Stefan Streif", 180, 485, 200, 15)
    $guiversion = GUICtrlCreateLabel("", 390, 485, 150, 15)
    GUICtrlSetColor(-1, 0xFFB400)

    ; Exit und Minimize
    GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit")
    GUISetOnEvent($GUI_EVENT_MINIMIZE, '_Minimize')
    TraySetOnEvent(-7, '_Restore')

    GUISetState() ; display the GUI
    _OwnTab_Hover($aCtrlTab, 0x333333,0,200) ;start hover-function if you want
    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    _SETTINGS($resettings = "0")

    _Timer_SetTimer($hGUI, 1000, "_UpdateClock") ; create timer

    Local $msg

    While 1
        $msg = GUIGetMsg()
        For $a = 1 To UBound($aCtrlTab, 1) - 1
            If $msg = $aCtrlTab[$a][0] Then
                _OwnTab_Switch($aCtrlTab, $a)
            EndIf
        Next
        Switch $msg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
        Sleep(1000)
    WEnd
EndFunc   ;==>_Main

Func _SETTINGS($resettings)
    If $resettings = "1" Then
        _GUICtrlListView_DeleteAllItems($listview)
    EndIf
    _SQLite_Startup(@TempDir & "\sqlite3.dll", False, 1)
    ;_SQLite_Startup()
    If @error Then Exit MsgBox(16, "SQLite Fehler", "SQLite.dll konnte nicht geladen werden!")
    If FileExists("settings.sqlite") Then
        $hDB = _SQLite_Open("settings.sqlite")
        If @error Then Exit MsgBox(16, "SQLite Fehler", "1 - Kann die Datenbank nicht öffnen!")

        ; DB Abfrage der Version aus "settings"
        _SQLite_Query($hDB, "SELECT version FROM settings", $vQuery)
        If @error Then
            MsgBox(16, "SQLite Fehler", "Die Datenbank ist nicht mehr aktuell. Nach Klick auf Ok, wird diese aktualisiert!")
            _UpdateDB()
            _NeustartNachDrucken()
        Else
                While _SQLite_FetchData($vQuery, $vRow, False, True) = $SQLITE_OK
                    If $vRow[0] < "2.0" Then
                        MsgBox(16, "SQLite Fehler", "Die Datenbank ist nicht mehr aktuell. Nach Klick auf Ok, wird diese aktualisiert!")
                        _UpdateDB2()
                        _NeustartNachDrucken()
                    EndIf
                WEnd
        EndIf

        _SQLite_Query($hDB, "SELECT * FROM settings", $aQuery)
        ; Auslesen der nächsten Zeile
        While _SQLite_FetchData($aQuery, $aRow, False, True) = $SQLITE_OK
            Global $uLine1 = $aRow[1]
            Global $uLine2 = $aRow[2]
            Global $uLine3 = $aRow[3]
            Global $sPaste = $aRow[4]
            Global $version = "Version " & $aRow[5]
        WEnd
        GUICtrlSetData($guiversion, $version)
        If _SQLite_GetTable2d($hDB, "Select subject,text,key,dreizeiler From texte WHERE active='1'", $aResult, $iRows, $iColumns) = $SQLITE_OK Then
            For $iR = 1 To $iRows
                $sItem = ""
                For $iC = 0 To $iColumns - 1
                    ;$replace = $aResult[$iR][$iC]
                    ;$replace = StringReplace($replace, "{", "")
                    ;$replace = StringReplace($replace, "}", "")
                    $sItem &= $aResult[$iR][$iC] & "|"
                Next
                GUICtrlCreateListViewItem(StringTrimRight($sItem, 1), $listview)
            Next
        Else
            MsgBox($MB_SYSTEMMODAL, "SQLite Error: " & _SQLite_ErrMsg())
        EndIf
        Global $First3Lines = $uLine1 & @CRLF & $uLine2 & @CRLF & $uLine3 & @CRLF
        ;Am Skriptanfang
        Global $oDict = ObjCreate("Scripting.Dictionary")
        _SQLite_Query($hDB, "SELECT text,key From texte WHERE active='1'", $aQuery)
        ; Auslesen der nächsten Zeile
        While _SQLite_FetchData($aQuery, $aRow, False, False) = $SQLITE_OK
            $aRow[1] = StringReplace($aRow[1], "+", "")
            $aRow[1] = StringReplace($aRow[1], "STRG", "^")
            $aRow[1] = StringReplace($aRow[1], "ALT", "!")
            $aRow[1] = StringReplace($aRow[1], "Shift", "+")
            $oDict($aRow[1]) = $aRow[0] ;((key)) : text
            HotKeySet($aRow[1], "ssf")
        WEnd
        _SQLite_QueryFinalize($aQuery)
        _SQLite_Close()
        _SQLite_Shutdown()
    Else
        MsgBox(16, "SQLite Fehler", "Die Datenbank wurde nicht gefunden!" & @CRLF & "Es werden nun die 'Einstellungen' geöffnet," & @CRLF & "um eine neue Datenbank zu erstellen!")
        _OPTIONS()
    EndIf
EndFunc   ;==>_SETTINGS

; Handle menu commands
Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam
    Switch _WinAPI_LoWord($wParam)
        Case $e_ftasten
            fprint()
        Case $e_idExit
            Exit
        Case $e_options
            _OPTIONS()
        Case $e_hilfe
            _Hilfe()
        Case $e_idAbout
            MsgBox(BitOR($MB_OK, $MB_ICONINFORMATION, $MB_DEFBUTTON1, $MB_SYSTEMMODAL, $MB_SETFOREGROUND), 'About', 'Dieses Tool wurde geschrieben von:' & @CRLF & @CRLF & 'Stefan Streif' & @CRLF & 'Technical Support' & @CRLF & 'NL Villingen-Schwenningen' & @CRLF & 'Tel: 07721 6806 29470' & @CRLF & @CRLF & $version)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

; --------------- Functions ---------------
Func _UpdateClock($hWnd, $iMsg, $iIDTimer, $iTime)
    #forceref $hWnd, $iMsg, $iIDTimer, $iTime
    Global $g_zeit = StringFormat("%02d:%02d", @HOUR, @MIN)
    ;MsgBox(0, "Zeit", "Aktuelle Zeit ist: "& $g_zeit, 2)
EndFunc   ;==>_UpdateClock

Func ssf()
    $First3Lines1 = $First3Lines
    $First3Lines1 = StringReplace($First3Lines1, "%datum%", _NowDate())
    $First3Lines1 = StringReplace($First3Lines1, "%zeit%", $g_zeit)
    $First3Lines1 = StringReplace($First3Lines1, "%name%", @UserName)
    _ClipBoard_SetData($First3Lines1 & $oDict(@HotKeyPressed) & @CRLF)
    ;_ClipBoard_SetData($uline1 & _NowDate() &" / "& $g_zeit &" / "& @UserName & @CRLF & $oDict(@HotKeyPressed) & @CRLF)
    If $sPaste = "1" Then Send("^v")
EndFunc   ;==>ssf

Func fprint()
    Local $iMsgBoxAnswer
    $iMsgBoxAnswer = MsgBox(4145, "F-Tastenbelegung drucken", "Wenn du auf 'OK' klickst, wird der Druckauftrag sofort gestartet und auf dem in Windows definierten Standard Drucker gedruckt.")
    Select
        Case $iMsgBoxAnswer = 1 ;OK
            d_ftasten()
        Case $iMsgBoxAnswer = 2 ;Cancel
    EndSelect
EndFunc   ;==>fprint

Func _Hilfe()
    MsgBox(BitOR($MB_ICONQUESTION, $MB_SYSTEMMODAL), 'Generelle Hilfe', 'Du befindest im Hauptprogramm.' & @CRLF & @CRLF & 'Hier bekommst Du die aktuell eingerichteten Texte mit den entsprechenden Hotkeys angezeigt.' & @CRLF & @CRLF & _
            'Um diese nutzen zu können, einfach die entsprechend angezeigte HotKey Kombination auf der Tastatur drücken.' & @CRLF & 'Des Weiteren kannst Du in diesem Bereich auch neue Texte anlegen, bestehende bearbeiten oder löschen.' & @CRLF & @CRLF & _
            '"Bearbeiten"' & @CRLF & 'Um ein bestehenden Text zu bearbeiten, diesen in der Auflistung anklicken und den Button "Eintrag bearbeiten" betätigen.' & @CRLF & @CRLF & _
            '"Löschen"' & @CRLF & 'Um ein bestehenden Text zu löschen, diesen in der Auflistung anklicken und den Button "Eintrag löschen" betätigen.' & @CRLF & @CRLF & _
            'Solltest Du weitergehende Hilfe brauchen, dann klicke im Menü oben auf "Hilfe" -> "About" und kontaktiere den dort angegebenen Autor dieses Tools.')
EndFunc   ;==>_Hilfe

Func _NeustartNachDBErstellung()
    MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), 'Information', 'Die Datenbank wurde erstellt. Das Tool wird nach drücken des "OK" Buttons neu gestartet, damit die eben erstellte Datenbank eingelesen und die Einstellungen übernommen werden können.')
    Exit Run(@ScriptFullPath)
EndFunc   ;==>_NeustartNachDBErstellung

Func _NeustartNachDrucken()
    Exit Run(@ScriptFullPath)
EndFunc   ;==>_NeustartNachDrucken

Func OnExit()
    Exit
EndFunc   ;==>OnExit

Func o_NewEntry()
    _NewEntry()
EndFunc   ;==>o_NewEntry

Func o_EditEntry()
    Local $editItem_id = _GUICtrlListView_GetSelectionMark($listview)
    If $editItem_id = -1 Then
        MsgBox(0, "Fehler", "Du hast vergessen, zuvor einen Eintrag auszuwählen. Sowas ist natürlich ganz schlecht, wenn Du etwas bearbeiten willst!")
    Else
        Global $editItem = _GUICtrlListView_GetItemText($listview, $editItem_id, 2)
        _EditEntry($editItem)
    EndIf
EndFunc   ;==>o_EditEntry

Func o_DelEntry()
    Local $DelItem_id = _GUICtrlListView_GetSelectionMark($listview)
    If $DelItem_id = -1 Then
        MsgBox(0, "Fehler", "Du hast vergessen, zuvor einen Eintrag auszuwählen. Sowas ist natürlich ganz schlecht, wenn Du etwas löschen willst!")
    Else
        Global $DelItem = _GUICtrlListView_GetItemText($listview, $DelItem_id, 2)
        _DelEntry($DelItem)
    EndIf
EndFunc   ;==>o_DelEntry

Func _Minimize()
    TraySetState(1)
    GUISetState(@SW_HIDE)
EndFunc   ;==>_Minimize

Func _Restore()
    TraySetState(2)
    GUISetState(@SW_SHOW)
EndFunc   ;==>_Restore

Func o_pingtest()
    Local $p_host = GUICtrlRead($host)
    Local $p_count = GUICtrlRead($count)
    _ping($p_count, $p_host)
EndFunc   ;==>o_pingtest

 

Link to post
Share on other sites

Changed two or three lines in files in post #1 to let the script work with actual version of AutoIt.

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

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