Oxygen Basic
Programming => Problems & Solutions => Topic started by: Aurel on June 27, 2013, 10:05:47 AM
-
Hi all... :)
To avoid stupid and useless chalenges on bp.org back to real stuff...
Anyone maybe have a idea what is wrong with function where i need to get tab control text.
I create function which SetTabtext and who work fine but GettabText wont return string(text)
-caption of tab...
any help is welcome.. ;)
this functions work:
Function SetTabControl(byval _tbhwnd as INT,byval _tx as INT,byval _ty as INT,byval _tw as INT,byval _th as INT,byval _tbflag as INT,byval _ex as INT,byval cID as INT) As INT
INT _hfont
If _tbflag=0
_tbflag=WS_CHILD | WS_VISIBLE|_tbflag
End If
hTabControl = CreateWindowEx(_ex,"SysTabControl32","",_tbflag,_tx,_ty,_tw,_th,_tbhwnd,cID,0,0)
_hfont = GetStockObject(17)
SendMessage hTabControl,WM_SETFONT,_hfont,0
UpdateWindow _tbhwnd
Function = hTabControl
End Function
'=====================================================================================
'AddTab
Function AddTab (hwnd as INT ,tbpos as INT,tbtext as String ) as INT
TC_ITEM tie
tie.mask=1
tie.pszText= strptr(tbtext)
tie.cchTextMax=Len(tbtext)
tie.iImage = -1
SendMessage(hWnd,0x1307,tbpos,&tie)
End Function
'=====================================================================================
Function SetTabText (cntID as INT,tbIndex as INT,tabText as String)
TC_ITEM tie
tie.mask=1
tie.pszText= strptr(tabText)
tie.cchTextMax=Len(tabtext)
tie.iImage = -1
SendMessage(cntID,TCM_SETITEM,tbIndex,&tie)
Return
End Function
'=====================================================================================
Function GetSelectedTab (cntID as INT) as INT
INT tbIndex
tbIndex = Sendmessage (cntID,TCM_GETCURSEL,0,0)
Return tbIndex
End Function
but this one not:
Function GetTabText (cntID as INT,tbIndex as INT) as string
char tabText[100]
TC_ITEM tie
tie.mask=1
tabtext=Sendmessage (cntID,WM_GETTEXT,tbIndex,&tie.psztext)
Return tabText
End Function
I have search trough all possible exemples i found on net and nothing work... ???
-
To avoid stupid and useless chalenges on bp.org back to real stuff...
Tomaaz has taken the baton and running full speed. ::)
Sorry, I have nothing to offer to resolve your issues.
-
Ok John ...i see ,he is just a lonely freak :D
Maybe Charles know where to look... ;)
-
Ok John ...i see ,he is just a lonely freak
No, I don't think so. He was just filling in. :-*
-
I don't think its WM_GETTEXT
Any of these?
Tab Control Messages
http://msdn.microsoft.com/en-us/library/windows/desktop/ff486047(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/bb760589(v=vs.85).aspx
-
sorry Charles but i don't have acces to msdn ( because of some unknown reason--our wifi network).
Maybe is something useful on joseRoca site ???
-
hmm..i have found this on JRoca forum:
LOCAL szTabTxt AS ASCIIZ * 256
nTab = SendMessage(ghTabMdi, %TCM_GETITEMCOUNT, 0, 0)
FOR idx = 0 TO nTab - 1
' Get tab item text string
ttc_item.mask = %TCIF_TEXT
ttc_item.pszText = VARPTR(szTabTxt)
ttc_item.cchTextMax = SIZEOF(szTabTxt)
SendMessage ghTabMdi, %TCM_GETITEM, idx, BYVAL VARPTR(ttc_item)
so i do this in oxygen...
Function GetTabText (byval cntID as int,byval tabIndex as int) as string
string tabText
TC_ITEM tie
tie.mask=1
tie.pszText = strptr (tabText)
tie.cchTextMax = sizeOf(tabText)
SendMessage(cntID,TCM_GETITEM,tabIndex,&tie)
print "TAB_TEXT:" + tabText
Return tabtext
End Function
And not work ,string is not recieved ???
How is this posssible? do i must use maybe something else than string ?
-
I also try this to:
Function GetTabText ( cntID as int, tabIndex as int) as string
zstring tabText[256]
TC_ITEM tie
tie.mask=1
tie.pszText = strptr tabText
tie.cchTextMax = LEN(tabText)
SendMessage(cntID,TCM_GETITEM,tabIndex,&tie)
print "TAB_TEXT:" + tabText
Return tabtext
End Function
and still nothing ???
-
I even try with asciiz:
Function GetTabText ( cntID as int, tabIndex as int) as char
dim tabText as asciiz * 256
TC_ITEM tie
tie.mask=1
tie.pszText = strptr tabText
tie.cchTextMax = LEN(tabText)
SendMessage(cntID,TCM_GETITEM,tabIndex,&tie)
'print "TAB_TEXT:" + tabText
Return tabtext
End Function
And again nothing...i simply don't get it what might be wrong ::)
-
Hi Aurel
Taking the Jose snippet:
PB / Jose:
LOCAL szTabTxt AS ASCIIZ * 256
nTab = SendMessage(ghTabMdi, %TCM_GETITEMCOUNT, 0, 0)
FOR idx = 0 TO nTab - 1
' Get tab item text string
ttc_item.mask = %TCIF_TEXT
ttc_item.pszText = VARPTR(szTabTxt)
ttc_item.cchTextMax = SIZEOF(szTabTxt)
SendMessage ghTabMdi, %TCM_GETITEM, idx, BYVAL VARPTR(ttc_item)
...
Oxygen
LOCAL szTabTxt AS ASCIIZ * 256
nTab = SendMessage(ghTabMdi, %TCM_GETITEMCOUNT, 0, 0)
indexbase 0
FOR idx = 0 TO nTab - 1
' Get tab item text string
ttc_item.mask = %TCIF_TEXT
ttc_item.pszText = strptr(szTabTxt)
ttc_item.cchTextMax = 256 'buffer size
SendMessage ghTabMdi, %TCM_GETITEM, idx, & ttc_item)
...
I think its the buffersize you need. (256)
-
YES...it work...
But how then not work with sizeOf or with LEN
PowerBasic use sizeOf like many C or similar examples ???
Ok oxygen need number...good to know ;)
Thank you Charles!
Without this i simply cannot continue work on tab control for AsciEditor..
because i must know what text is on tab
so now function look like this:
Function GetTabText ( cntID as int, tabIndex as int) as string
dim tbText as asciiz * 256
TC_ITEM tie
tie.mask=1
tie.pszText = strptr tbText
tie.cchTextMax = 256
SendMessage(cntID,TCM_GETITEM,tabIndex,&tie)
'print "TAB_TEXT:" + tabText
Return tbtext
End Function
-
You can use spanof
dim s as asciiz*256
print sizeof s '=1
print spanof s '=256
-
aha i see... ;)
also work with
string tabtext=space(256)
tabtext[256] as zstring
char tabtext[256]
:)