 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
derRaphael
Joined: 23 Nov 2007 Posts: 841 Location: ~/.
|
Posted: Fri Nov 23, 2007 7:49 pm Post subject: |
|
|
i tried that, but still the errorlevel for the
| Code: |
SendMessage, 0x1305, TabNo, &TCITEM, SysTabControl321
|
Gives me FAIL as an result
i am definitly missing something quite important here.
and when i set the TCITEM thing to 3 how do i get the name and icon number
with just one call?
as far, as i've understood the TCITEM should contain it?
would be nice, if someone can manage a working version of this, so i can learn from it
Thanks in Advance
DerRaphael |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7299 Location: Australia
|
Posted: Sat Nov 24, 2007 12:54 am Post subject: |
|
|
| DerRaphael wrote: | | Gives me FAIL as an result |
Oops, I overlooked "The Returncode is FAIL." That only happens if there is a problem sending the message, not if there is a problem processing the message on the other end. You need to either specify a WinTitle, or ensure the Last Found Window is set properly.
| DerRaphael wrote: | | and when i set the TCITEM thing to 3 how do i get the name and icon number with just one call? |
| lexikos wrote: | | TCM_GETITEM wrote: | If the mask member specifies the TCIF_TEXT value, the pszText member must contain the address of the buffer that receives the item text, and the cchTextMax member must specify the size of the buffer.
|
|
Actually... | TCM_GETITEM wrote: | | If the TCIF_TEXT flag is set in the mask member of the TCITEM structure, the control may change the pszText member of the structure to point to the new text instead of filling the buffer with the requested text. The control may set the pszText member to NULL to indicate that no text is associated with the item. |
|
|
| Back to top |
|
 |
Drugwash
Joined: 07 Sep 2008 Posts: 921 Location: Ploiesti, RO
|
Posted: Mon Mar 30, 2009 1:19 am Post subject: |
|
|
Feels like wakin' up the dead but since I needed this feature and the topic was generously offered in the Help file, I dropped here and reviewed DerRaphael's code.
Changes are:
- replaced InsertInteger with NumPut
- fixed the getTabName function
- adjusted TCITEM struct size in all functions
- added button for the getTabName function testing
Hopefully I didn't break too much. Enjoy!
| Code: | ; created by DerRaphael
; updated by Drugwash
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, y240 x16 w440 gTestRun, Start the Test
Gui, Add, Button, y+2 x16 w80 gTestGetName, Get name
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::
TestGetName:
Gui +LastFound
name := getTabName(GetActiveTab()-1)
MsgBox, Selected tab's name is %name%
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, 28, 0)
NumPut(3, TCITEM, 0, "UInt")
NumPut(&TabName, TCITEM, 12, "UInt")
NumPut(IconNumber - 1, TCITEM, 20, "UInt")
SendMessage, 0x1307, 999, &TCITEM, SysTabControl321
}
ModTab(IconNumber, TabName, Index) ; TCM_SETITEM
{
VarSetCapacity(TCITEM, 28, 0)
NumPut(3, TCITEM, 0, "UInt")
NumPut(&TabName, TCITEM, 12, "UInt")
NumPut(IconNumber - 1, TCITEM, 20, "UInt")
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
{
szBuf=254
VarSetCapacity(TCITEM, 28, 0)
VarSetCapacity(Buffer, szBuf, 0)
NumPut(1, TCITEM, 0, "UInt")
NumPut(&Buffer, TCITEM, 12, "UInt")
NumPut(szBuf, TCITEM, 16, "Int")
SendMessage, 0x1305, item, &TCITEM, SysTabControl321
Loop, %szBuf%
{
getchr := NumGet(Buffer, A_Index - 1, "UChar")
if !getchr
break
newbuf := newbuf . Chr(getchr)
}
return newbuf
}
GuiClose:
IL_Destroy(MyImageList) ; Required for image lists used by tab controls.
ExitApp
|
_________________ AHK tools by Drugwash |
|
| Back to top |
|
 |
derRaphael
Joined: 23 Nov 2007 Posts: 841 Location: ~/.
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|