May 06, 2024, 06:00:36 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Tab control set text

Started by aurelCB, February 17, 2011, 03:48:31 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

aurelCB

Hi...
I use example 'tabcontrol' and create tab control without problem.
Adding new tabs is also not problematic but how change text(title) of specific tab?
This looks like mistery ???
I try with sendmessage WM_STTEXT but without succes..
I search trough whole internet and dont find anything concret or useful.
my second question is - how remove or delete specific tab?
here is code:
'Tab control
DEF w1:WINDOW

DECLARE IMPORT, FindWindowA(lpClassName AS STRING,lpWindowName AS STRING),INT
CONST WS_VISIBLE = 0x10000000
CONST WS_CHILD = 0x40000000
CONST TCM_INSERTITEM = 0x1307
Const TCM_SETCURFOCUS = 0x1330
CONST TCN_SELCHANGE = -550-1
CONST TCM_GETCURSEL = 4875
CONST EM_SETBKGNDCOLOR = (0x1307 + 67)
const WM_SETTEXT = 0xC

declare "user32",DestroyWindow(wnd:uint),int

def tc as int
REM open the window
OPENWINDOW w1,0,0,600,400,@MINBOX,0,"Tabed Editor",&main
SETWINDOWCOLOR w1,RGB(220,220,230)

'crete tab control
tc=CreateTabControl(w1,20,20,300,24,10)
SETFONT w1,"MS Sans serif",8,400,0,10

'add tabs
AddTab(tc,0,"First Tab")
SendMessage w1, EM_SETBKGNDCOLOR,0, RGB(243,242,214),10
AddTab(tc,1,"Second Tab")
'AddTab(tc,2,"New File Tab")
'AddTab(tc,3,"Set Color Tab")

'SendMessage tc, WM_SETTEXT, 1, "hello"


WAITUNTIL w1 = 0
DeleteTabControl(tc)
END
'---
REM every time there is a message for our window

SUB main
select @class
case @IDCONTROL
SELECT @NOTIFYCODE
    case TCN_SELCHANGE
'move win,0,205
temp=GetSelectedTab(tc)
SetTabText(tc,temp,"Hello")
SendMessage(tc,WM_SETTEXT,temp,"Hello")
MESSAGEBOX 0,"TAB->:"+str$(temp),"OK"
ENDSELECT


Case @IDCLOSEWINDOW
        CLOSEWINDOW w1
'IF *<window>pw2<>0 THEN CLOSEWINDOW *<window>pw2

endselect
RETURN
ENDSUB

SUB CreateTabControl(hwnd as window,tx as int,ty as int,tw as int,th as int,tcID as INT),INT
def tflag as int
    tflag=WS_VISIBLE|WS_CHILD
tc=CONTROLEX(hwnd,"SysTabControl32","",tx,ty,tw,th,tflag,0,tcID)
Return tc
ENDSUB

SUB AddTab(hWnd:uint,index:int,text:string)

TYPE TC_ITEM
def mask:int
def res1:int
def res2:int
def pszText:POINTER
def cchTextMax:int
def iImage:int
def lParam:int
ENDTYPE

DEF tie:TC_ITEM
tie.mask=1
'TCIF_TEXT=1
tie.pszText=text
tie.cchTextMax=len(text)
tie.iImage=-1
SendMessage(hWnd,TCM_INSERTITEM,index,tie)
return
ENDSUB

sub DeleteTabControl(hWnd:int)
DestroyWindow(hWnd)
return
ENDSUB

SUB SetTabText(hWnd:uint,index:int,text:string)

TYPE TC_ITEM
def mask:int
def res1:int
def res2:int
def pszText:POINTER
def cchTextMax:int
def iImage:int
def lParam:int
ENDTYPE

DEF tie:TC_ITEM
tie.mask=1
'TCIF_TEXT=1
tie.pszText=text
tie.cchTextMax=len(text)
tie.iImage=-1
SendMessage(hWnd,WM_SETTEXT,index,tie.pszText)
return
ENDSUB

sub GetSelectedTab(hWnd:uint),INT
temp = SENDMESSAGE(hWnd,TCM_GETCURSEL,0,0)
return temp
ENDSUB

LarryMc

February 17, 2011, 04:44:46 AM #1 Last Edit: February 17, 2011, 05:04:26 AM by LarryMc
Aurel
I reworked your code a little.
It will change the tab text to hello of the newly selected tab when there is a CHANGE in the selected tab.
'Tab control
TYPE TC_ITEM
def mask:int
def res1:int
def res2:int
def pszText:POINTER
def cchTextMax:int
def iImage:int
def lParam:int
ENDTYPE

DECLARE IMPORT, FindWindowA(lpClassName AS STRING,lpWindowName AS STRING),INT
CONST WS_VISIBLE = 0x10000000
CONST WS_CHILD = 0x40000000
CONST TCM_FIRST = 0x1300
CONST TCM_SETITEM = (TCM_FIRST + 6)
CONST TCM_DELETEITEM = (TCM_FIRST + 8)
CONST TCM_INSERTITEM = 0x1307
Const TCM_SETCURFOCUS = 0x1330
CONST TCN_SELCHANGE = -550-1
CONST TCM_GETCURSEL = 4875
CONST EM_SETBKGNDCOLOR = (0x1307 + 67)
const WM_SETTEXT = 0xC
const TCIF_TEXT=1

declare "user32",DestroyWindow(wnd:uint),int

def tc as uint
DEF w1:WINDOW
REM open the window
OPENWINDOW w1,0,0,600,400,@MINBOX,0,"Tabed Editor",&main
SETWINDOWCOLOR w1,RGB(220,220,230)
Control w1,@Button,"Delete Tab",20,60,100,20,0,3
'crete tab control
tc=CreateTabControl(w1,20,20,300,24,10)
SETFONT w1,"MS Sans serif",8,400,0,10

'add tabs
AddTab(tc,0,"First Tab")
SendMessage w1, EM_SETBKGNDCOLOR,0, RGB(243,242,214),10
AddTab(tc,1,"Second Tab")
AddTab(tc,2,"New File Tab")
AddTab(tc,3,"Set Color Tab")

WAITUNTIL w1 = 0
DeleteTabControl(tc)
END
'---
REM every time there is a message for our window

SUB main
select @class
case @IDCONTROL
select @controlid
case 10
if @NOTIFYCODE =  TCN_SELCHANGE
'move win,0,205
uint temp=GetSelectedTab(tc)
SetTabText(tc,temp,"Hello")
MESSAGEBOX w1,"TAB->:"+str$(temp),"OK"
endif
case 3
if @NOTIFYCODE = 0
temp=GetSelectedTab(tc)
DelTab(tc,temp)
endif
ENDSELECT
Case @IDCLOSEWINDOW
CLOSEWINDOW w1
'IF *<window>pw2<>0 THEN CLOSEWINDOW *<window>pw2
endselect
RETURN
ENDSUB

SUB CreateTabControl(hwnd as window,tx as int,ty as int,tw as int,th as int,tcID as INT),INT
def tflag as int
tflag=WS_VISIBLE|WS_CHILD
tc=CONTROLEX(hwnd,"SysTabControl32","",tx,ty,tw,th,tflag,0,tcID)
Return tc
ENDSUB

SUB AddTab(hWnd:uint,index:int,text:string)
DEF tie:TC_ITEM
tie.mask=TCIF_TEXT
tie.pszText=text
tie.cchTextMax=len(text)
tie.iImage=-1
SendMessage(hWnd,TCM_INSERTITEM,index,&tie)
return
ENDSUB

sub DeleteTabControl(hWnd:int)
DestroyWindow(hWnd)
return
ENDSUB

SUB SetTabText(hWnd:uint,index:int,text:string)
DEF tie:TC_ITEM
tie.mask=TCIF_TEXT
tie.pszText=text
tie.cchTextMax=len(text)
tie.iImage=-1
SendMessage(hWnd,TCM_SETITEM,index,&tie)
return
ENDSUB

sub GetSelectedTab(hWnd:uint),INT
int temp = SENDMESSAGE(hWnd,TCM_GETCURSEL,0,0)
return temp
ENDSUB

SUB DelTab(hWnd:uint,index:int)
SendMessage(hWnd,TCM_DELETEITEM ,index,0)
return
ENDSUB


LarryMc

EDIT: I left out the delete tab code - added.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

aurelCB

Thank you Larry!
I dont know how i miss this:
select @controlid
   case 10

And i find this tab messages but i dont know how to use them...
Thanks again!

all best...
Aurel

LarryMc

Quote from: aurelCB on February 17, 2011, 05:19:40 AM
select @controlid
   case 10
Just making sure you understand.
That wasn't the problem.
The problem was you were using the wrong message in your sendmessage command in your set text subroutine.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

I also assume you know that all the things you might need for tab controls is already in the Control Pak library that comes with IWB/EB.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

aurelCB

QuoteThe problem was you were using the wrong message in your sendmessage command in your set text subroutine.
Yes Larry ,i see now ;)

aurelCB

Larry sorry if i bothering you...
I have just one question about tab control.
I have plan to use tab control for my scintilla editor and want close one of tabs .
Do i can do this on this way:
with mouse rightclick on tab i want open small context menu and close this tab.
what i must use for this?

any suggestion are welcome... :)

all best..
Aurel

LarryMc

Aurel
Added code to open a contextmenu if a tab is rightclicked.
If delete is selected the tab is removed.

'Tab control
TYPE TC_ITEM
def mask:int
def res1:int
def res2:int
def pszText:POINTER
def cchTextMax:int
def iImage:int
def lParam:int
ENDTYPE
DECLARE import,GetCursorPos(pPoint:POINTAPI),INT
DECLARE import,ScreenToClient(hwnd:INT, lpPoint:POINTAPI),INT

DECLARE IMPORT, FindWindowA(lpClassName AS STRING,lpWindowName AS STRING),INT
CONST WS_VISIBLE = 0x10000000
CONST WS_CHILD = 0x40000000
CONST TCM_FIRST = 0x1300
CONST TCM_SETITEM = (TCM_FIRST + 6)
CONST TCM_DELETEITEM = (TCM_FIRST + 8)
CONST TCM_INSERTITEM = 0x1307
Const TCM_SETCURFOCUS = 0x1330
CONST TCN_SELCHANGE = -550-1
CONST TCM_GETCURSEL = 4875
CONST EM_SETBKGNDCOLOR = (0x1307 + 67)
const WM_SETTEXT = 0xC
const TCIF_TEXT=1

declare "user32",DestroyWindow(wnd:uint),int

def tc as uint
DEF w1:WINDOW
int hittab = -1
REM open the window
OPENWINDOW w1,0,0,600,400,@MINBOX,0,"Tabed Editor",&main
SETWINDOWCOLOR w1,RGB(220,220,230)
Control w1,@Button,"Delete Tab",20,60,100,20,0,3
'crete tab control
tc=CreateTabControl(w1,20,20,300,24,10)
SETFONT w1,"MS Sans serif",8,400,0,10

'add tabs
AddTab(tc,0,"First Tab")
SendMessage w1, EM_SETBKGNDCOLOR,0, RGB(243,242,214),10
AddTab(tc,1,"Second Tab")
AddTab(tc,2,"New File Tab")
AddTab(tc,3,"Set Color Tab")

WAITUNTIL w1 = 0
DeleteTabControl(tc)
END
'---
REM every time there is a message for our window

SUB main
select @class
case @IDCONTROL
select @controlid
case 10
if @NOTIFYCODE =  TCN_SELCHANGE
'move win,0,205
uint temp=GetSelectedTab(tc)
SetTabText(tc,temp,"Hello")
MESSAGEBOX w1,"TAB->:"+str$(temp),"OK"
endif
if @NOTIFYCODE =  @NMRCLICK
POINT cursor
GetCursorPos(cursor)
ScreenToClient(tc, cursor)
hittab = tcHitTest(w1,10,cursor.X,cursor.y)
if hittab > -1
CONTEXTMENU w1, cursor.x, cursor.y
MENUITEM "Delete", 0, 20
MENUITEM "Abort", 0, 99
ENDMENU
endif
endif
case 3
if @NOTIFYCODE = 0
temp=GetSelectedTab(tc)
DelTab(tc,temp)
endif
ENDSELECT
case @idmenupick
         'user clicked an item from the context menu
         SELECT @MENUNUM
case 20
DelTab(tc,hittab)
case 99
endselect
Case @IDCLOSEWINDOW
CLOSEWINDOW w1
'IF *<window>pw2<>0 THEN CLOSEWINDOW *<window>pw2
endselect
RETURN
ENDSUB

SUB CreateTabControl(hwnd as window,tx as int,ty as int,tw as int,th as int,tcID as INT),INT
def tflag as int
tflag=WS_VISIBLE|WS_CHILD
tc=CONTROLEX(hwnd,"SysTabControl32","",tx,ty,tw,th,tflag,0,tcID)
Return tc
ENDSUB

SUB AddTab(hWnd:uint,index:int,text:string)
DEF tie:TC_ITEM
tie.mask=TCIF_TEXT
tie.pszText=text
tie.cchTextMax=len(text)
tie.iImage=-1
SendMessage(hWnd,TCM_INSERTITEM,index,&tie)
return
ENDSUB

sub DeleteTabControl(hWnd:int)
DestroyWindow(hWnd)
return
ENDSUB

SUB SetTabText(hWnd:uint,index:int,text:string)
DEF tie:TC_ITEM
tie.mask=TCIF_TEXT
tie.pszText=text
tie.cchTextMax=len(text)
tie.iImage=-1
SendMessage(hWnd,TCM_SETITEM,index,&tie)
return
ENDSUB

sub GetSelectedTab(hWnd:uint),INT
int temp = SENDMESSAGE(hWnd,TCM_GETCURSEL,0,0)
return temp
ENDSUB

SUB DelTab(hWnd:uint,index:int)
SendMessage(hWnd,TCM_DELETEITEM ,index,0)
return
ENDSUB


LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

aurelCB

Thank you very much Larry :)
I think that might be something like add contextmenu to richedit control but i will not set properly this stuff.
Interesting i understand next code:
POINT cursor
GetCursorPos(cursor)
ScreenToClient(tc, cursor)

but next thing i see first time becose is not explained in help...
hittab = tcHitTest(w1,10,cursor.X,cursor.y)
i mean this command tcHitTest - i see that is highlited in blue...

Great it works perfect.. ;)

Aurel

LarryMc

Quotei mean this command tcHitTest - i see that is highlited in blue...
It's highlited in blue because it is an IWBasic command.
Look in theIDE help menu for Control Pak Guide and then look at tabcontrol.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

aurelCB

Oh i finally found this ControlPak guide and i see that i can create TabControl like any other controls.
But i have one problem again.
Using API or with IWB commands for insert new Tab i cannot force this new tab that is
selected,Only first tab is selected.
Do i must change stayle of tab control or do something else..?

Aurel

sapero

Check out tcSetSelectedTab(win,id,tab_index) or tcSetFocusTab(win,id,tab_index) :).

aurelCB

Yes Sapero i checked but nothing help
then i look into D-Lib internal control functions and found TCM_SETCURSEL message which is added after is tab created
so i do same in my program
tcInsertTab w1,50,tabcount,"*New"
Sendmessage w1,TCM_SETCURSEL,tabcount,0,50

And finaly new tab is swiched as selected :)
I dont know why dont work with
tcSetSelectedTab demo, IDTABCONTROL, 1
maby becose of this which is in CPack guide:
QuoteRemarks

A tab control does not send a @TCN_SELCHANGING or @TCN_SELCHANGE notification message when a tab is selected using this message.


LarryMc

Aurel
I use tcSetSelectedTab all the time.
I don't know why it didn't work for you unless it was a problem of where or when you were using it.
Can't help you with that without seeing some code.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

Aurel
Here's my code from above with a button that adds a new tab and selects it using tcSetSelectedTab'Tab control
TYPE TC_ITEM
def mask:int
def res1:int
def res2:int
def pszText:POINTER
def cchTextMax:int
def iImage:int
def lParam:int
ENDTYPE
DECLARE import,GetCursorPos(pPoint:POINTAPI),INT
DECLARE import,ScreenToClient(hwnd:INT, lpPoint:POINTAPI),INT

DECLARE IMPORT, FindWindowA(lpClassName AS STRING,lpWindowName AS STRING),INT
CONST WS_VISIBLE = 0x10000000
CONST WS_CHILD = 0x40000000
CONST TCM_FIRST = 0x1300
CONST TCM_SETITEM = (TCM_FIRST + 6)
CONST TCM_DELETEITEM = (TCM_FIRST + 8)
CONST TCM_INSERTITEM = 0x1307
Const TCM_SETCURFOCUS = 0x1330
CONST TCN_SELCHANGE = -550-1
CONST TCM_GETCURSEL = 4875
CONST EM_SETBKGNDCOLOR = (0x1307 + 67)
const WM_SETTEXT = 0xC
const TCIF_TEXT=1

declare "user32",DestroyWindow(wnd:uint),int

def tc as uint
DEF w1:WINDOW
int hittab = -1
REM open the window
OPENWINDOW w1,0,0,600,400,@MINBOX,0,"Tabed Editor",&main
SETWINDOWCOLOR w1,RGB(220,220,230)
Control w1,@Button,"Delete Tab",20,60,100,20,0,3
Control w1,@Button,"Add Tab",140,60,100,20,0,4
'crete tab control
tc=CreateTabControl(w1,20,20,400,24,10)
SETFONT w1,"MS Sans serif",8,400,0,10

'add tabs
AddTab(tc,0,"First Tab")
SendMessage w1, EM_SETBKGNDCOLOR,0, RGB(243,242,214),10
AddTab(tc,1,"Second Tab")
AddTab(tc,2,"New File Tab")
AddTab(tc,3,"Set Color Tab")

WAITUNTIL w1 = 0
DeleteTabControl(tc)
END
'---
REM every time there is a message for our window

SUB main
select @class
case @IDCONTROL
select @controlid
case 10
if @NOTIFYCODE =  TCN_SELCHANGE
'move win,0,205
uint temp=GetSelectedTab(tc)
SetTabText(tc,temp,"Hello")
MESSAGEBOX w1,"TAB->:"+str$(temp),"OK"
endif
if @NOTIFYCODE =  @NMRCLICK
POINT cursor
GetCursorPos(cursor)
ScreenToClient(tc, cursor)
hittab = tcHitTest(w1,10,cursor.X,cursor.y)
if hittab > -1
CONTEXTMENU w1, cursor.x, cursor.y
MENUITEM "Delete", 0, 20
MENUITEM "Abort", 0, 99
ENDMENU
endif
endif
case 3
if @NOTIFYCODE = 0
temp=GetSelectedTab(tc)
DelTab(tc,temp)
endif
case 4
if @NOTIFYCODE = 0
int cnt= tcGetTabCount(w1,10)
tcInsertTab(w1,10,cnt,"Tab"+str$(cnt))
tcSetSelectedTab(w1,10,cnt)
endif
ENDSELECT
case @idmenupick
         'user clicked an item from the context menu
         SELECT @MENUNUM
case 20
DelTab(tc,hittab)
case 99
endselect
Case @IDCLOSEWINDOW
CLOSEWINDOW w1
'IF *<window>pw2<>0 THEN CLOSEWINDOW *<window>pw2
endselect
RETURN
ENDSUB

SUB CreateTabControl(hwnd as window,tx as int,ty as int,tw as int,th as int,tcID as INT),INT
def tflag as int
tflag=WS_VISIBLE|WS_CHILD
tc=CONTROLEX(hwnd,"SysTabControl32","",tx,ty,tw,th,tflag,0,tcID)
Return tc
ENDSUB

SUB AddTab(hWnd:uint,index:int,text:string)
DEF tie:TC_ITEM
tie.mask=TCIF_TEXT
tie.pszText=text
tie.cchTextMax=len(text)
tie.iImage=-1
SendMessage(hWnd,TCM_INSERTITEM,index,&tie)
return
ENDSUB

sub DeleteTabControl(hWnd:int)
DestroyWindow(hWnd)
return
ENDSUB

SUB SetTabText(hWnd:uint,index:int,text:string)
DEF tie:TC_ITEM
tie.mask=TCIF_TEXT
tie.pszText=text
tie.cchTextMax=len(text)
tie.iImage=-1
SendMessage(hWnd,TCM_SETITEM,index,&tie)
return
ENDSUB

sub GetSelectedTab(hWnd:uint),INT
int temp = SENDMESSAGE(hWnd,TCM_GETCURSEL,0,0)
return temp
ENDSUB

SUB DelTab(hWnd:uint,index:int)
SendMessage(hWnd,TCM_DELETEITEM ,index,0)
return
ENDSUB
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

aurelCB

February 20, 2011, 02:15:43 AM #15 Last Edit: February 20, 2011, 02:17:33 AM by aurelCB
Larry ...yes your code work fine .
I add new button which add text to selected tab(i guess..)
and insted of just adding text, - this command also create new tab?
what i do wrong?
This new button is for example like OpenFile and when i open file i want see filename in
this last opened tab..
How set this properly...?
really weird... ???

here is code:
'Tab control
TYPE TC_ITEM
def mask:int
def res1:int
def res2:int
def pszText:POINTER
def cchTextMax:int
def iImage:int
def lParam:int
ENDTYPE
DECLARE import,GetCursorPos(pPoint:POINTAPI),INT
DECLARE import,ScreenToClient(hwnd:INT, lpPoint:POINTAPI),INT

DECLARE IMPORT, FindWindowA(lpClassName AS STRING,lpWindowName AS STRING),INT
CONST WS_VISIBLE = 0x10000000
CONST WS_CHILD = 0x40000000
CONST TCM_FIRST = 0x1300
CONST TCM_SETITEM = (TCM_FIRST + 6)
CONST TCM_DELETEITEM = (TCM_FIRST + 8)
CONST TCM_INSERTITEM = 0x1307
Const TCM_SETCURFOCUS = 0x1330
CONST TCN_SELCHANGE = -550-1
CONST TCM_GETCURSEL = 4875
CONST EM_SETBKGNDCOLOR = (0x1307 + 67)
const WM_SETTEXT = 0xC
const TCIF_TEXT=1

declare "user32",DestroyWindow(wnd:uint),int

def tc as uint
DEF w1:WINDOW
int hittab = -1
REM open the window
OPENWINDOW w1,0,0,600,400,@MINBOX,0,"Tabed Editor",&main
SETWINDOWCOLOR w1,RGB(220,220,230)
Control w1,@Button,"Delete Tab",20,60,100,20,0,3
Control w1,@Button,"Add Tab",140,60,100,20,0,4
Control w1,@Button,"Add Text",140,160,100,20,0,5


'crete tab control
tc=CreateTabControl(w1,20,20,400,24,10)
SETFONT w1,"MS Sans serif",8,400,0,10

'add tabs
AddTab(tc,0,"First Tab")
SendMessage w1, EM_SETBKGNDCOLOR,0, RGB(243,242,214),10
'AddTab(tc,1,"Second Tab")
'AddTab(tc,2,"New File Tab")
'AddTab(tc,3,"Set Color Tab")

WAITUNTIL w1 = 0
DeleteTabControl(tc)
END
'---
REM every time there is a message for our window

SUB main
select @class
case @IDCONTROL
select @controlid
case 10
if @NOTIFYCODE =  TCN_SELCHANGE
'move win,0,205
uint temp=GetSelectedTab(tc)
SetTabText(tc,temp,"Hello")
MESSAGEBOX w1,"TAB->:"+str$(temp),"OK"
endif
if @NOTIFYCODE =  @NMRCLICK
POINT cursor
GetCursorPos(cursor)
ScreenToClient(tc, cursor)
'hittab = tcHitTest(w1,10,cursor.X,cursor.y)
if hittab > -1
CONTEXTMENU w1, cursor.x, cursor.y
MENUITEM "Delete", 0, 20
MENUITEM "Abort", 0, 99
ENDMENU
endif
endif
case 3
if @NOTIFYCODE = 0
temp=GetSelectedTab(tc)
DelTab(tc,temp)
endif
case 4
if @NOTIFYCODE = 0
int cnt= tcGetTabCount(w1,10)
tcInsertTab(w1,10,cnt,"Tab"+str$(cnt))
tcSetSelectedTab(w1,10,cnt)
Move w1,20,160:Print w1,cnt
endif
'----------------------------------------
case 5
if @NOTIFYCODE = 0
temp=tcGetSelectedTab(w1,10)
Move w1,20,180:Print w1,temp
'why next command add new tab?
tcSetTabText w1, 10,temp, "New"
ENDIF

ENDSELECT
case @idmenupick
         'user clicked an item from the context menu
         SELECT @MENUNUM
case 20
DelTab(tc,hittab)
case 99
endselect
Case @IDCLOSEWINDOW
CLOSEWINDOW w1
'IF *<window>pw2<>0 THEN CLOSEWINDOW *<window>pw2
endselect
RETURN
ENDSUB

SUB CreateTabControl(hwnd as window,tx as int,ty as int,tw as int,th as int,tcID as INT),INT
def tflag as int
tflag=WS_VISIBLE|WS_CHILD
tc=CONTROLEX(hwnd,"SysTabControl32","",tx,ty,tw,th,tflag,0,tcID)
Return tc
ENDSUB

SUB AddTab(hWnd:uint,index:int,text:string)
DEF tie:TC_ITEM
tie.mask=TCIF_TEXT
tie.pszText=text
tie.cchTextMax=len(text)
tie.iImage=-1
SendMessage(hWnd,TCM_INSERTITEM,index,&tie)
return
ENDSUB

sub DeleteTabControl(hWnd:int)
DestroyWindow(hWnd)
return
ENDSUB

SUB SetTabText(hWnd:uint,index:int,text:string)
DEF tie:TC_ITEM
tie.mask=TCIF_TEXT
tie.pszText=text
tie.cchTextMax=len(text)
tie.iImage=-1
SendMessage(hWnd,TCM_SETITEM,index,&tie)
return
ENDSUB

sub GetSelectedTab(hWnd:uint),INT
int temp = SENDMESSAGE(hWnd,TCM_GETCURSEL,0,0)
return temp
ENDSUB

SUB DelTab(hWnd:uint,index:int)
SendMessage(hWnd,TCM_DELETEITEM ,index,0)
return
ENDSUB

ckoehn

When you replace your case 5 with this one it works.  I'm like you I wonder too why it adds another tab when it says it is suppose to add text.

case 5
if @NOTIFYCODE = 0
temp=tcGetSelectedTab(w1,10)
Move w1,20,180:Print w1,temp
'why next command add new tab?
SetTabText (tc,temp, "New")
ENDIF


Later,
Clint

LarryMc

Appears to be a bug in that library.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

aurelCB

it looks like bug becose
tcSetTabText
do the same thing like
tcInsertTab
and both commands have same number of parametars.
So i think that i must use API commands for this...