After i read about the possibility to add Icons to a Tab List, i played around
and generated some test cases for playing around with Icons, Renaming iconified Tabs, deleting 'em adding some more and backreferencing 'em
here's the code:
Code:
MyImageList := IL_Create()
Loop 10
IL_Add(MyImageList, "shell32.dll", A_Index)
Gui, Add, Tab, x16 y216 w440 h20 0x38 -Wrap +Bottom gShoutActiveTab vMyIconTab
Gui +LastFound
SendMessage, 0x1303, 0, MyImageList, SysTabControl321 ; TCM_SETIMAGELIST
Gui, Tab
Gui, Add, Edit, y17 w440 h200 x16, This Edit Control is not part of the Tab Structure :)
Gui, Add, Button, y250 x16 w440 gTestRun, Start the Test
AppendTab(1, "Berlin")
AppendTab(2, "London")
AppendTab(3, "New York")
AppendTab(4, "Helsinki")
AppendTab(5, "Bejing")
AppendTab(6, "Rom")
AppendTab(7, "Moskwa")
Gui, Show, x131 y91 h294 w477, Tabs with Icon Test
return
^l::
getTabName(1)
return
TestRun:
MsgBox,1,Test #1, Press Enter to append a Tab with customized Label and Icon
IfMsgBox, OK
{
InputBox, TabName, Enter Name for new Tab, Please Name a TabName to Add
InputBox, IconNr, Enter IconNumber for new Tab, Please specify an Icon# from 1..10
AppendTab(IconNr, TabName)
}
MsgBox,1,Test #2, Press Enter to change Tab #1's Label and Icon
IfMsgBox, OK
{
InputBox, TabName, Enter Name for new Tab, Please Name a TabName to Add
InputBox, IconNr, Enter IconNumber for new Tab, Please specify an Icon# from 1..10
ModTab(IconNr, TabName, 0 )
}
MsgBox,1,Test #3, Press Enter to Remove Tab #2
IfMsgBox, OK
{
DelTab(1)
}
Msg=
Msg .= "There are " . CountTabs() . " Tabs in this SysTabControl`n"
Msg .= "Tab #" . GetActiveTab() . " is the active Tab`n"
Msg .= "Tab #" . GetTabFocus() . " is the focused Tab`n"
MsgBox,,Status, %Msg%
return
ShoutActiveTab:
GuiControlGet, label,, MyIconTab
GuiControl,,Edit1, The Selected Tab is labeled with "%label%"
return
AppendTab(IconNumber, TabName) ; TCM_INSERTITEM
{
VarSetCapacity(TCITEM, 100, 0)
InsertInteger(3, TCITEM, 0)
InsertInteger(&TabName, TCITEM, 12)
InsertInteger(IconNumber - 1, TCITEM, 20)
SendMessage, 0x1307, 999, &TCITEM, SysTabControl321
}
ModTab(IconNumber, TabName, Index) ; TCM_SETITEM
{
VarSetCapacity(TCITEM, 100, 0)
InsertInteger(3, TCITEM, 0)
InsertInteger(&TabName, TCITEM, 12)
InsertInteger(IconNumber - 1, TCITEM, 20)
SendMessage, 0x1306, Index, &TCITEM, SysTabControl321
}
DelTab(Index) ; TCM_DELETEITEM
{
SendMessage, 0x1308, Index, 0, SysTabControl321
}
CountTabs() ; TCM_GETITEMCOUNT
{
SendMessage, 0x1304, 0, 0, SysTabControl321
Return, %ErrorLevel%
}
GetActiveTab() ;
{
ControlGet, ActiveTab, Tab,, SysTabControl321
Return, % ActiveTab
}
GetTabFocus() ; TCM_GETCURFOCUS
{
SendMessage, 0x132F, 0, 0, SysTabControl321
Return, % ErrorLevel += 1
}
getTabName(item) ; TCM_GETITEM
{
VarSetCapacity(TCITEM, 512, 0)
InsertInteger(3, TCITEM, 0)
SendMessage, 0x1305, item, &TCITEM, SysTabControl321
MsgBox %ErrorLevel%
}
InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4)
{
Loop %pSize%
DllCall("RtlFillMemory", "UInt", &pDest + pOffset + A_Index-1, "UInt", 1, "UChar", pInteger >> 8*(A_Index-1) & 0xFF)
}
GuiClose:
IL_Destroy(MyImageList) ; Required for image lists used by tab controls.
ExitApp
There is still a Message, with which its possible to get the Icon Number associated with a Tab. Its the Message TCM_GETITEM which i didnt master. The Returncode is FAIL when i give it a call.
I guess the TCITEM is somehow corrupted, but i dont get it how to set it up correctly.
http://msdn2.microsoft.com/en-us/library/bb760589.aspx for TCM_GETITEM
http://msdn2.microsoft.com/en-us/library/bb760554.aspx for TCITEM
Well Then so far ... happy playing around
Keep Scriptin'
DerRaphael