AutoHotkey Community

It is currently May 25th, 2012, 9:39 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: November 23rd, 2007, 8:49 pm 
Offline

Joined: November 23rd, 2007, 10:23 am
Posts: 841
Location: ~/.
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 24th, 2007, 1:54 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7501
Location: Australia
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.
Code:
Gui, +LastFound

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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 30th, 2009, 2:19 am 
Offline
User avatar

Joined: September 8th, 2008, 12:26 am
Posts: 1048
Location: Ploieşti, RO
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. :oops: 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 (AHK 1.0.48.05 and Win98SE)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 10th, 2010, 7:29 pm 
Offline

Joined: November 23rd, 2007, 10:23 am
Posts: 841
Location: ~/.
i've updated the here presented functions to be used in a more stdLib way.

see http://www.autohotkey.com/forum/viewtopic.php?p=323127#323127 for more details.

greets
dR

_________________
Image
    All scripts, unless otherwise noted, are hereby released under CC-BY


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 0 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group