hi frank...
i have some sort of similar problem with tabControl items...
first you must have this function:
Function GetTabText (cntID as INT,tbIndex as INT) as string
string tabText=Space(256)
TC_ITEM tie
tie.mask=1
tie.pszText = strptr tabText
tie.cchTextMax = 256
tie.iImage = -1
Sendmessage (cntID,TCM_GETITEM,tbIndex,&tie)
Return tabText
End Function
it is not problematic to remove(delete) last created tab than problem is if
you whish to delete tab which is not last..right?
for example you create 3 new tabs....
because tab-control is zero based (like most of win controls) you have
tabCount = GetTabCount(tc) ... is 3
Function GetTabCount (cntID as INT) as INT
INT tbCount
tbCount = Sendmessage (cntID,TCM_GETITEMCOUNT,0,0)
Return tbCount
End Function
but items are sorted from zero ...
0 ...1....2
so if is for example tab 0 selected and you want remove this selected tab
sTab = GetSelectedTab(tc)
Function GetSelectedTab (cntID as INT) as sys
INT tbIndex
tbIndex = Sendmessage (cntID,TCM_GETCURSEL,0,0)
Return tbIndex
End Function
so delete this tab :
Function DeleteTab (tabw as INT,_tpos as INT ) as INT
SendMessage(tabw,TCM_DELETEITEM,_tpos,0)
INT acttab = SendMessage(tabw,TCM_GETCURSEL,0,0)
If acttab<0
acttab=0
SendMessage(tabw,TCM_SETCURSEL,acttab,0)
End If
End Function
(i am not sure that this function work properly)..
0...<-1...<-2
what is left...
1 is now tab 0,2 is tab 1...right?
so main question is which tab to select now,i think that is best to select first tab
like:
if tab > -1 the SetSelectedtab(tc)
SUB SetSelectedTab (cntID as INT,index as INT)
Sendmessage (cntID,TCM_SETCURSEL,index,0)
'Return tbIndex
End Sub
hm i think that you get it now what main problematic part is here.
In AsciEdit I use array(zero based) to store tab information and there is no problem
with adding new tabs BUT when you try to delete specific tab then we are in trouble
because it need to be resorted...