Shoutbox

[?] Trying to get into the advanced stuff - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [?] Trying to get into the advanced stuff (/showthread.php?tid=75206)

[?] Trying to get into the advanced stuff by Matti on 06-09-2007 at 03:02 PM

Okay, for a very long time I managed to do all my scripting stuff using just JScript code with some API calls. But that time seems to be ended...

I want to make my ListViewControl's columns sortable. This can be done usign the LVM_SORTITEMS message, but because Plus! doesn't support function pointers I'll need to program a DLL with a function to do this and call it from my script. The only problem is: I have no clue how. I never programmed a DLL before. :P

So, if anyone's interested in helping me with this, please PM me so I can give you my Messenger address. :)

Thanks in advance!


RE: [?] Trying to get into the advanced stuff by Volv on 06-09-2007 at 03:40 PM

ListViewControl columns can be made sortable within the schema file can't they?

code:
<ReportView>
    <SortColHeader>true</SortColHeader>
</ReportView>

RE: [?] Trying to get into the advanced stuff by Matti on 06-09-2007 at 03:49 PM

quote:
Originally posted by Volv
ListViewControl columns can be made sortable within the schema file can't they?
code:
<ReportView>
    <SortColHeader>true</SortColHeader>
</ReportView>

If it would've been that easy, I'd already have done that! :P
No, Plus!' scripting engine still has a lot of incomplete features, including this one. Developers have to code it in manually, which I'm trying to do now.
RE: [?] Trying to get into the advanced stuff by Volv on 06-09-2007 at 04:06 PM

Hmm ok, you're right - it doesn't work :(
I only just realised that I had that tag in my script all along and didn't even know about it :p


RE: [?] Trying to get into the advanced stuff by vikke on 06-09-2007 at 04:17 PM

I don't get what you would do with function pointers, but I have PMed you, hopefully I can help you. :)


RE: [?] Trying to get into the advanced stuff by markee on 06-10-2007 at 07:02 AM

I was looking at this just last week and though that Patchou should have really put events on the column names being pressed and was suprised it wasn't there and that they weren't called through the CtrlClicked event.  The only work around I could think of was to remove the top bar and sit buttons there instead, but then you can't use the <SortColHeader> which is unfortunate (but I have been too lazy to do this....).  I'm sure your method is probably going to be better, but if you wanted to be lazy like me then this way is always a possibility (and will only require JScript).


RE: [?] Trying to get into the advanced stuff by Matti on 06-10-2007 at 11:49 AM

quote:
Originally posted by markee
I was looking at this just last week and though that Patchou should have really put events on the column names being pressed and was suprised it wasn't there and that they weren't called through the CtrlClicked event.  The only work around I could think of was to remove the top bar and sit buttons there instead, but then you can't use the <SortColHeader> which is unfortunate (but I have been too lazy to do this....).  I'm sure your method is probably going to be better, but if you wanted to be lazy like me then this way is always a possibility (and will only require JScript).
But then, it'd be better to write it with a DLL, since then you can actually receive notifications from window controls and use function pointers... I just want to learn HOW. :)
RE: [?] Trying to get into the advanced stuff by Eljay on 06-10-2007 at 01:28 PM

To detect when someone clicks the column header, you don't have to write a dll to subclass the ListView at all. ListView controls send a WM_NOTIFY message to the parent window for various events, including when the column headers are clicked, which means you can detect it in JScript using PlusWnd.RegisterMessageNotification().

I have attached a little example script to detect column header clicks, enjoy :P

Note: if you have multiple ListViews, you can distinguish between them by reading the hwndFrom of the NMLISTVIEW structure.
if(NMLISTVIEW.ReadDWORD(0) == Wnd.GetControlHandle("<ControlId>"))...


RE: [?] Trying to get into the advanced stuff by Matti on 06-10-2007 at 03:36 PM

Whoa, thanks! :D Now I only need to program a DLL to do the sorting. :)
EDIT: Just for the sake of correctness: it's LVN_COLUMNCLICK instead of LVN_COLUMNCLICKED. ;)


RE: [?] Trying to get into the advanced stuff by Eljay on 06-10-2007 at 04:03 PM

quote:
Originally posted by Mattike
Whoa, thanks! :D Now I only need to program a DLL to do the sorting. :)
EDIT: Just for the sake of correctness: it's LVN_COLUMNCLICK instead of LVN_COLUMNCLICKED. ;)

Why do you need a dll to do the sorting? That's also possible with JScript, even with custom sort orders via a callback function.
RE: [?] Trying to get into the advanced stuff by markee on 06-10-2007 at 04:11 PM

Thanks Eljay, I might just use this myself :happy:

* markee bookmarks Eljay's post for later reference


RE: [?] Trying to get into the advanced stuff by CookieRevised on 06-10-2007 at 08:26 PM

Detecting a column click and then manually sort the list is still a workaround.

If Plus! scripting supported real callbacks you could use the proper Windows APIs to do the job in one go.

Now you need to read the entire list, sort it manually, and put everything back in the list. This is a very very very slow method, especially on larger lists.

Anyways, you might be interested in:
[Question] ListViewControl - Numeric sortable Columns


RE: [?] Trying to get into the advanced stuff by Matti on 06-11-2007 at 04:27 PM

But if I used the LVM_SORTITEMS message to do the sorting, it wouldn't clear the list to sort but simply move the items, wouldn't it? :S


RE: [?] Trying to get into the advanced stuff by markee on 06-12-2007 at 04:04 AM

quote:
Originally posted by Mattike
But if I used the LVM_SORTITEMS message to do the sorting, it wouldn't clear the list to sort but simply move the items, wouldn't it? :S
But that is exactly what you should do with JScript anyway, you don't need to remove the lists, only replace them ;)

Take a close look at the thread Cookie linked to and you should be able to see how cookie said that in the final post.
RE: [?] Trying to get into the advanced stuff by Matti on 06-12-2007 at 06:12 PM

Okay, so I took a look and came to the conclusion that it's a good alternative if I can't come up with a better programmed DLL. (if my VS2005 wants to install...) But I still have one question left: what about flipping the sorting? And can we add (and change) the icon displayed next to the column header which indicates the sorting direction? Like in a "real" ListViewControl?

I know this is almost not possible, but because you always have a no and can get a yes, I thought I'd better ask. :)


RE: [?] Trying to get into the advanced stuff by markee on 06-13-2007 at 02:40 AM

quote:
Originally posted by Mattike
Okay, so I took a look and came to the conclusion that it's a good alternative if I can't come up with a better programmed DLL. (if my VS2005 wants to install...) But I still have one question left: what about flipping the sorting? And can we add (and change) the icon displayed next to the column header which indicates the sorting direction? Like in a "real" ListViewControl?

I know this is almost not possible, but because you always have a no and can get a yes, I thought I'd better ask. :)
Flipping and sorting (in other words, changing between ascending and descending order) can be done by making the changes that cookie has said in the last post on the linked thread and you can change the column headers using the function you posted in the tips thread the other day.  This is the exact method that i was going to use.....
RE: [?] Trying to get into the advanced stuff by Patchou on 02-10-2008 at 10:04 PM

Note: callbacks will be supported in 4.51 so that should solve that problem.