1. How to sort ListView?

I am using the Win32lib-59-1.

Somebody knows how to get one ListView be sorted by my program, 
possibly by a specific column?
I cannot find any information about.

Thanks

Antonio Alessi

new topic     » topic index » view message » categorize

2. Re: How to sort ListView?

LVM_SORTITEMS=20
wParam = (WPARAM) (LPARAM) lParamSort;=20
lParam = (LPARAM) (PFNLVCOMPARE) pfnCompare;=20

// Corresponding macro=20
BOOL ListView_SortItems(HWND hwnd, PFNLVCOMPARE pfnCompare,
=09LPARAM lParamSort);=20


The LVM_SORTITEMS message sorts list view items using an
application-defined comparison function. The index of each item
changes to reflect the new sequence. You can send this message
explicitly or by using the ListView_SortItems macro.

Parameters

hwnd

Handle to the list view control.

pfnCompare

Pointer to the application-defined comparison function. The comparison
function is called during the sort operation each time the relative
order of two list items needs to be compared. For more information,
see the following.

lParamSort

Application-defined value that is passed to the comparison function.

Return Value

Returns TRUE if successful or FALSE otherwise.

Remarks

The comparison function has the following form:

int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2,
=09LPARAM lParamSort);=20


The comparison function must return a negative value if the first item
should precede the second, a positive value if the first item should
follow the second, or zero if the two items are equivalent.
The lParam1 and lParam2 parameters specify the item data for the two
items being compared. The lParamSort parameter is the same value
passed to the LVM_SORTITEMS message.



On 6/20/05, Antonio Alessi <guest at rapideuphoria.com> wrote:
>
>
> posted by: Antonio Alessi <a.admin at myway.it>
>
>
>
> I am using the Win32lib-59-1.
>
> Somebody knows how to get one ListView be sorted by my program,
> possibly by a specific column?
> I cannot find any information about.
>
> Thanks
>
> Antonio Alessi
>
>
>
>
>

new topic     » goto parent     » topic index » view message » categorize

3. Re: How to sort ListView?

Thank you Greg: I'm sorry to have posted the question in a too much fast way.
I knew how the ListView works in several details.

What I don't find out is how to get my program automatically sort the LV 
by a defined column on startup, without waiting any user's click.

I other words, I want to get the LV sorted by default on a definable column,
when the Main opens.

Thanks again

Antonio Alessi

new topic     » goto parent     » topic index » view message » categorize

4. Re: How to sort ListView?

Antonio Alessi wrote:
> 
> Thank you Greg: I'm sorry to have posted the question in a too much fast way.
> I knew how the ListView works in several details.
> 
> What I don't find out is how to get my program automatically sort the LV 
> by a defined column on startup, without waiting any user's click.
> 
> I other words, I want to get the LV sorted by default on a definable column,
> when the Main opens.
> 

Assuming you are using Win32lib, the following code works.

---------------------
atom p
p = w32acquire_mem(0, SIZEOF_NMLISTVIEW)
w32store(p, NMLISTVIEW_HDRhWndFrom, getHandle(MyListView))
w32store(p, NMLISTVIEW_HDRidFrom, MyListView)
w32store(p, NMLISTVIEW_HDRcode, LVN_COLUMNCLICK)
w32store(p, NMLISTVIEW_iSubItem, theColumn)  -- Zero is the first column.

VOID = sendMessage(MyListView, WM_NOTIFY, 0, p)

w32release_mem(p)

--------------



-- 
Derek Parnell
Melbourne, Australia
irc://irc.sorcery.net:9000/euphoria

new topic     » goto parent     » topic index » view message » categorize

5. Re: How to sort ListView?

Thanks to Derek also, but, as I wrote in my 1st message, I'm using the 
Win32lib-59-1, due to some compatibility problems with a one year older
procedure.

However I tried to run this routine, using the Win32lib v0.60.6
with the hope to get some direct or indirect chance.

Unfortunately the columns of the ListView are not sorted if they call 
a custom routine_id( ), as is in my prog.:
VOID = setLVAttr( fListVw, {{kLVSortRtn,
    {routine_id( "mySortDATE"), routine_id( "mySortNameType"), -2, -2, -2}}})

Both the first and the second column cannot be sorted by the 
Win32lib v0.60.6 with the above setting, even clicking their headers.

Other chances?

Regards,

Antonio Alessi

new topic     » goto parent     » topic index » view message » categorize

6. Re: How to sort ListView?

Antonio Alessi wrote:
> 
> Thanks to Derek also, but, as I wrote in my 1st message, I'm using the 
> Win32lib-59-1, due to some compatibility problems with a one year older
> procedure.
> 
> However I tried to run this routine, using the Win32lib v0.60.6
> with the hope to get some direct or indirect chance.
> 
> Unfortunately the columns of the ListView are not sorted if they call 
> a custom routine_id( ), as is in my prog.:
> }}}
<eucode>
>   VOID = setLVAttr( fListVw, {{kLVSortRtn, 
>     {routine_id( "mySortDATE"), routine_id( "mySortNameType"), -2, -2, -2}}})
> <font color="#330033"></eucode>
{{{
</font>
> Both the first and the second column cannot be sorted by the 
> Win32lib v0.60.6 with the above setting, even clicking their headers.
> 
> Other chances?
> 
> Regards,
> 
> Antonio Alessi
> 

Hi there!


Derek's idea sounds good so im wondering now...

Would it make any difference if you used an updated version of
WinLib or isnt that possible, and if it's not, why isnt it?


Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

new topic     » goto parent     » topic index » view message » categorize

7. Re: How to sort ListView?

Hi Al!

It simply would involve to rewrite DON'T KNOW HOW MANY routines of this
procedure
(which should be in beta test since November.. instead of continuously growing; 
by the way this will soon be submitted to this Community).

Working on that since 20 months, I could not add this new problem; at the moment
it will be easier to sort my files before adding them to the ListView!

Do you want to know some reasons, which appear at a first view, just after the
WinMain( )?
1. Icons profile gives problems; other graphic settings work also in a different
way.
2. Some Main window's frames (or ToolBars) do not leave space to the Status Bar,
which is full of Buttons
that is they overlap it.
3. THe ListView works differently, as probably several other functions.
If you want to see details, I can e-mail some screen shots of that.

Just for an example I had to spend much time to decipher older routines taken 
from the precious User's Contribution, where 
onXxxx[] = routine_id( )
are not compatible with the 
setHandler( ). 

Obviously this may be due to my being a beginner in programming Euphoria; 
I come from Quick Basic, no 'C' language or Visual Basic experience before, 
the more my program is complex and you will see it soon anyway, [I hope].
I could also send you an Alpha release to watch, if you are so patient
'cause too many bugs still walk all around.

Please, be patient with my English, too.

Antonio Alessi

new topic     » goto parent     » topic index » view message » categorize

8. Re: How to sort ListView?

Al Getz wrote:
> 
> Antonio Alessi wrote:
> > 
> > Thanks to Derek also, but, as I wrote in my 1st message, I'm using the 
> > Win32lib-59-1, due to some compatibility problems with a one year older
> > procedure.
> > 
> > However I tried to run this routine, using the Win32lib v0.60.6
> > with the hope to get some direct or indirect chance.
> > 
> > Unfortunately the columns of the ListView are not sorted if they call 
> > a custom routine_id( ), as is in my prog.:
> > }}}
<eucode>
> >   VOID = setLVAttr( fListVw, {{kLVSortRtn, 
> >     {routine_id( "mySortDATE"), routine_id( "mySortNameType"), -2, -2,
> >     -2}}})
> <font color="#330033">> <font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">></eucode>
{{{
</font></font>
> > Both the first and the second column cannot be sorted by the 
> > Win32lib v0.60.6 with the above setting, even clicking their headers.
> > 
> > Other chances?
> > 
> > Regards,
> > 
> > Antonio Alessi
> > 
> 
> Hi there!
> 
> 
> Derek's idea sounds good so im wondering now...
> 
> Would it make any difference if you used an updated version of
> WinLib or isnt that possible, and if it's not, why isnt it?
> 
> 
> Take care,
> Al
> 
> And, good luck with your Euphoria programming!
> 
> My bumper sticker: "I brake for LED's"
> 
Hi again Al,

just after having answered to your message I found out a mail sent to Wolf 
on January, which refers about a compatibility problem between the Win32lib 
that I use and the most recent one; I paste it herewith, for your knowledge:
____________________

After hours of search I could verify that one call to a procedure, 
which could make a Dialog be visible, made this Dialog appear even if it is 
setVisible to zero. There was nothing to do to hide it!

There must be some confusion between the created, opened and visible...
This happens visibly with the Win32lib 0.6; with the Win32lib 0.59 
it does not appear on my Win2000, but it could be the indirect reason of that 
symptom that you described on your system ("..It is destroying parts of the 
screen occasionally, like the main title-bar.").
I think you colud be interested to evaluate that, if you didn't yet.
The 3 other dialogs get a similar behaviour, but their sizes were set to 
0,0,0,0. I'm going to trap them too.
 
--- ==========
procedure onEvent_MainWin( integer self, integer event, sequence dialog)
 
     .. ..
     .. ..
     dialog = {ChldTag, ChldPop, HyphDic, EWFindR}
     for i = 1 to 4 do
      if compare( getControlInfo( dialog[i], {CONTROLINFO_closed}), {1}) then 
?i
       setVisible( dialog[i], 1)
      end if
     end for

end procedure
--- ==========
setHandler( MainWin, w32HResize, routine_id( "onEvent_MainWin"))
--- ==========
 
Checking with the "?i" above, the Win32lib 0.6 outputs 1,2,3,4 while the
Win32lib 0.59 doesn't; but probably something remains indigestible anyway..
________________________
 
I have inserted into the for next loop the line:
? getControlInfo( dialog[i], CONTROLINFO_closed) & compare( getControlInfo(
   dialog[i], {CONTROLINFO_closed}), {1})

the result with Win32lib 0.59:
{1,0}
{1,0}
{1,0}
{1,0}
the result with Win32lib 0.6:
{-11,-1}
1
{-11,-1}
2
{-11,-1}
3
{-11,-1}
4
I don't believe so good to reverse settings from one release to the other of the
same library.
 
Ciao,
Antonio
____________________

Regards.

new topic     » goto parent     » topic index » view message » categorize

9. Re: How to sort ListView?

Antonio Alessi wrote:
> 
> Thanks to Derek also, but, as I wrote in my 1st message, I'm using the 
> Win32lib-59-1, due to some compatibility problems with a one year older
> procedure.

Ok, but I believe the sorting of ListViews was implemented before v0.59 anyway,
so you should be able to do it in the version you are using.

> However I tried to run this routine, using the Win32lib v0.60.6
> with the hope to get some direct or indirect chance.
> 
> Unfortunately the columns of the ListView are not sorted if they call 
> a custom routine_id( ), as is in my prog.:
> }}}
<eucode>
>   VOID = setLVAttr( fListVw, {{kLVSortRtn, 
>     {routine_id( "mySortDATE"), routine_id( "mySortNameType"), -2, -2, -2}}})
> <font color="#330033"></eucode>
{{{
</font>
> Both the first and the second column cannot be sorted by the 
> Win32lib v0.60.6 with the above setting, even clicking their headers.
> 
> Other chances?

It works just fine on my machine. So I suspect that your custom sorting routine
has a problem. Can you post those routine for me to check over?

The general form a ListView customer sort function looks like this ...

---------------------------------
function lvsort(integer id, atom rowA, atom rowB, integer column)
---------------------------------
    object text1, text2

    if rowA = -1 then
        if rowB = -1 then
            if column = 0 then
                -- Sorting starts!
                -- Code that is performed before the sort starts.
                 . . . 
                 return w32True -- Use w32False to abort sort operation.
            else
                -- Sorting ends!
                -- Code that is performed after the sort has ended.
                 . . . 
                return w32True
            end if
        end if

    end if

    text1 = getLVItemText(id, rowA, column)
    text2 = getLVItemText(id, rowB, column)

    -- Code to compare the *TEXT* of two row entries in a given column.
    . . .
    return result -- One of either -1, 0, +1 
                  -- for rowA<rowB, rowA=rowB, rowA>rowB
                  -- respectively.

end function




-- 
Derek Parnell
Melbourne, Australia
irc://irc.sorcery.net:9000/euphoria

new topic     » goto parent     » topic index » view message » categorize

10. Re: How to sort ListView?

Antonio Alessi wrote:

[snip]

> I have inserted into the for next loop the line:
>    ? getControlInfo( dialog[i], CONTROLINFO_closed) & compare( getControlInfo(
>    dialog[i],
> {CONTROLINFO_closed}), {1})
> 
> the result with Win32lib 0.59:
> {1,0}
> {1,0}
> {1,0}
> {1,0}
> the result with Win32lib 0.6:
> {-11,-1}
> 1
> {-11,-1}
> 2
> {-11,-1}
> 3
> {-11,-1}
> 4
> I don't believe so good to reverse settings from one release to the
> other of the same library.

I have not documented this property and thus it could change from time to time
without notice. However, I apologize that this has caused a problem for you.

The CONTROLINFO_closed property has a few settings:

 -11   --> The window has never been opened and thus has never been closed.
   0   --> The window is currently open. It may or may not be hidden.
   1   --> The window has been closed and hidden.
   2   --> The window is in the process of being closed.

-- 
Derek Parnell
Melbourne, Australia
irc://irc.sorcery.net:9000/euphoria

new topic     » goto parent     » topic index » view message » categorize

11. Re: How to sort ListView?

Derek Parnell wrote:
> 
> Antonio Alessi wrote:
> 
> [snip]
> 
> > I have inserted into the for next loop the line:
> >    ? getControlInfo( dialog[i], CONTROLINFO_closed) & compare(
> >    getControlInfo( dialog[i],
> > {CONTROLINFO_closed}), {1})
> > 
> > the result with Win32lib 0.59:
> > {1,0}
> > {1,0}
> > {1,0}
> > {1,0}
> > the result with Win32lib 0.6:
> > {-11,-1}
> > 1
> > {-11,-1}
> > 2
> > {-11,-1}
> > 3
> > {-11,-1}
> > 4
> > I don't believe so good to reverse settings from one release to the
> > other of the same library.
> 
> I have not documented this property and thus it could change from time to time
> without
> notice. However, I apologize that this has caused a problem for you. 
> 
> The CONTROLINFO_closed property has a few settings:
> 
>  -11   --> The window has never been opened and thus has never been closed.
>    0   --> The window is currently open. It may or may not be hidden.
>    1   --> The window has been closed and hidden.
>    2   --> The window is in the process of being closed.
> 
> -- 
> Derek Parnell
> Melbourne, Australia
> irc://irc.sorcery.net:9000/euphoria
> 

Hi Derek,

don't worry about that; that's the normal programmer's "routine" ;)

A first release of my program on another machine was opening to the upper left
corner
of the screen some dialog windows which were created but set to 0,0,0,0 rect.
They did never appear on my system (Win2000 server) before being opened, but the
user wrote me:
"It is destroying parts of the screen occasionally, like the main title-bar.."
So I tried to trap this behaviour with the Win32lib 0.6 and this was useful.
Regards,

Antonio Alessi

new topic     » goto parent     » topic index » view message » categorize

12. Re: How to sort ListView?

Derek Parnell wrote:
> 
> Antonio Alessi wrote:
> > 
> > Thanks to Derek also, but, as I wrote in my 1st message, I'm using the 
> > Win32lib-59-1, due to some compatibility problems with a one year older
> > procedure.
> 
> Ok, but I believe the sorting of ListViews was implemented before v0.59
> anyway, so
> you should be able to do it in the version you are using.
> 
> > However I tried to run this routine, using the Win32lib v0.60.6
> > with the hope to get some direct or indirect chance.
> > 
> > Unfortunately the columns of the ListView are not sorted if they call 
> > a custom routine_id( ), as is in my prog.:
> > }}}
<eucode>
> >   VOID = setLVAttr( fListVw, {{kLVSortRtn, 
> >     {routine_id( "mySortDATE"), routine_id( "mySortNameType"), -2, -2,
> >     -2}}})
> <font color="#330033">> <font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">></eucode>
{{{
</font></font>
> > Both the first and the second column cannot be sorted by the 
> > Win32lib v0.60.6 with the above setting, even clicking their headers.
> > 
> > Other chances?
> 
> It works just fine on my machine. So I suspect that your custom sorting
> routine has
> a problem. Can you post those routine for me to check over?
> 
> The general form a ListView customer sort function looks like this ...
> 
> }}}
<eucode>
> ---------------------------------
> function lvsort(integer id, atom rowA, atom rowB, integer column)
> ---------------------------------
>     object text1, text2
> 
>     if rowA = -1 then
>         if rowB = -1 then
>             if column = 0 then
>                 -- Sorting starts!
>                 -- Code that is performed before the sort starts.
>                  . . . 
>                  return w32True -- Use w32False to abort sort operation.
>             else
>                 -- Sorting ends!
>                 -- Code that is performed after the sort has ended.
>                  . . . 
>                 return w32True
>             end if
>         end if
> 
>     end if
> 
>     text1 = getLVItemText(id, rowA, column)
>     text2 = getLVItemText(id, rowB, column)
> 
>     -- Code to compare the *TEXT* of two row entries in a given column.
>     . . .
>     return result -- One of either -1, 0, +1 
>                   -- for rowA<rowB, rowA=rowB, rowA>rowB
>                   -- respectively.
> 
> end function
> <font color="#330033"></eucode>
{{{
</font>
> 
> 
> -- 
> Derek Parnell
> Melbourne, Australia
> irc://irc.sorcery.net:9000/euphoria
> 

Yes Derek, the problems are into the routines,
but due however to compatibility reasons.
So, to use that 'autosort' feature, the Win32lib v0.60.6 is needed anyway.

This is the Date sort routine (the other is a bit more complicated, switching
three options into the same column: asc. Name, desc. Name, asc. Type, 
but the problem should match). Please, clear >>> and see *** :

global constant mth = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
"Sep", "Oct", "Nov", "Dec"}
integer toggleDT, SortDate, LVcheck

--- ========= 
function check_DATE( sequence string)

if length( string) = 9 then string = "0"&string end if  -- 9 for final space
    added
if string[8] = 57 then string[8] = 47  end if           -- the years 90th
    are put under zero..
-- quick local solution: to be revised
    before the 2090 ;)
    return string

end function

--- ======== ListView DATE sort: current date format ( 29-Jan-04)
function mySortDATE( integer id, integer lItem1, integer lItem2, integer column)
sequence text1, text2 integer t
	
	SortDate = 1

--	toggleDT:               1 = "Ascending Sort by Date"    0 = "Descending Sort
by Date"

	text1 = check_DATE( getLVItemText( id, lItem1, 1))
>>> puts(1, text1 &"\n")  -- *** OUTPUT v0.60.6 RESULT:	"Invalid getLVItemText
>>> call: ID=7, ROW=-1 ="

    text2 = check_DATE( getLVItemText( id, lItem2, 1))

    t = compare( text1[8..9], text2[8..9])
    if t then return t *toggleDT end if

    t = compare( match( {text1[4..6]}, mth), match( {text2[4..6]}, mth))
    if t then return t *toggleDT end if

return compare( text1[1..2]&getLVItemText( id, lItem1, 4 -- own Time is
    added at this point
                  , text2[1..2]&getLVItemText( id, lItem2, 4) ) *toggleDT
end function


new topic     » goto parent     » topic index » view message » categorize

13. Re: How to sort ListView?

Antonio Alessi wrote:
> 
> Derek Parnell wrote:
> > 
> > Antonio Alessi wrote:
> > > 
> > > Thanks to Derek also, but, as I wrote in my 1st message, I'm using the 
> > > Win32lib-59-1, due to some compatibility problems with a one year older
> > > procedure.
> > 
> > Ok, but I believe the sorting of ListViews was implemented before v0.59
> > anyway, so
> > you should be able to do it in the version you are using.
> > 
> > > However I tried to run this routine, using the Win32lib v0.60.6
> > > with the hope to get some direct or indirect chance.
> > > 
> > > Unfortunately the columns of the ListView are not sorted if they call 
> > > a custom routine_id( ), as is in my prog.:
> > > }}}
<eucode>
> > >   VOID = setLVAttr( fListVw, {{kLVSortRtn, 
> > >     {routine_id( "mySortDATE"), routine_id( "mySortNameType"), -2, -2,
> > >     -2}}})
> <font color="#330033">> <font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">>> <font color=</font><font
> color=</font><font color="#00A033">"#00A033"</font><font
> color="#330033">></font><font color="#00A033">"#330033"</font><font
> color="#330033"></font><font color=</font><font
> color="#00A033">"#330033"</font><font
> color="#330033">>></eucode>
{{{
</font></font></font>
> > > Both the first and the second column cannot be sorted by the 
> > > Win32lib v0.60.6 with the above setting, even clicking their headers.
> > > 
> > > Other chances?
> > 
> > It works just fine on my machine. So I suspect that your custom sorting
> > routine has
> > a problem. Can you post those routine for me to check over?
> > 
> > The general form a ListView customer sort function looks like this ...
> > 
> > }}}
<eucode>
> > ---------------------------------
> > function lvsort(integer id, atom rowA, atom rowB, integer column)
> > ---------------------------------
> >     object text1, text2
> > 
> >     if rowA = -1 then
> >         if rowB = -1 then
> >             if column = 0 then
> >                 -- Sorting starts!
> >                 -- Code that is performed before the sort starts.
> >                  . . . 
> >                  return w32True -- Use w32False to abort sort operation.
> >             else
> >                 -- Sorting ends!
> >                 -- Code that is performed after the sort has ended.
> >                  . . . 
> >                 return w32True
> >             end if
> >         end if
> > 
> >     end if
> > 
> >     text1 = getLVItemText(id, rowA, column)
> >     text2 = getLVItemText(id, rowB, column)
> > 
> >     -- Code to compare the *TEXT* of two row entries in a given column.
> >     . . .
> >     return result -- One of either -1, 0, +1 
> >                   -- for rowA<rowB, rowA=rowB, rowA>rowB
> >                   -- respectively.
> > 
> > end function
> <font color="#330033">> <font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">></eucode>
{{{
</font></font>
> > 
> > 
> > -- 
> > Derek Parnell
> > Melbourne, Australia
> > irc://irc.sorcery.net:9000/euphoria
> > 
> 
> Yes Derek, the problems are into the routines,
> but due however to compatibility reasons.
> So, to use that 'autosort' feature, the Win32lib v0.60.6 is needed anyway.
> 
> This is the Date sort routine (the other is a bit more complicated, switching
> three options into the same column: asc. Name, desc. Name, asc. Type, 
> but the problem should match). Please, clear >>> and see *** :
> 
> }}}
<eucode>
> global constant mth = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
> "Sep", "Oct", "Nov", "Dec"}
> integer toggleDT, SortDate, LVcheck
> 
> --- ========= 
> function check_DATE( sequence string)
> 
>     if length( string) = 9 then string = "0"&string end if  -- 9 for final
>     space added
>     if string[8] = 57 then string[8] = 47  end if           -- the years 90th
>     are put under zero..
>     	    	    	    	    	    	    	    -- quick local solution: to be revised
>     before the 2090 ;)
>     return string
> 
> end function
> 
> --- ======== ListView DATE sort: current date format ( 29-Jan-04)
> function mySortDATE( integer id, integer lItem1, integer lItem2, integer
> column)
> sequence text1, text2 integer t
> 	
> 	SortDate = 1
> 
> --	toggleDT:               1 = "Ascending Sort by Date"    0 = "Descending
> Sort by Date"
> 
> 	text1 = check_DATE( getLVItemText( id, lItem1, 1))
> >>> puts(1, text1 &"\n")  -- *** OUTPUT v0.60.6 RESULT:	"Invalid getLVItemText
> >>> call: ID=7, ROW=-1 ="
> 
>     text2 = check_DATE( getLVItemText( id, lItem2, 1))
> 
>     t = compare( text1[8..9], text2[8..9])
>     if t then return t *toggleDT end if
> 
>     t = compare( match( {text1[4..6]}, mth), match( {text2[4..6]}, mth))
>     if t then return t *toggleDT end if
> 
>     return compare( text1[1..2]&getLVItemText( id, lItem1, 4 -- own Time is
>     added at this point
>                   , text2[1..2]&getLVItemText( id, lItem2, 4) ) *toggleDT
> end function
></eucode>
{{{


I see that you didn't understand my example of a custom sort function. 

There are two special calls of the routine. One before the sort starts and one
after the sort ends. In both these cases, the lItem1 and lItem2 parameters are
set to -1. You need to check for item values >= 0 before calling getLVItemText.
If you get an item value < 0 then return with w32True.

-- 
Derek Parnell
Melbourne, Australia
irc://irc.sorcery.net:9000/euphoria

new topic     » goto parent     » topic index » view message » categorize

14. Re: How to sort ListView?

Derek Parnell wrote:
> 
> I see that you didn't understand my example of a custom sort function. 
> 
> There are two special calls of the routine. One before the sort starts and one
> after the
> sort ends. In both these cases, the lItem1 and lItem2 parameters are set to
> -1. You need
> to check for item values >= 0 before calling getLVItemText. If you get an item
> value <
> 0 then return with w32True. 
> 
> -- 
> Derek Parnell
> Melbourne, Australia
> irc://irc.sorcery.net:9000/euphoria
> 
I'm sorry, I did not deepen that since I could immediately verified, as you
suspected,
the Win32lib v0.60.6 error in my routine, which is working well with the
Win32lib-59.

I will give a look into in order to learn more, but I'm afraid that some
confusion arised:
even if I adjust those custom sort functions, I don't think I could use the
autosort
instructions with the Win32lib-59; do you?

Regards

Antonio Alessi
a.admin at myway.it
http://www.astrologicagenda.org

new topic     » goto parent     » topic index » view message » categorize

15. Re: How to sort ListView?

Hello again Antonio,

Im not sure if this will help or not, but in one program i used the
list view 'owner data' style and sorted the entire contents with a
special sort routine that sorts by column.  On program startup, the
data is first sorted by whatever column, then later, as the user clicks
columns, the data is sorted by that column.  Since the list view uses
owner data it gets the correct values without having to reload the
whole list every time a sort is done.

This technique has a two basic requirements:

1.  The list view style must be set to owner data style
2.  The list view contents must be stored as a Euphoria sequence of seq's

Perhaps you can tell us how your program acquires the data for the
listview when the program starts up...


Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

new topic     » goto parent     » topic index » view message » categorize

16. Re: How to sort ListView?

Al Getz wrote:
> 
> Hello again Antonio,
> 
> Im not sure if this will help or not, but in one program i used the
> list view 'owner data' style and sorted the entire contents with a
> special sort routine that sorts by column.  On program startup, the
> data is first sorted by whatever column, then later, as the user clicks
> columns, the data is sorted by that column.  Since the list view uses
> owner data it gets the correct values without having to reload the
> whole list every time a sort is done.
> 
> This technique has a two basic requirements:
> 
> 1.  The list view style must be set to owner data style
> 2.  The list view contents must be stored as a Euphoria sequence of seq's
> 
> Perhaps you can tell us how your program acquires the data for the
> listview when the program starts up...
> 
> 
> Take care,
> Al
> 
> And, good luck with your Euphoria programming!
> 
> My bumper sticker: "I brake for LED's"
> 
Hello Al,

          of course, I can do.
It simply deals with a list of files got like this:
ItemEntry = walk_dir( TargetDir, ...  (simplified)

and stored exactly as a sequence:
addLVItem( fListVw, 0,
{ sprint( ItemEntry[D_DAY])& "-" & mth[ItemEntry[D_MONTH]]& "-" &year[3..4]&
" ", ItemEntry[D_NAME],
	  sprint( -floor( -ItemEntry[D_SIZE]/1010)), 
	  sprintf("%02d:%02d", {ItemEntry[D_HOUR], ItemEntry[D_MINUTE]}),
	  path_name })

	  
I could add the LVS_OWNERDATA to:

flags = or_all( {LVS_EX_GRIDLINES, LVS_EX_FULLROWSELECT, LVS_EX_CHECKBOXES,
LVS_EX_HEADERDRAGDROP, LVS_OWNERDATA})

What should I do then to sort by whatever column on program startup?

Antonio

new topic     » goto parent     » topic index » view message » categorize

17. Re: How to sort ListView?

Antonio Alessi wrote:
> 
> Al Getz wrote:
> > 
> > Hello again Antonio,
> > 
> > Im not sure if this will help or not, but in one program i used the
> > list view 'owner data' style and sorted the entire contents with a
> > special sort routine that sorts by column.  On program startup, the
> > data is first sorted by whatever column, then later, as the user clicks
> > columns, the data is sorted by that column.  Since the list view uses
> > owner data it gets the correct values without having to reload the
> > whole list every time a sort is done.
> > 
> > This technique has a two basic requirements:
> > 
> > 1.  The list view style must be set to owner data style
> > 2.  The list view contents must be stored as a Euphoria sequence of seq's
> > 
> > Perhaps you can tell us how your program acquires the data for the
> > listview when the program starts up...
> > 
> > 
> > Take care,
> > Al
> > 
> > And, good luck with your Euphoria programming!
> > 
> > My bumper sticker: "I brake for LED's"
> > 
> Hello Al,
> 
>           of course, I can do.
> It simply deals with a list of files got like this:
> }}}
<eucode>
>       ItemEntry = walk_dir( TargetDir, ...  (simplified)
> <font color="#330033"></eucode>
{{{
</font>
> and stored exactly as a sequence:
> }}}
<eucode>
> 	  addLVItem( fListVw, 0,
> 	  { sprint( ItemEntry[D_DAY])& "-" & mth[ItemEntry[D_MONTH]]& "-"
> &year[3..4]& " ", ItemEntry[D_NAME],
> 	  sprint( -floor( -ItemEntry[D_SIZE]/1010)), 
> 	  sprintf("%02d:%02d", {ItemEntry[D_HOUR], ItemEntry[D_MINUTE]}),
> 	  path_name })
> <font color="#330033"></eucode>
{{{
	  </font>
> I could add the LVS_OWNERDATA to:
> 
> flags = or_all( {LVS_EX_GRIDLINES, LVS_EX_FULLROWSELECT, LVS_EX_CHECKBOXES,
> LVS_EX_HEADERDRAGDROP,
> LVS_OWNERDATA})
> 
> What should I do then to sort by whatever column on program startup?
> 
> Antonio
> 

Hi Antonio,


Oh ok, it sounds like you can use this method.  I originally got the idea
from Pete Lomax when we were discussing list view sorting, and from there
i created a function to sort by column if the data is stored in a Euphoria
sequence (which yours is too) in the following form...

s={
    {r1c1,r1c2,r1c3,...},
    {r2c1,r2c2,r2c3,...},
    {...,...}
  }

where r stands for row and c stands for column.


There's two different routines...



  -- Example 1, sort by one column alone:
  --  s=
  --    {
  --      {1,4,2},
  --      {2,3,3},
  --      {3,2,1}
  --    }
  --  s=column_upper_case_sort(s,3)
  --
  --  result:
  --    {
  --      {3,2,1},
  --      {1,4,2},
  --      {2,3,3}
  --    }
All the data has been sorted according to column 3.


The second function sorts according to column priority:

  --  s=column_upper_case_sort(s,3)
  --  s=column_upper_case_sort2(s,3,2)
  --  s=column_upper_case_sort2(s,2,1).
  --
  --  After the last call, the list is sorted according to all rows
  --  with col 3 highest priority, col 2 next highest, and col 1 lowest.

You dont always need the second form 'sort2' but it's handy
for some things.  Usually you would sort first by column 1, then 2,
then 3, etc., to get a nice order to everything.

For your app, you may wish to store something like this:

s={
    {filename1,date1,bytes1},
    {filename2,date2,bytes2},
    {filename3,date3,bytes3}
  }

so you can sort by filename, date, bytes, or even make filename
first priority, date second, and bytes third, or any other priority
order you deem appropriate.

For example, let's start with this:

sequence s
s={
    { "c:", "Acme.txt",     2005, 06, 24,  10456},
    { "d:", "Denver.gif",   2005, 01, 03,  12345},
    { "d:", "Bee.bmp",      2005, 01, 02,  48923},
    { "c:", "Cooking.txt",  2004, 05, 12,  24318},
    { "c:", "Bee.bmp",      2003, 03, 02,  18923}
  }

This data, printed out, looks like this:

  c: Acme.txt    2005 06 24 10456
  d: Denver.gif  2005 01 03 12345
  d: Bee.bmp     2005 01 02 48923
  c: Cooking.txt 2004 05 12 24318
  c: Bee.bmp     2003 03 02 18923


--Let's say we dont care about the drive letter, and we want to sort
--by filename first, so we call:

s=column_upper_case_sort(s,2)

--The result, printed out, looks like this:

  c: Acme.txt    2005 06 24 10456
  d: Bee.bmp     2005 01 02 48923
  c: Bee.bmp     2003 03 02 18923
  c: Cooking.txt 2004 05 12 24318
  d: Denver.gif  2005 01 03 12345

--Now let's say we want all similar items to be sorted by year so they
--are in chronological order (we'd also have to do month and day next),
--so we call:

s=column_upper_case_sort2(s,2,3)
--where 2 is the previous column and 3 is the new column (the year).
--The result, printed out, looks like this:

c: Acme.txt    2005 06 24 10456
c: Bee.bmp     2003 03 02 18923
d: Bee.bmp     2005 01 02 48923
c: Cooking.txt 2004 05 12 24318
d: Denver.gif  2005 01 03 12345

Note this last result flipped the two 'Bee.bmp' files because that
puts them in chronological order, while nothing else changed.  Of 
course if we didnt know we were done here we would also have to sort
next by month, then by day like this:

s=column_upper_case_sort2(s,3,4)
s=column_upper_case_sort2(s,4,5)


The whole process in a program would look like this:

sequence s
s={
    { "c:", "Acme.txt",     2005, 06, 24,  10456},
    { "d:", "Denver.gif",   2005, 01, 03,  12345},
    { "d:", "Bee.bmp",      2005, 01, 02,  48923},
    { "c:", "Cooking.txt",  2004, 05, 12,  24318},
    { "c:", "Bee.bmp",      2003, 03, 02,  18923}
  }

s=column_upper_case_sort(s,2)
s=column_upper_case_sort2(s,2,3)
s=column_upper_case_sort2(s,3,4)
s=column_upper_case_sort2(s,4,5)


It just so happens, however, that there's a third function:
 "prioritized_columns_upper_case_sort(sequence x,sequence ColumnPriorities)"

that allows this whole process to be handled in one call so the whole
program would look like this:

sequence s
s={
    { "c:", "Acme.txt",     2005, 06, 24,  10456},
    { "d:", "Denver.gif",   2005, 01, 03,  12345},
    { "d:", "Bee.bmp",      2005, 01, 02,  48923},
    { "c:", "Cooking.txt",  2004, 05, 12,  24318},
    { "c:", "Bee.bmp",      2003, 03, 02,  18923}
  }
s=prioritized_column_upper_case_sort(s,{2,3,4,5})

--printed result:

  c: Acme.txt    2005 06 24 10456
  c: Bee.bmp     2003 03 02 18923
  d: Bee.bmp     2005 01 02 48923
  c: Cooking.txt 2004 05 12 24318
  d: Denver.gif  2005 01 03 12345


I'll submit the include file to the contributions site if you're
interested.


Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

new topic     » goto parent     » topic index » view message » categorize

18. Re: How to sort ListView?

Antonio Alessi wrote:
> 
> Derek Parnell wrote:
> > 
> > I see that you didn't understand my example of a custom sort function. 
> > 
> > There are two special calls of the routine. One before the sort starts and
> > one after the
> > sort ends. In both these cases, the lItem1 and lItem2 parameters are set to
> > -1. You need
> > to check for item values >= 0 before calling getLVItemText. If you get an
> > item value <
> > 0 then return with w32True. 
> > 
> > -- 
> > Derek Parnell
> > Melbourne, Australia
> > irc://irc.sorcery.net:9000/euphoria
> > 
> I'm sorry, I did not deepen that since I could immediately verified, as you
> suspected,
> 
> the Win32lib v0.60.6 error in my routine, which is working well with the
> Win32lib-59.
> 
> I will give a look into in order to learn more, but I'm afraid that some
> confusion
> arised: 
> even if I adjust those custom sort functions, I don't think I could use the
> autosort
> 
> instructions with the Win32lib-59; do you?

I do not have a copy of v0.59 with me so I cannot answer your question just now.
If you look into the win32lib.ew file for how 'kLVSortRtn' is used, you can find
the answer yourself.

I think you can but I don't understand why you can't use v0.60.6. You state that
there are incompatiblities but I don't know what they are.

My advice is to upgrade win32lib and change your application accordingly, if
required. My previous advice about sorting ListView controls works fine for
Win32lib v0.60.6.

-- 
Derek Parnell
Melbourne, Australia
irc://irc.sorcery.net:9000/euphoria

new topic     » goto parent     » topic index » view message » categorize

19. Re: How to sort ListView?

Derek Parnell wrote:
> 
> Antonio Alessi wrote:
> > 
> > Derek Parnell wrote:
> > > 
> > > I see that you didn't understand my example of a custom sort function. 
> > > 
> > > There are two special calls of the routine. One before the sort starts and
> > > one after the
> > > sort ends. In both these cases, the lItem1 and lItem2 parameters are set
> > > to -1. You need
> > > to check for item values >= 0 before calling getLVItemText. If you get an
> > > item value <
> > > 0 then return with w32True. 
> > > 
> > > -- 
> > > Derek Parnell
> > > Melbourne, Australia
> > > irc://irc.sorcery.net:9000/euphoria
> > > 
> > I'm sorry, I did not deepen that since I could immediately verified, as you
> > suspected,
> > 
> > the Win32lib v0.60.6 error in my routine, which is working well with the
> > Win32lib-59.
> > 
> > I will give a look into in order to learn more, but I'm afraid that some
> > confusion
> > arised: 
> > even if I adjust those custom sort functions, I don't think I could use the
> > autosort
> > 
> > instructions with the Win32lib-59; do you?
> 
> I do not have a copy of v0.59 with me so I cannot answer your question just
> now. If
> you look into the win32lib.ew file for how 'kLVSortRtn' is used, you can find
> the answer
> yourself.
> 
> I think you can but I don't understand why you can't use v0.60.6. You state
> that there
> are incompatiblities but I don't know what they are. 
> 
> My advice is to upgrade win32lib and change your application accordingly, if
> required.
> My previous advice about sorting ListView controls works fine for Win32lib
> v0.60.6.
> 
> -- 
> Derek Parnell
> Melbourne, Australia
> irc://irc.sorcery.net:9000/euphoria
> 

As I wrote, I have tried to upgrade since the first v0.60 release, but the
problems became more than one.
Sometimes I am enticed to do that, but it's a matter of time. My procedure is
large and grows with new features and choices (just the contrary of the technique
for writing bugfree programs ;) and I wonder
how much time this version change could require. I come from having spent many
weeks in order to replace an initial formulation by EditText with a RichText
(that I had to learn, as everything else).

As is, the program runs and the autosort is to be considered a simple
refinement, not a main problem.
However, according to your suggestion, I intend to do that at the 2nd release,
if the first one will take place.

For not to leave such a big question mark, I have put on site two screen shots:

http://hyphenator.myway.it/images/Clipboard_59.gif

http://hyphenator.myway.it/images/Clipboard_60.gif

which you can view and note some immediate differences:

1. the upper icons borders introduce black shadows
2. one combo disappeared on repaint
3. the bottom buttons (included into a StatusBar) do not appear inside the main
window, even if enlarged.

Although not well visible, the header contains 2 Toolbars and 2 FlatToolBar,
whose height seems to reflect some problems to the footer space evaluation. So
the matter would not be so short to reset.

Thanks,

Antonio Alessi

new topic     » goto parent     » topic index » view message » categorize

20. Re: How to sort ListView?

Al Getz wrote:
> 
> 
> Antonio Alessi wrote:
> > 
> > Al Getz wrote:
> > > 
> > > Hello again Antonio,
> > > 
> > > Im not sure if this will help or not, but in one program i used the
> > > list view 'owner data' style and sorted the entire contents with a
> > > special sort routine that sorts by column.  On program startup, the
> > > data is first sorted by whatever column, then later, as the user clicks
> > > columns, the data is sorted by that column.  Since the list view uses
> > > owner data it gets the correct values without having to reload the
> > > whole list every time a sort is done.
> > > 
> > > This technique has a two basic requirements:
> > > 
> > > 1.  The list view style must be set to owner data style
> > > 2.  The list view contents must be stored as a Euphoria sequence of seq's
> > > 
> > > Perhaps you can tell us how your program acquires the data for the
> > > listview when the program starts up...
> > > 
> > > 
> > > Take care,
> > > Al
> > > 
> > > And, good luck with your Euphoria programming!
> > > 
> > > My bumper sticker: "I brake for LED's"
> > > 
> > Hello Al,
> > 
> >           of course, I can do.
> > It simply deals with a list of files got like this:
> > }}}
<eucode>
> >       ItemEntry = walk_dir( TargetDir, ...  (simplified)
> <font color="#330033">> <font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">></eucode>
{{{
</font></font>
> > and stored exactly as a sequence:
> > }}}
<eucode>
> > 	  addLVItem( fListVw, 0,
> > 	  { sprint( ItemEntry[D_DAY])& "-" & mth[ItemEntry[D_MONTH]]& "-"
> > &year[3..4]& " ", ItemEntry[D_NAME],
> > 	  sprint( -floor( -ItemEntry[D_SIZE]/1010)), 
> > 	  sprintf("%02d:%02d", {ItemEntry[D_HOUR], ItemEntry[D_MINUTE]}),
> > 	  path_name })
> <font color="#330033">> <font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">></eucode>
{{{
	  </font></font>
> > I could add the LVS_OWNERDATA to:
> > 
> > flags = or_all( {LVS_EX_GRIDLINES, LVS_EX_FULLROWSELECT, LVS_EX_CHECKBOXES,
> > LVS_EX_HEADERDRAGDROP,
> > LVS_OWNERDATA})
> > 
> > What should I do then to sort by whatever column on program startup?
> > 
> > Antonio
> > 
> 
> Hi Antonio,
> 
> 
> Oh ok, it sounds like you can use this method.  I originally got the idea
> from Pete Lomax when we were discussing list view sorting, and from there
> i created a function to sort by column if the data is stored in a Euphoria
> sequence (which yours is too) in the following form...
> 
> s={
>     {r1c1,r1c2,r1c3,...},
>     {r2c1,r2c2,r2c3,...},
>     {...,...}
>   }
> 
> where r stands for row and c stands for column.
> 
> 
> There's two different routines...
> 
> 
>   -- Example 1, sort by one column alone:
>   --  s=
>   --    {
>   --      {1,4,2},
>   --      {2,3,3},
>   --      {3,2,1}
>   --    }
>   --  s=column_upper_case_sort(s,3)
>   --
>   --  result:
>   --    {
>   --      {3,2,1},
>   --      {1,4,2},
>   --      {2,3,3}
>   --    }
> All the data has been sorted according to column 3.
> 
> 
> The second function sorts according to column priority:
> 
>   --  s=column_upper_case_sort(s,3)
>   --  s=column_upper_case_sort2(s,3,2)
>   --  s=column_upper_case_sort2(s,2,1).
>   --
>   --  After the last call, the list is sorted according to all rows
>   --  with col 3 highest priority, col 2 next highest, and col 1 lowest.
> 
> You dont always need the second form 'sort2' but it's handy
> for some things.  Usually you would sort first by column 1, then 2,
> then 3, etc., to get a nice order to everything.
> 
> For your app, you may wish to store something like this:
> 
> s={
>     {filename1,date1,bytes1},
>     {filename2,date2,bytes2},
>     {filename3,date3,bytes3}
>   }
> 
> so you can sort by filename, date, bytes, or even make filename
> first priority, date second, and bytes third, or any other priority
> order you deem appropriate.
<snip>

Hello Al,

At this point I believe that it could be interesting for everyone involved by
this matter to access your routine, myself included.
It should be the worthy completion of this discussion.

While for my current subject I thought at first could simply add each Item to
the List selecting the row, with the: addLVItem( {fListVw, row}, 0, .., formula
according to the column's order, I have developed too the Sort with chained
column's priorities in one DOS file manager many years ago.
If your tool does this and that let it be welcome one!

To complete the subject, I have also found that in my case the walk_dir( )
function allows to pre-select the default sort column.

Best wishes from Italy.

new topic     » goto parent     » topic index » view message » categorize

21. Re: How to sort ListView?

Antonio Alessi wrote:
> 
> Al Getz wrote:
> > 
> > 
> > Antonio Alessi wrote:
> > > 
> > > Al Getz wrote:
> > > > 
> > > > Hello again Antonio,
> > > > 
> > > > Im not sure if this will help or not, but in one program i used the
> > > > list view 'owner data' style and sorted the entire contents with a
> > > > special sort routine that sorts by column.  On program startup, the
> > > > data is first sorted by whatever column, then later, as the user clicks
> > > > columns, the data is sorted by that column.  Since the list view uses
> > > > owner data it gets the correct values without having to reload the
> > > > whole list every time a sort is done.
> > > > 
> > > > This technique has a two basic requirements:
> > > > 
> > > > 1.  The list view style must be set to owner data style
> > > > 2.  The list view contents must be stored as a Euphoria sequence of
> > > > seq's
> > > > 
> > > > Perhaps you can tell us how your program acquires the data for the
> > > > listview when the program starts up...
> > > > 
> > > > 
> > > > Take care,
> > > > Al
> > > > 
> > > > And, good luck with your Euphoria programming!
> > > > 
> > > > My bumper sticker: "I brake for LED's"
> > > > 
> > > Hello Al,
> > > 
> > >           of course, I can do.
> > > It simply deals with a list of files got like this:
> > > }}}
<eucode>
> > >       ItemEntry = walk_dir( TargetDir, ...  (simplified)
> <font color="#330033">> <font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">>> <font color=</font><font
> color=</font><font color="#00A033">"#00A033"</font><font
> color="#330033">></font><font color="#00A033">"#330033"</font><font
> color="#330033"></font><font color=</font><font
> color="#00A033">"#330033"</font><font
> color="#330033">>></eucode>
{{{
</font></font></font>
> > > and stored exactly as a sequence:
> > > }}}
<eucode>
> > > 	  addLVItem( fListVw, 0,
> > > 	  { sprint( ItemEntry[D_DAY])& "-" & mth[ItemEntry[D_MONTH]]& "-"
> > > &year[3..4]& " ", ItemEntry[D_NAME],
> > > 	  sprint( -floor( -ItemEntry[D_SIZE]/1010)), 
> > > 	  sprintf("%02d:%02d", {ItemEntry[D_HOUR], ItemEntry[D_MINUTE]}),
> > > 	  path_name })
> <font color="#330033">> <font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">>> <font color=</font><font
> color=</font><font color="#00A033">"#00A033"</font><font
> color="#330033">></font><font color="#00A033">"#330033"</font><font
> color="#330033"></font><font color=</font><font
> color="#00A033">"#330033"</font><font color="#330033">>></eucode>
{{{

>   </font></font></font>
> > > I could add the LVS_OWNERDATA to:
> > > 
> > > flags = or_all( {LVS_EX_GRIDLINES, LVS_EX_FULLROWSELECT,
> > > LVS_EX_CHECKBOXES, LVS_EX_HEADERDRAGDROP,
> > > LVS_OWNERDATA})
> > > 
> > > What should I do then to sort by whatever column on program startup?
> > > 
> > > Antonio
> > > 
> > 
> > Hi Antonio,
> > 
> > 
> > Oh ok, it sounds like you can use this method.  I originally got the idea
> > from Pete Lomax when we were discussing list view sorting, and from there
> > i created a function to sort by column if the data is stored in a Euphoria
> > sequence (which yours is too) in the following form...
> > 
> > s={
> >     {r1c1,r1c2,r1c3,...},
> >     {r2c1,r2c2,r2c3,...},
> >     {...,...}
> >   }
> > 
> > where r stands for row and c stands for column.
> > 
> > 
> > There's two different routines...
> > 
> > 
> >   -- Example 1, sort by one column alone:
> >   --  s=
> >   --    {
> >   --      {1,4,2},
> >   --      {2,3,3},
> >   --      {3,2,1}
> >   --    }
> >   --  s=column_upper_case_sort(s,3)
> >   --
> >   --  result:
> >   --    {
> >   --      {3,2,1},
> >   --      {1,4,2},
> >   --      {2,3,3}
> >   --    }
> > All the data has been sorted according to column 3.
> > 
> > 
> > The second function sorts according to column priority:
> > 
> >   --  s=column_upper_case_sort(s,3)
> >   --  s=column_upper_case_sort2(s,3,2)
> >   --  s=column_upper_case_sort2(s,2,1).
> >   --
> >   --  After the last call, the list is sorted according to all rows
> >   --  with col 3 highest priority, col 2 next highest, and col 1 lowest.
> > 
> > You dont always need the second form 'sort2' but it's handy
> > for some things.  Usually you would sort first by column 1, then 2,
> > then 3, etc., to get a nice order to everything.
> > 
> > For your app, you may wish to store something like this:
> > 
> > s={
> >     {filename1,date1,bytes1},
> >     {filename2,date2,bytes2},
> >     {filename3,date3,bytes3}
> >   }
> > 
> > so you can sort by filename, date, bytes, or even make filename
<snip>

Hi again Antonio,


Ok let me clean up the file a little then i'll upload it.
Oh, from Italy?  My grandfather was from Sicily smile


Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

new topic     » goto parent     » topic index » view message » categorize

22. Re: How to sort ListView?

> 
> Hi again Antonio,
> 
> 
> Ok let me clean up the file a little then i'll upload it.
> Oh, from Italy?  My grandfather was from Sicily smile
> 
> 
> Take care,
> Al
> 
> And, good luck with your Euphoria programming!
> 
> My bumper sticker: "I brake for LED's"
> 

My grandfather was from Sicily too :o))

Antonio

new topic     » goto parent     » topic index » view message » categorize

23. Re: How to sort ListView?

Antonio Alessi wrote:
> 
> > 
> > Hi again Antonio,
> > 
> > 
> > Ok let me clean up the file a little then i'll upload it.
> > Oh, from Italy?  My grandfather was from Sicily smile
> > 
> > 
> > Take care,
> > Al
> > 
> > And, good luck with your Euphoria programming!
> > 
> > My bumper sticker: "I brake for LED's"
> > 
> 
> My grandfather was from Sicily too :o))
> 
> Antonio
> 

Hi Antonio,


His first name wasnt Giuseppe (variant spellings) was it?  smile

Ok, the file has been submitted to the archive site.  Let me know
if it helps.  You can sort by any column, or by any number of columns
in the desired order.


Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

new topic     » goto parent     » topic index » view message » categorize

24. Re: How to sort ListView?

Al Getz wrote:
> 
> Hi Antonio,
> 
> 
> Ok, the file has been submitted to the archive site.  Let me know
> if it helps.  You can sort by any column, or by any number of columns
> in the desired order.
> 
> 
> Take care,
> Al
> 
> And, good luck with your Euphoria programming!
> 
> My bumper sticker: "I brake for LED's"
> 

Hi Al,

I have run your excellent columnsort work; I find it special, but in my case the
challenge seems to expand:
I have to reckon with the structure.
My ListView is ready and well working - apart the problem of beginning sort by
an instruction - but it cannot directly handle the column_.._sort routines;
right?

I could not find out any information about the LVS_OWNERDATA and what it does.
Your examples do not work on a ListView, they sort the full sequence at a time
instead;
should I get all the items into a sequence and sort them? 

In any case I need to interface the ListView with your routines; how can I set
the Handlers for every column?
Can you clarify?

Thanks 
Antonio Alessi

new topic     » goto parent     » topic index » view message » categorize

25. Re: How to sort ListView?

Antonio Alessi wrote:
> 
> Al Getz wrote:
> > 
> > Hi Antonio,
> > 
> > 
> > Ok, the file has been submitted to the archive site.  Let me know
> > if it helps.  You can sort by any column, or by any number of columns
> > in the desired order.
> > 
> > 
> > Take care,
> > Al
> > 
> > And, good luck with your Euphoria programming!
> > 
> > My bumper sticker: "I brake for LED's"
> > 
> 
> Hi Al,
> 
> I have run your excellent columnsort work; I find it special, but in my case
> the challenge
> seems to expand:
> I have to reckon with the structure.
> My ListView is ready and well working - apart the problem of beginning sort by
> an instruction
> - but it cannot directly handle the column_.._sort routines; right? 
> 
> I could not find out any information about the LVS_OWNERDATA and what it does.
> Your examples do not work on a ListView, they sort the full sequence at a time
> instead;
> 
> should I get all the items into a sequence and sort them? 
> 
> In any case I need to interface the ListView with your routines; how can I set
> the
> Handlers for every column?
> Can you clarify?
> 
> Thanks 
> Antonio Alessi
> 

Hi there Antonio,


I know this method works fairly well because i have a working demo
using another lib (WinClass) and it sorts the Listview as columns
are clicked...that's why i suggested it might work for you too because
your program has a similar need for handling the sort.

Here are the basic steps involved...

1.  Include the LVS_OWNERDATA style when you create the listview.
    This has to be done during creation only.
2.  Process WM_NOTIFY for the parent window, trapping:
      code=LVN_COLUMNCLICK, and getting the zero based column number:
        columnnumb=peek4u(lParam+16)
        then add 1:
          columnnumb+=1
      You now have the column the user clicked, so now you can sort:
ListViewData1=prioritized_columns_upper_case_sort(ListViewData1,{columnnumb})
      r=SendMessage(LV1,LVM_REDRAWITEMS,0,99999999) --or whatever numb of lines
      Now the list is sorted and the viewable part is displayed.

    Also trap:
      LVN_GETDISPINFO
      and use the data passed to get the requested string.


This wouldnt be hard to do if you could ask Derek how to trap
LVN_COLUMNCLICK and LVM_GETDISPINFO using winlib.  I could then
provide you with the rest of the details.

I noticed you mentioned that the 'whole' list gets sorted?
If this isnt what you wanted (only the visible portion) then
you need to handle the data differently by creating a separate
sequence (list) for only the items on the screen.


Take care,
Al



    



Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

new topic     » goto parent     » topic index » view message » categorize

26. Re: How to sort ListView?

Al Getz wrote:
> 
> Antonio Alessi wrote:
> > 
> > Al Getz wrote:
> > > 
> > > Hi Antonio,
> > > 
> > > 
> > > Ok, the file has been submitted to the archive site.  Let me know
> > > if it helps.  You can sort by any column, or by any number of columns
> > > in the desired order.
> > > 
> > > 
> > > Take care,
> > > Al
> > > 
> > > And, good luck with your Euphoria programming!
> > > 
> > > My bumper sticker: "I brake for LED's"
> > > 
> > 
> > Hi Al,
> > 
> > I have run your excellent columnsort work; I find it special, but in my case
> > the challenge
> > seems to expand:
> > I have to reckon with the structure.
> > My ListView is ready and well working - apart the problem of beginning sort
> > by an instruction
> > - but it cannot directly handle the column_.._sort routines; right? 
> > 
> > I could not find out any information about the LVS_OWNERDATA and what it
> > does.
> > Your examples do not work on a ListView, they sort the full sequence at a
> > time instead;
> > 
> > should I get all the items into a sequence and sort them? 
> > 
> > In any case I need to interface the ListView with your routines; how can I
> > set the
> > Handlers for every column?
> > Can you clarify?
> > 
> > Thanks 
> > Antonio Alessi
> > 
> 
> Hi there Antonio,
> 
> 
> I know this method works fairly well because i have a working demo
> using another lib (WinClass) and it sorts the Listview as columns
> are clicked...that's why i suggested it might work for you too because
> your program has a similar need for handling the sort.
> 
> Here are the basic steps involved...
> 
> 1.  Include the LVS_OWNERDATA style when you create the listview.
>     This has to be done during creation only.
> 2.  Process WM_NOTIFY for the parent window, trapping:
>       code=LVN_COLUMNCLICK, and getting the zero based column number:
>         columnnumb=peek4u(lParam+16)
>         then add 1:
>           columnnumb+=1
>       You now have the column the user clicked, so now you can sort:
>      
>       ListViewData1=prioritized_columns_upper_case_sort(ListViewData1,{columnnumb})
>       r=SendMessage(LV1,LVM_REDRAWITEMS,0,99999999) --or whatever numb of
>       lines
>       Now the list is sorted and the viewable part is displayed.
> 
>     Also trap:
>       LVN_GETDISPINFO
>       and use the data passed to get the requested string.
> 
> 
> This wouldnt be hard to do if you could ask Derek how to trap
> LVN_COLUMNCLICK and LVM_GETDISPINFO using winlib.  I could then
> provide you with the rest of the details.
> 
> I noticed you mentioned that the 'whole' list gets sorted?
> If this isnt what you wanted (only the visible portion) then
> you need to handle the data differently by creating a separate
> sequence (list) for only the items on the screen.
> 
> 
> Take care,
> Al
> 
> 
> Take care,
> Al
> 
> And, good luck with your Euphoria programming!
> 
> My bumper sticker: "I brake for LED's"
> 

Hi Al,

I'm sorry, most of that is out of my current knowledge; I'm afraid those options
must wait.
I have began this search for a nuance and so far it's taking more and more time
and attention; besides I don't yet know where it could bring ;)
I want to thank you for the chance that you shared so kindly; I'm sure it could
be conveniently used for other projects.

Antonio

new topic     » goto parent     » topic index » view message » categorize

27. Re: How to sort ListView?

Hi there Antonio,


If you'd like to send the program AND your current WinLib version
i'll take a look, but you'll have to explain what you want this
listview to do and perhaps why so i have a clear idea what it is
you're trying to do.


Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

new topic     » goto parent     » topic index » view message » categorize

28. Re: How to sort ListView?

Al Getz wrote:
> 
> Hi there Antonio,
> 
> 
> If you'd like to send the program AND your current WinLib version
> i'll take a look, but you'll have to explain what you want this
> listview to do and perhaps why so i have a clear idea what it is
> you're trying to do.
> 
> 
> Take care,
> Al
> 
> And, good luck with your Euphoria programming!
> 
> My bumper sticker: "I brake for LED's"
> 

Hi there Al,

that is really very kind of you!

Well, let's clarify. 
This problem is not a real need: it deals with the idea of repeating on startup
of my prog. the same sort situation left on exit by the user.
As you can see, it is not high priority and is not worth of too much attention,
in case of such a difficulty (read: the Windows' complicatedness). It is
requiring a lot of time, while I am too busy in fighting with bugs, which have
been multiplied by change and grow and enhance etc..

Just one more thought: it could be interesting to apply your routines to a
ListView in that this could allow to set an invisible column for Dates which
could be quickly sorted in number format, and for Types, when not needed to the
view, as in my case, or for anything else of indirect use.

I'll send you the program however.

Antonio Alessi

new topic     » goto parent     » topic index » view message » categorize

29. Re: How to sort ListView?

Antonio Alessi wrote:
> 
> Al Getz wrote:
> > 
> > Hi there Antonio,
> > 
> > 
> > If you'd like to send the program AND your current WinLib version
> > i'll take a look, but you'll have to explain what you want this
> > listview to do and perhaps why so i have a clear idea what it is
> > you're trying to do.
> > 
> > 
> > Take care,
> > Al
> > 
> > And, good luck with your Euphoria programming!
> > 
> > My bumper sticker: "I brake for LED's"
> > 
> 
> Hi there Al,
> 
> that is really very kind of you!
> 
> Well, let's clarify. 
> This problem is not a real need: it deals with the idea of repeating on
> startup of
> my prog. the same sort situation left on exit by the user.
> As you can see, it is not high priority and is not worth of too much
> attention, in
> case of such a difficulty (read: the Windows' complicatedness). It is
> requiring a lot
> of time, while I am too busy in fighting with bugs, which have been multiplied
> by change
> and grow and enhance etc..
> 
> Just one more thought: it could be interesting to apply your routines to a
> ListView
> in that this could allow to set an invisible column for Dates which could be
> quickly
> sorted in number format, and for Types, when not needed to the view, as in my
> case,
> or for anything else of indirect use.
> 
> I'll send you the program however.
> 
> Antonio Alessi
> 

Hi Antonio,

So you want the program to do the same sort that the user last did
before last closing the program?
If this is correct, why dont you try saving the last column clicked?
If you're using a multi-column sort you could save the last call
sequence to the 'prioritized column sort' or you could simply
build your own sequence (list) of columns as the user clicks a column.

Perhaps you could send me an explanation of what your program is
supposed to do, in as much detail as possible.

BTW, im not really sure what you meant by 'invisible column' maybe
you could explain more...


Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

new topic     » goto parent     » topic index » view message » categorize

30. Re: How to sort ListView?

Oh BTW Antonio...

You sent the exe file, can you send a zip file of the ew and exw files
instead ?



Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

new topic     » goto parent     » topic index » view message » categorize

31. Re: How to sort ListView?

Al Getz wrote:
> 
> Oh BTW Antonio...
> 
> You sent the exe file, can you send a zip file of the ew and exw files
> instead ?
> 
> 
> Take care,
> Al
> 
> And, good luck with your Euphoria programming!
> 
> My bumper sticker: "I brake for LED's"
> 

Here I am again AL,

sorry to aswer so late; busy outside.

What I sent to you is just the About program, if I am not wrong.

The full program is a big procedure, that I'm trying to get runnig correctly,
although not without bugs, in order to show it to you.

But it seems I have met one system error on a tester's machine (not existing on
mY Win2000 and XP OS) and I' trying to fix it before.
Hope in these days. 


Antonio

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu