PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Trouble to GetItem values with listview, tabcontrol

Here are my function attempts:

func Tabbox_GetTab(tabbox$, editbox$)
struct (ti$, TCITEM);
ti.mask$ = TCIF_TEXT;
tabcount$ = SendMessage(tabbox$, TCM_GETCURSEL, 0, 0);
ti.
//SendMessage(tabbox$, TCM_GETITEM, tabcount$, &ti;$);
//tabname$ = ti.pszText$;
tablen$ = ti.cchTextMax$;
tabname$ = GetItem(tabbox$, tabcount$);
SetText(MEMO106$, str(tabname$));
SetText(editbox$, str(tabname$));
Return(true);
end;

func Listview_GetItem(listview$, editbox$)
struct (lv$, LVITEM);
lv.mask$ = LVIF_TEXT;
tabcount$ = SendMessage(listview$, LVM_GETITEMCOUNT, 0, 0);
//tabcount$--;
lv.iItem$ = 1;
//lv.SubItem$ = 1;
//SendMessage(listview$, LVM_GETITEM , 0, &lv;$);
//tabcount$ = 1;
//lv.fmt$ = LVCFMT_LEFT;
text$ = Char(lv.pszText$);
//lv.stateMask$ = Int(-1);
//lv.iIndent$ = 1;
SetText(editbox$, Char(lv.pszText$));
tabname$ = text$;
//lv.pszText$ = tabname$;
//tablen$ = length(tabname$);
//lv.cchTextMax$ = tablen$;
//SendMessage(listview$, LVM_INSERTITEM , tabcount$, &lv;$);
SetText(MEMO107$, Char(lv.pszText$));
text$ = GetItem(listview$, lv.iItem$);
SetText(MEMO107$, text.pszText$);
SetText(editbox$, text$);
Return(true);
end;

I have tried a lot, somebody know howto get that value ? The one selected for sure.
Before using the LVM_GETITEM you have to do the following:

Code:
struct (lv$, LVITEM);
lv.mask$ = LVIF_TEXT;
lv.iItem$ = 0; // First item
new(buffer$, 255 * 2); // * 2 is because WIDECHAR are 2 bytes.
lv.pszText$ = &buffer;$;
lv.cchTextMax$ = 255;
SendMessage(listview$, LVM_GETITEM , 0, &lv;$);
text$ = Char(lv.pszText$);


This should do it. You have to create room to store the widechar information returned by LVM_GETITEM.

Hope this help,
Kornalius
Thanks Koarnalius, i tried it, it do something but it does not return the text value.
If I do not make the Char conversion it look's like: 1514960, 1515472, looks like internal addressing.

I can't get it working.
When i look in the MS help:

pszText
Pointer to a null-terminated string that contains the item text if the structure specifies item attributes. If this member is the LPSTR_TEXTCALLBACK value, the item is a callback item. Do not set the pszText member to LPSTR_TEXTCALLBACK if the list-view control has LVS_SORTASCENDING or LVS_SORTDESCENDING style.
If the structure is receiving item attributes, this member is the pointer to the buffer that receives the item text.

I tried all conversion i know to this value.
Is this working on your ppc ?
The values you get in pszText is a string (widechar) pointer and not the actual string. To convert the pointer to a string do the following:

^lv.pszText$ --> This will put a widechar string on the stack.
char(^lv.pszText$) --> Convert the widechar string to a regular string.

ShowMessage(char(^lv.pszText$));

PPL uses the same method to store strings in arrays. It only stores the pointer of the string.

DIM(A$, 100);
A$[1] = "STRING";
ShowMessage(A$[1]); --> Will show string pointer value.
ShowMessage(^A$[1]); --> Display "STRING"

Regards,
Kornalius
Okay, thanks again !
I will try this asap :-)
I was playing a bit now with the winsock.
Just to get some xml files from internet.

I think i found a bug in the visual builder, for listbox at least you can't set empty caption name.
It result in a Index out of bounds error message.

Regards,
Thanks Red, I will double-check that and make sure it's fixed for 0.6b.

Regards,
Kornalius