1. Help needed with Listview controls
- Posted by Terry <terry at EDERNEY.IDPS.CO.UK> Jul 28, 1999
- 492 views
If anybody there knows anything about listview controls could they tell me why the procedure below doesn't work? I can display the listview control in listview_win, set up the columns and headings but can't get the control to display the items held in lv_data. For Bernie Ryan and Michael Sabal, Thanks for the help on my earlier post "C to plain English" Would this procedure be a fair Eu interpretation of that post or am I making a silly whoops somewhere (probably)? ---------------------------------------------------------------------------- ---- procedure fill_listview() atom lv_struct integer ok sequence lv_data, string_struct, temp_str, struct_members struct_members = {} lv_struct = allocate(36) lv_data = {{"12-12","1","2","3"},{"12-12","1","2","3"},{"12-12","1","2","3"}} for iitem = 1 to length(lv_data) do string_struct = {} temp_str = lv_data[iitem] for j = 1 to length(temp_str) do string_struct = string_struct & temp_str[j] & 0 end for ok = allocate_string(string_struct) struct_members = struct_members & ok poke4(lv_struct + 00, or_all({LVIF_TEXT, LVIF_IMAGE, LVIF_PARAM, LVIF_STATE})) --mask; poke4(lv_struct + 04, iitem-1) -- 0 based --iItem; poke4(lv_struct + 08, 0) --iSubItem; poke4(lv_struct + 12, 0) --state; poke4(lv_struct + 16, 0) --stateMask; poke4(lv_struct + 20, -1) -- = LPSTR_TEXTCALLBACK --pszText; poke4(lv_struct + 24, length(string_struct)) --cchTextMax; poke4(lv_struct + 28, 0) --iImage; poke4(lv_struct + 32, ok) --lParam; ok = c_func(SendMessage, {window_handle[listview_win], LVM_INSERTITEM, 0, lv_struct}) end for c_proc(UpdateWindow, {window_handle[listview_win]}) end procedure ---------------------------------------------------------------------------- --------------------------------- Thanks all Terry
2. Re: Help needed with Listview controls
- Posted by Bernie Ryan <bwryan at PCOM.NET> Jul 28, 1999
- 497 views
Terry: On Wed, 28 Jul 1999 19:19:43 -0400, Terry <terry at EDERNEY.IDPS.CO.UK> wrote: > ok = allocate_string(string_struct) > struct_members = struct_members & ok I am having trouble understanding what your trying to do at this point? Bernie
3. Re: Help needed with Listview controls
- Posted by Terry Moriarty <terry at EDERNEY.IDPS.CO.UK> Jul 29, 1999
- 512 views
On Wed, 28 Jul 1999 19:47:17 -0400, Bernie Ryan <bwryan at PCOM.NET> wrote: >Terry: > >On Wed, 28 Jul 1999 19:19:43 -0400, Terry <terry at EDERNEY.IDPS.CO.UK> wrote: > >> ok = allocate_string(string_struct) >> struct_members = struct_members & ok > >I am having trouble understanding what your trying to do at this point? > I'm using *ok* at this point for 2 reasons, to make reading the code simpler and to save my poor ol' fingers. The reason for struct_members is that I will need to save the string_struct address. Or is it that you think I should maybe be using string_struct for poking and not allocate_string(string_struct)? Thanks Terry >Bernie
4. Re: Help needed with Listview controls
- Posted by Bernie Ryan <bwryan at PCOM.NET> Jul 29, 1999
- 513 views
Terry: I looked up ListView in my C++ compiler samples and I think that you will find that it is going to be a serious task to use it with the win32lib.ew because you will have to handle a lot of callbacks and codes that are not yet implemented in win32lib which was written to handle the basic standard controls used in win32. If you are just trying to display data records on the screen for a user to view then there may be a easier ways to do that. What I would suggest that you sit down and define your problem and determine what you are trying to accomplish. Then see if you can find a simple way to accomplish it. Maybe someone that is an expert at using listview can help you. Sometimes the controls are very impressive and dazzling in win95 and NT but they require C++ to make them easy to manage. I am not saying that they can't be done in Euphoria, just that it will take hours of work to implemnt the list view control and get it working. If you got a dead-line to meet then try to make a simpler approch to your problem by rethinking it. Bernie
5. Re: Help needed with Listview controls
- Posted by Terry Moriarty <terry at EDERNEY.IDPS.CO.UK> Jul 29, 1999
- 482 views
On Thu, 29 Jul 1999 10:25:21 -0400, Bernie Ryan <bwryan at PCOM.NET> wrote: >Terry: > I looked up ListView in my C++ compiler samples and I think that you > will find that it is going to be a serious task to use it with > the win32lib.ew because you will have to handle a lot of callbacks > and codes that are not yet implemented in win32lib which was written > to handle the basic standard controls used in win32. Thanks for the reply Bernie. Der! Disegard the part of my earlier posting where I was wondering how to poke an unlimited-length string into a dword. I really should wait until I wake before posting. I'm not using David's win32lib for the exact reasons you mention (although I have stolen a lot of his code, for which he will be thanked). Catching any callbacks (i.e. LVN_COLUMNCLICK) isn't really a problem for me. My main difficulty is understanding C code, as it is a language I have never used. My background would be more in assembly. I like taking on things which I don't know how to do, because I have more of a chance of remebering anything I learn then. I'm including below the complete C code example of what I posted earlier. Maybe if you (or anybody) has the chance, they could compare my Eu procedure with the C code to see where I am going wrong Thanks Terry argh!!! C code ahead --> // InitListViewItems - adds items and subitems to a list view. // Returns TRUE if successful or FALSE otherwise. // hwndLV - handle of the list view control // pfData - text file containing list view items with columns // separated by semicolons BOOL WINAPI InitListViewItems(HWND hwndLV, FILE *pfData) { extern char g_achTemp[256]; // temporary buffer PSTR pszStart; PSTR pszEnd; int iItem; int iSubItem; LV_ITEM lvi; // Initialize LV_ITEM members that are common to all items. lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM | LVIF_STATE; lvi.state = 0; lvi.stateMask = 0; lvi.pszText = LPSTR_TEXTCALLBACK; // app. maintains text lvi.iImage = 0; // image list index // Read each line in the specified file. for (iItem = 0; fgets(g_achTemp, sizeof(g_achTemp), pfData); iItem++) { // Allocate an application-defined structure to store the // item label and the text of each subitem. MYITEM *pItem = LocalAlloc(LPTR, sizeof(MYITEM)); // Copy the first string (the label). pszEnd = strchr(g_achTemp, ';'); *pszEnd = '\0'; pItem->aCols[0] = DupString(g_achTemp); // Copy subsequent strings (subitems). for (iSubItem = 1; iSubItem < C_COLUMNS && pszEnd != NULL; iSubItem++) { pszStart = pszEnd + 1; if ((pszEnd = strchr(pszStart, ';')) != NULL) *pszEnd = '\0'; pItem->aCols[iSubItem] = DupString(pszStart); } // Initialize item-specific LV_ITEM members. lvi.iItem = iItem; lvi.iSubItem = 0; lvi.lParam = (LPARAM) pItem; // item data // Add the item. ListView_InsertItem(hwndLV, &lvi); // There is no need to set the text of the subitems. They // default to LPSTR_TEXTCALLBACK. } return TRUE; } // DupString - allocates a copy of a string. // lpsz - address of the null-terminated string to copy LPSTR DupString(LPSTR lpsz) { int cb = lstrlen(lpsz) + 1; LPSTR lpszNew = LocalAlloc(LMEM_FIXED, cb); if (lpszNew != NULL) CopyMemory(lpszNew, lpsz, cb); return lpszNew; } phew, that's the end of the C ======================================================= Now for the nice safe Eu --> procedure fill_listview() constant LPSTR_TEXTCALLBACK = -1 atom lv_struct integer ok sequence lv_data, string_struct, temp_str, struct_members struct_members = {} lv_struct = allocate(36) lv_data = {{"7-6","1","2","3"},{"2-9","1","2","3"},{"4-8","1","2","3"}} for iitem = 1 to length(lv_data) do string_struct = {} temp_str = lv_data[iitem] for j = 1 to length(temp_str) do string_struct = string_struct & temp_str[j] & 0 end for ok = allocate_string(string_struct) struct_members = struct_members & ok poke4(lv_struct + 00, or_all({LVIF_TEXT, LVIF_IMAGE, LVIF_PARAM, LVIF_STATE})) --mask; poke4(lv_struct + 04, iitem-1) -- 0 based --iItem; poke4(lv_struct + 08, 0) --iSubItem; poke4(lv_struct + 12, 0) --state; poke4(lv_struct + 16, 0) --stateMask; poke4(lv_struct + 20, LPSTR_TEXTCALLBACK) --pszText; poke4(lv_struct + 24, length(string_struct)) --cchTextMax; poke4(lv_struct + 28, 0) --iImage; poke4(lv_struct + 32, ok) --pointer to string_struct --lParam; ok = c_func(SendMessage, {window_handle[listview_win], LVM_INSERTITEM, 0, lv_struct}) end for c_proc(UpdateWindow, {window_handle[listview_win]}) end procedure
6. Re: Help needed with Listview controls
- Posted by Bernie Ryan <bwryan at PCOM.NET> Jul 29, 1999
- 479 views
Terry: Dont forget that in order to use ListView control you have to load and register the comctl.dll. All so there are many versions of this dll on different computers out there so somethings may require a new version. Bernie
7. Re: Help needed with Listview controls
- Posted by Bernie Ryan <bwryan at PCOM.NET> Jul 29, 1999
- 489 views
oops Thats comctl32.dll Bernie
8. Re: Help needed with Listview controls
- Posted by Terry Moriarty <terry at EDERNEY.IDPS.CO.UK> Jul 29, 1999
- 471 views
On Thu, 29 Jul 1999 18:23:35 -0400, Bernie Ryan <bwryan at PCOM.NET> wrote: >Terry: > Dont forget that in order to use ListView control you have to > load and register the comctl.dll. All so there are many versions > of this dll on different computers out there so somethings may require a > new version. >Bernie Thanks Bernie, I don't think I've explained properly then. I already have a listview control (with columns and headers) in place and working on the screen. The difficulty I am having is displaying the items in the control. The C procedure that I quoted is supposed to accomplish this but I cannot get it to work. I believe the problems lies in one of the following places 1) my Eu procedure is not the correct translation of the C one. (Probably) 2) the value I have for the LVIF_PARAM flag is incorrect (I have #4) 3) the value I have for LPSTR_TEXTCALLBACK is wrong (-1) (quite possibly) If I change the pszText from LPSTR_TEXTCALLBACK to the pointer to string_struct then the first column is filled correctly, (due to the 0 terminator after the first item), but this is not what I require as I need the whole string as LPSTR_TEXTCALLBACK which is why the pointer to string_struct is stored in the final lparam position and the LVIF_PARAM flag enabled. Thanks again Terry