Author Topic: tabcontrol close?  (Read 2246 times)

0 Members and 1 Guest are viewing this topic.

Frankolinox

  • Guest
tabcontrol close?
« on: December 31, 2013, 03:32:25 AM »
lalala :)
« Last Edit: October 01, 2014, 08:43:35 AM by Frankolinox »

Aurel

  • Guest
Re: tabcontrol close?
« Reply #1 on: December 31, 2013, 04:10:06 AM »
hi frank...
i have some sort of similar problem with tabControl items... >:(
first you must have this function:
Quote
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
Code: [Select]
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)

Code: [Select]
Function GetSelectedTab (cntID as INT) as sys
INT tbIndex
tbIndex = Sendmessage (cntID,TCM_GETCURSEL,0,0)

Return tbIndex
End Function

so delete this tab :
Code: [Select]
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)

Code: [Select]
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...



Aurel

  • Guest
Re: tabcontrol close?
« Reply #2 on: January 01, 2014, 10:14:46 AM »
ok Frank... ;)
and Happy New Year

JRS

  • Guest
Re: tabcontrol close?
« Reply #3 on: January 01, 2014, 11:50:34 AM »
@Frank:

Nice job. Persistence is what makes a good programmer a great one.  8)

JRS

  • Guest
Re: tabcontrol close?
« Reply #4 on: January 04, 2014, 09:21:33 AM »
Nice. It's like the jQuery of Windows.  :D

Haim

  • Guest
Re: tabcontrol close?
« Reply #5 on: January 04, 2014, 08:51:07 PM »
Thank you Frankolinox for your contribution.
I enjoy studying  your code.