Juno_okyo

Multiline Tab Control Example

Jun 20th, 2015
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.82 KB | None | 0 0
  1. ;=> Author: Melba23
  2. #include <GUIConstantsEx.au3>
  3. #include <WindowsConstants.au3>
  4. #include <StaticConstants.au3>
  5. #include <GuiTab.au3>
  6. #include <WinAPI.au3>
  7.  
  8. Opt("GUIResizeMode", $GUI_DOCKALL)
  9.  
  10. $hGUI_Main = GUICreate("Test", 500, 500)
  11.  
  12. $cButton_1 = GUICtrlCreateButton('Create Tab', 20, 450, 70, 20)
  13. $cButton_2 = GUICtrlCreateButton('Delete Tab', 120, 450, 70, 20)
  14. $cTab = GUICtrlCreateTab(0, 0, 500, 400, $TCS_MULTILINE)
  15. GUICtrlCreateTabItem('Tab_0')
  16. GUICtrlCreateTabItem('')
  17.  
  18. GUISetState()
  19.  
  20. $hGUI_Child = GUICreate("", 500, 400, 0, 0, $WS_POPUP, BitOr($WS_EX_MDICHILD, $WS_EX_LAYERED), $hGUI_Main)
  21. GUISetBkColor(0xABCDEF)
  22. _WinAPI_SetLayeredWindowAttributes($hGUI_Child, 0xABCDEF, 250)
  23.  
  24. $cButton_3 = GUICtrlCreateButton('Test', 20, 30, 200, 20, $ss_sunken)
  25. $cInput = GUICtrlCreateInput('', 20, 60, 100, 20)
  26.  
  27. GUISetState()
  28.  
  29. GUISwitch($hGUI_Main)
  30.  
  31. $iTabY = -1
  32. _CheckTab()
  33.  
  34. $iCount = 0
  35.  
  36. While 1
  37.     Switch GUIGetMsg()
  38.         Case $GUI_EVENT_CLOSE
  39.             Exit
  40.         Case $cButton_3
  41.             ConsoleWrite('clicked button in tab item ' & GUICtrlRead($cTab) & @CRLF)
  42.         Case $cButton_1
  43.             $iCount += 1
  44.             GUICtrlCreateTabItem('Tab_' & $iCount)
  45.             GUICtrlCreateTabItem('')
  46.             _CheckTab()
  47.         Case $cButton_2
  48.             GUICtrlDelete(GUICtrlRead($cTab, 1))
  49.             _CheckTab()
  50.     EndSwitch
  51. WEnd
  52.  
  53. Func _CheckTab()
  54.  
  55.     $aTabRect = _GUICtrlTab_GetDisplayRect(GUICtrlGetHandle($cTab))
  56.     If $aTabRect[1] <> $iTabY And $aTabRect[3] - $aTabRect[1] > 100 Then
  57.         $tPoint = DllStructCreate("int X;int Y")
  58.         DllStructSetData($tPoint, "X", $aTabRect[0])
  59.         DllStructSetData($tPoint, "Y", $aTabRect[1])
  60.         _WinAPI_ClientToScreen($hGUI_Main, $tPoint)
  61.         $iX = DllStructGetData($tPoint, "X")
  62.         $iY = DllStructGetData($tPoint, "Y")
  63.         WinMove($hGUI_Child, "", $iX, $iY, $aTabRect[2] - $aTabRect[0], $aTabRect[3] - $aTabRect[1])
  64.         $iTabY = $aTabRect[1]
  65.     EndIf
  66.  
  67. EndFunc
Add Comment
Please, Sign In to add comment