#1
|
|||
|
|||
![]()
Hello
I need a kind of table, so I tried the Listview. This works beautiful, but I found no possibility to change the background for single fields (only for the hole background). So this is my first question, if there was a possibility to change the color of the fields. The second question: I need an event for the click in the fields of a listview. Is there an event or something like that, that returns the row and the col of the clicked field ? Flixy |
#2
|
|||
|
|||
![]()
In regards to changing the color of individual fields, I'd wager that you'd have to override the drawing functions of the control to do that. Given enough time I could probably come up with an example, but unfortunately I don't have the time at the moment.
As for knowing which field you clicked, I'm still working to get you a good answer for that. The quick answer is that in the OnClick event of the ListView (if you're using the visual editor), you can get the row as follows: row$ = ListView_GetSel(ListViewVariable$); Unfortunately, I haven't found a good way to get the column yet. The "evil" way would be to check the bounding rectangle of each cell against the x,y coordinates of when you released the mouse / stylus, but that would be ugly. If I can come up with a good way I will definitely share. You have to keep in mind that ListViews were really meant to show data a row at a time, meaning you can always get any of the values in a row just by knowing the index of the row. Most people don't care about the individual cell being clicked within the row, so there probably wasn't a need to make that information easy to find. |
#3
|
|||
|
|||
![]()
Okay, here's a better but still not useful answer to the "identify a cell" thing. Here's some code:
func LISTVIEW101_OnClick(hWnd$, Msg$, wParam$, lParam$) HandleEventParms struct(hti$, LVHITTESTINFO); struct(pt$, POINT); SetText(Label103$, "x: " + lvx$ + ", y: " + lvy$); pt.X$ = lvx$; pt.Y$ = lvy$; hti.pt$ = pt$; hti.flags$ = LVHT_ONITEM; ret$ = SendMessage(ListView101$, LVM_SUBITEMHITTEST, 0, &hti$); if(ret$ > -1) ShowMessage("Clicked item " + (hti.iItem$ + 1) + " and SubItem " + hti.iSubItem$); end; return(true); end; func LISTVIEW101_OnLeftButtonDown(hWnd$, Msg$, wParam$, lParam$) HandleEventParms lvx$ = loword(lParam$); lvy$ = hiword(lParam$); return (true); end; In theory this code should work. Basically, you're passing the X and Y coordinates of your mouse click to the listview control, and it's supposed to tell you whether or not the coordinates correspond to any visible item / subitem. Unfortunately, I've messed with this a bunch of different ways, trying redefinitions of LVHITTESTINFO with different variable sizes and what have you, and nothing seemed to work. I recreated the code as identically as I could in VB6 and it works fine there, so I know the theory is sound. I just don't understand why PPL doesn't get a good return value on the SendMessage for LVM_SUBITEMHITTEST. Maybe you can at least use this as a start to figure out what you want. |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|