Что нового

Можно ли сделать GuiCtrlCreateTab в GuiCtrlCreateTab-ле ?

agikon

Знающий
Сообщения
789
Репутация
16
ну например есть
Код:
$0 = GuiCtrlCreateTab(10, 10, 300, 100)
$1 = GuiCtrlCreateTabItem("1")
$2 = GuiCtrlCreateTabItem("2")


а в вкладке $2 = GuiCtrlCreateTabItem("2") создать вот ещё GuiCtrlCreateTab

Код:
$00 = GuiCtrlCreateTab(10, 10, 100, 50)
$a = GuiCtrlCreateTabItem("a")
$b = GuiCtrlCreateTabItem("b")
 

CreatoR

Must AutoIt!
Команда форума
Администратор
Сообщения
8 473
Репутация
2 403
Код:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <TabConstants.au3>
#include <ListViewConstants.au3>
#include <GUIImageList.au3>

Global $hImageList = 0

$Main_GUI = GUICreate("Tab Sample", 400, 300, -1, -1) ;, BitOr($GUI_SS_DEFAULT_GUI,$WS_CLIPSIBLINGS))
$OK_Button = GUICtrlCreateButton("OK", 110, 270, 70, 20)
$Cancel_Button = GUICtrlCreateButton("Cancel", 220, 270, 70, 20)
GUISetState()

; Creates the first child window that is implemented into the main GUI
$Child1 = GUICreate("", 370, 215, 15, 40, BitOR($WS_CHILD, $WS_TABSTOP), -1, $Main_GUI)

$child1_tab = GUICtrlCreateTab(0, 0, 370, 215)
$child1_tabitem1 = GUICtrlCreateTabItem("Child1Tab1")
$child1_tabitem2 = GUICtrlCreateTabItem("Child1Tab2")
$child1_tabitem3 = GUICtrlCreateTabItem("Child1Tab3")
GUICtrlCreateTabItem("")

GUISetState()

; Creates the second child window that is implemented into the main GUI
$child2 = GUICreate("", 370, 215, 15, 40, BitOR($WS_CHILD, $WS_TABSTOP), -1, $Main_GUI)

$child3 = GUICreate("", 210, 220, 158, 0, BitOR($WS_CHILD, $WS_TABSTOP), -1, $child2)
$ListView = GUICtrlCreateListView("Col1|Col2", 0, 2, 210, 211, _
		BitOR($LVS_NOSORTHEADER, $LVS_SHOWSELALWAYS, $WS_TABSTOP), $WS_EX_CLIENTEDGE)

GUICtrlCreateListViewItem("ItemLong1|ItemLong2", $ListView)
GUICtrlCreateListViewItem("ItemLong3|ItemLong4", $ListView)
GUICtrlCreateListViewItem("ItemLong5|ItemLong6", $ListView)
GUISetState()

GUISwitch($child2)
$child2_tab = GUICtrlCreateTab(0, 0, 156, 215)
$child2_tabitem1 = GUICtrlCreateTabItem("Child2Tab1")
$child2_tabitem2 = GUICtrlCreateTabItem("Child2Tab2")
GUICtrlCreateTabItem("")

; Switch back the main GUI and create the tabs
GUISwitch($Main_GUI)
$main_tab = GUICtrlCreateTab(10, 10, 380, 250)
$main_tabitem1 = GUICtrlCreateTabItem("MainTab1")
$main_tabitem2 = GUICtrlCreateTabItem("MainTab2")
GUICtrlCreateTabItem("")
GUICtrlSetState($main_tabitem1, $GUI_SHOW)

Bind_ImageList($main_tab)

While 1
	$nMsg = GUIGetMsg()
	
	Switch $nMsg
		Case $GUI_EVENT_CLOSE, $Cancel_Button
			ExitLoop
			
		Case $main_tab
			$tabidx = GUICtrlRead($main_tab)
			
			Switch $tabidx
				Case 0
					GUISetState(@SW_HIDE, $child2)
					GUISetState(@SW_SHOW, $Child1)
				Case 1
					GUISetState(@SW_HIDE, $Child1)
					GUISetState(@SW_SHOW, $child2)
			EndSwitch
	EndSwitch
WEnd

_GUIImageList_Destroy($hImageList)

Func Bind_ImageList($nCtrl)
	$hImageList = _GUIImageList_Create(16, 16, 5, 1)
	GUICtrlSendMsg($nCtrl, $TCM_SETIMAGELIST, 0, $hImageList)
	
	$szIconFile = "shell32.dll"
	
	$tcitem = DllStructCreate("uint;dword;dword;ptr;int;int;int")
	DllStructSetData($tcitem, 1, 0x0002)
	DllStructSetData($tcitem, 6, 0)
	AddImageToTab($nCtrl, 0, $tcitem, $szIconFile, 12)
	
	DllStructSetData($tcitem, 6, 1)
	AddImageToTab($nCtrl, 1, $tcitem, $szIconFile, 21)
	
	$tcitem = 0
EndFunc ;==>Bind_ImageList

Func AddImageToTab($nCtrl, $nTabIndex, $nItem, $szIconFile, $nIconID)
	_GUIImageList_AddIcon($hImageList, $szIconFile, $nIconID)
	DllCall("user32.dll", "int", "SendMessage", "hwnd", GUICtrlGetHandle($nCtrl), "int", $TCM_SETITEMA, "int", $nTabIndex, "ptr", DllStructGetPtr($nItem))
EndFunc ;==>AddImageToTab
 
Автор
A

agikon

Знающий
Сообщения
789
Репутация
16
CreatoR
спасибо!
отличный пример.
 
Верх