#53 OODialog ListControlClass ~prev ~next errors

v3.0beta
closed
Rick McGuire
Classes (182)
5
2012-08-14
2005-03-18
Jon Wolfers
No

~prev & ~next should return -1 if there is no previous or
next item. However, when the list has only 1 item they
both return 0

This behaviour observed in 2.1.3. I do not have a beta
base to test against at present.

Discussion

  • Jon Wolfers
    Jon Wolfers
    2005-04-10

    Logged In: YES
    user_id=667060

    Looking at the source for the Advctrl mixinclass, this error
    could easily be fixed by inserting the following line as the
    second line of the previous and next methods of the
    listcontrol class:

    if self~LastItem < 2 then return -1

    so the code could look like this:

    ::method Next
    use arg startItem
    if self~LastItem < 2 then return -1 / line inserted to fix bug
    in HandleListCtrl
    /
    if Arg(1,'o') = 1 then startItem = -1
    return HandleListCtrl("I","GETNEXT", self~Hwnd,
    startItem, "BELOW TORIGHT")

    ::method Previous
    use arg startItem
    if self~LastItem < 2 then return -1 / line inserted to fix bug
    in HandleListCtrl
    /
    if Arg(1,'o') = 1 then startItem = -1
    return HandleListCtrl("I","GETNEXT", self~Hwnd,
    startItem, "ABOVE TOLEFT")

     
  • Jon Wolfers
    Jon Wolfers
    2006-04-27

    Logged In: YES
    user_id=667060

    I can now confirm this happens in v3

    Rick suggested I should attach a patch to this.
    I have managed to go halfway, & here is a diff for the fix.
    One thing that might confuse those testing this fix is that
    the first item in a list control is numbered 0.

    So previous for item 0 should always return -1, but if there
    is only one item in the list it returns 0 causing infinite
    loops in users programs.

    likewise, next for item 0 should return 1 if there is
    another item or -1 if there isnt, but if there is only one
    item in the list it returns 0

    cvs diff -- advctrl.cls (in directory
    C:\CVS\oorexx\platform\windows\oodialog)
    Index: advctrl.cls
    ===================================================================
    RCS file:
    /cvsroot/oorexx/oorexx/platform/windows/oodialog/advctrl.cls,v
    retrieving revision 1.3
    diff -r1.3 advctrl.cls
    897a898,901

                   /* the following line corrects a bug in
    

    HandleListControl /
    if self~LastItem < 2 then return -1 /
    Sahananda 27
    Apr 2006 [1165949] */

    902a907,910

                   /* the following line corrects a bug in
    

    HandleListControl /
    if self~LastItem < 2 then return -1 /
    Sahananda 27
    Apr 2006 [1165949] */

     


Anonymous


Cancel   Add attachments