I have this structure for tab controls:
type TCITEM
UINT mask
DWORD dwState
DWORD dwStateMask
LPSTR pszText
int cchTextMax
int iImage
LPARAM lParam
endtype
DEF tie as TCITEM
I have a sub routine to get the tab text:
SUB GetTabText(hWnd:window,cntID:int,index:int)
tie.cchTextMax = 255
SendMessage(hwnd,TCM_GETITEM,index,tie,cntID)
'print len(tie.pszText)
return
ENDSUB
I want to assign a string to tie.pszText
i.e. MyString = tie.pszText
but I'm getting cannot assign pointer to string error.
What am I doing wrong please?
I can print the tab text in a console, but not assign a string to it.
Andy.
I think what you are looking for is:
MyString = <string>tie.pszText
Bill
Thanks Bill,
That didn't work sorry, thanks for trying.
I've managed to get around the need to get the tab text via API, but it still doesn't tell me how to get the tab text into a string.
Thanks again,
Andy.
I think I figured out what you wanted.
try:
string sblarp = "Testing Pointers Blarp"
pointer pblarp
pblarp = &sblarp
print *<STRING>pblarp
do:until inkey$<>""
END
Bill
This was in the help file:
QuoteRetrieving the value that is contained in the address, that is stored in the pointer is called dereferencing. In some texts you may see it referred to as indirection. The IWBASIC compiler supports two general dereferencing operators, the # symbol and a 'C' style dereference operator, the '*'. The hash dereference '#' operator is unique to the IWBASIC language and is suitable for most basic pointer needs.
You can use Bill's way or use a # instead of a *.
STRING txt
txt = #<STRING>tie.pszText
Later
Clint
Thanks both of you,
I see what you are saying, and I have tried both ways, but they don't work here?
Andy.
:)
You challenged me with this problem. I had to see if I could make it work. ;D
I don't know if you have solved this yet, but here it is....
Run as a console obviously
$include "windowssdk.inc"
openconsole
type TCITEM
UINT mask
DWORD dwState
DWORD dwStateMask
LPSTR pszText
int cchTextMax
int iImage
LPARAM lParam
endtype
TCITEM tie
POINTER ptr 'temp pointer
STRING test = "something to point to"
STRING ret 'string var to store in to display
tie.pszText = &test 'assign a pointer to the structure, string is already a pointer, I don't know if we are doing multiple redirections or what
ptr = tie.pszText 'assign a pointer to a pointer variable outside of the structure
ret = #<STRING>ptr 'move the contents to a string variable
print ret 'print it
DO:UNTIL INKEY$ <> ""
CLOSECONSOLE
END
Later,
Clint
Some things here are not nececery at all
and i am not sure why you need string casting to UDT member when is already defined
as LPSTR...which is LongPointer to string i think that can be just string
and why windoowssdk and openconsole ::)
Andy i really dont get it what you want this time
look in this code from o2 just modify it to IWB
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
as you can see you need to alocate some space before you fill it with
structure member tie.pszText
and that is all
Thanks Aurel,
My eyes must have been playing tricks with me.
Andy.
:)