Ariane Soft PPL2 Pocket Programming DataMite
  #1  
Old 01-05-2009, 04:10 PM
Flixy Flixy is offline
Junior Member
 
Join Date: Jan 2009
Posts: 6
Question Table / Listview

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
Reply With Quote
  #2  
Old 01-06-2009, 06:42 PM
PointOfLight PointOfLight is offline
Senior Member
 
Join Date: Sep 2006
Posts: 1,197
Default

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.
Reply With Quote
  #3  
Old 01-07-2009, 04:50 AM
PointOfLight PointOfLight is offline
Senior Member
 
Join Date: Sep 2006
Posts: 1,197
Default

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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:22 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
Copyright (c) ArianeSoft Inc.
Copyright © 2009 www.ppl-lang.com - All rights reserved
Web Design by BR Web Consulting Ltd