Need help with click error on a list box

  1. ‹ Older
  2. 2 weeks ago

    I unhooked the internet and turned off all the anti-virus and firewalls and exploit prevention off. Still have the problem.

    But did I need to turn off any windows security too?
    Dave

  3. Emile S

    Jul 4 Europe (France, Strasbourg)

    Listbox (Row, Column, ListCount, etc.), Arrays, etc. returns or use 0-based values.

    Overall, without seeing real code how can we guess the correct anwser ?

  4. Are you working in a built module or in the IDE? If in the IDE, set a breakpoint before it crashes, and then step through line by line until it crashes, and then you know the offending line.

    Are you using a thread, timer, or other background process that could be running at the same time and that could be crashing the program? If so, deactivate them and see if the crash still occurs.

    Are you using a lot of memory (images or videos)? A Xojo app will crash without warning if you run out of total system memory.

  5. Edited 2 weeks ago

    I'm using the IDE and have 12 Gigs of memory.
    I've used the TRY command as the first line in the CHANGE function of the Listbox and on the mouse down & up and it never gets there. (see my original question)
    The problem with using a breakpoint is that the failure only happens once in a while maybe 1 in 25 tries.

    as far as "Overall, without seeing real code how can we guess the correct answer ?" is concerned I'm not sure what you mean by real code.

    It's like it fails when I click on an item in a listbox and never gets to any code thereafter (Not exception, or TRY or even a Message statement. ) Is there anywhere else I can put the TRY command or Message command? or is there an ON ERROR command?

    Like I said before any ideas will be greatly apricated as I'm not the brightest bulb around.
    Thanks
    Dave

    PS As far as I know I'm NOT using a thread, timer, or other background process that could be running at the same time.

  6. Edited 2 weeks ago

    It is worth knowing if the program is even reaching the code in your ListBox event handler.

    Consider putting something like this at the beginning of your MouseDown (or other event handler you are using) code:

    STATIC RunCount AS INTEGER = 0
    RunCount = RunCount + 1
    DIM d AS NEW Date
    DIM Now as STRING = d.LongTime
    
    DIM f AS FolderItem = GetFolderItem ("SomeFileName.log")
    IF f <> Nil THEN
      DIM t AS TextOutputStream = TextOutputStream.Append (f)
      t.Write Now + " (" + Str (RunCount) + ")" + EndOfLine
      t.Close
    END IF

    Choose an appropriate path and file name for SomeFileName.log.

    Monitor the log file. Especially keep track of the number of times you click, and check if the log file agrees with the number of Event responses. If the code does not even run on the cycle that the app crashes, then you probably have a compiler bug. If the event response runs before the crash, then move the above code down, after a few lines of "real" code in your event handler, until you find the offending line of code.

  7. Dale A

    Jul 5 San Diego, California, USA

    Without seeing the actual code, we're all guessing here so let's clear up a few specifics to help us (me) focus.

    1. You said you're on Windows 10. What version Xojo are you using?
    2. Since you said it happens in all your programs that have a listbox in them and on other computers, I assume that you built the App and moved the executables and Libs to the other machines. Perhaps the Xojo installation is somehow munged. Have you removed it and reinstalled from a freshly downloaded copy? Remove any 3rd party plugins, scripts, etc., that you may have.

    If you have done the above without success ...

    1. You say "when I click on an item..." what are you clicking on? Are you clicking on the listbox header, a cell in a row, in the space below the last row?
    2. If you are clicking on a cell, does the app just select the row or are you opening the cell for editing? (Calling EditCell?)
    3. Does the crash happen when a cell is selected and you click on another cell in the listbox in the same row? Or in a different row/column? Or in the free space below the last row? Or someplace outside the listbox?

    Lastly,
    6. Try starting a new, blank project with nothing in it and, from the IDE's Control Library, add only a listbox to the main window. Add a few rows of data in the Listbox's Open event. Run it and go on a clicking spree. Does the problem still occur? If so, revisit item #2.

  8. last week

    Thanks for all the help guys especially Alex and Dale

    Dale
    I am running the latest version of XOJO but it is happening with earlier versions of XOJO too.
    When I click on an item it is a line in the listbox not a heading or a blank line.
    Note: It happens on listboxes that have no cells too. As far as I can tell it has never happened when I click on a blank line.
    When I have tried it on other machines it has been a clean install of XOJO but I transferred the my program over.
    The problem occurs when I click on an item a listbox and the program instantly drops back to the IDE or if I'm running a build the program just quits. Other times I get a rotating circle before it crashes.

    That's why I I'm beginning to think Alex maybe right about Norton but can't prove it yet. There's something in the back of my mind that tells me that Norton and XOJO don't get along. (Hopefully I'll remember what the problem was.)

    In the mean time I'm running out of time before I have to do something else

    Dave

  9. Jeff T

    Jul 6 Pre-Release Testers Midlands of England, Europe

    A listbox might have change, cell click , mousedown and other events

    Exactly WHICH events have you implemented?
    Do you have 'SetFocus' anywhere in your code?

    You might be suffering a stack overflow if events are cascading.
    But can you please post your code and tell us which events you have implemented?
    Trying to guess what your code looks like is crazy.

  10. Julian S

    Jul 6 Pre-Release Testers, Xojo Pro UK
    Edited last week

    Are you able to replicate this in a new simple project? If you are, post an example and we'll take a look.

    If not, sprinkle your listbox events with system.debuglog's with increasing numeric values, e.g system.debuglog("here1") here2 here3 etc.

    Download https://docs.microsoft.com/en-us/sysinternals/downloads/debugview and run it along side your app. This will show the messages you just sprinkled around your app and will not have the flushing issues of the IDE where messages can be lost and not actually be reported to the IDE debug pane on a crash.

    You'll then be able to narrow down where your app got to before the crash and work back from there. Block comment out code until it stops happening to narrow it down even further.

  11. Here is the code that I use to load the List box

    'MsgBox "at LoadSameGroupingListBox"

    //This routine will list all book locations)
    Dim intAA As Integer
    Dim intRecordID As Integer
    Dim intTotalRecords As integer

    dim strAA As string
    dim strBB As string
    dim strCC As string
    Dim strDD As String
    Dim strRecordType As string
    Dim strBookName as String
    Dim strAuthor as String
    Dim strDescription as String
    Dim strTypeBook as String
    Dim strMyRating as String
    Dim strLocation as String
    Dim strDateLastRead as String
    Dim strSameGrouping as String
    Dim strCurrentSameGroupingCode As String
    Dim strStartName As String
    Dim strEndName As String

    strStartName = ""
    strStartName = Trim(txtGetSortGroupCode.Text)
    strStartName = F__Aphosphes_Replace(strStartName)
    strStartName = Uppercase(strStartName)
    strEndName = strStartName + "||||||"
    'MsgBox "start name is: " + strStartName

    lstSameGroupingListBox.DeleteAllRows
    lstSameGroupingListBox.TextSize = 16
    intTotalRecords = 0
    strCurrentSameGroupingCode = ""
    //============================================================
    //============================================================
    //Get all christian romance books
    'rs = db.SQLSelect("SELECT * From MyBooks WHERE (RecordType) = 'BOOKS' and (TypeBook) = 'CHRISTIAN ROMANCE' ORDER BY RecordType, DateLastRead, BookName asc")
    RS_01 = DB__01.SQLSelect("SELECT * From Table_One WHERE (Record_Type) = 'BOOKS' ORDER BY Record_Type, Field_08 asc")

    //note you can only SQL the access table not a querry on the tables
    While Not RS_01.EOF
    intRecordID = RS_01.IdxField(1).IntegerValue
    int__Record_ID = intRecordID
    db_Read_A_DB_Record_By_ID_Number
    strRecordType =str__RecordType
    strBookName = str__Field_03
    strLocation =str__Field_04
    strDescription = str__Field_05
    strDateLastRead= str__Field_06
    strTypeBook =str__Field_07
    strSameGrouping =str__Field_08
    strMyRating =str__Field_09
    strAuthor = str__Field_10

    if str__Field_08 >= strStartName then
    'MsgBox "we want to show this author name in alphabetical order
    'bool__SearchingTheWhloeSubject = False


    //-------------------------------------------------------
    //check to see if we have already processed this location code
    if strCurrentSameGroupingCode = strSameGrouping then
    //we have already proessed this code do nothing
    Else
    //we need to show this group code

    strCurrentSameGroupingCode = strSameGrouping
    strAA = Trim(str__Field_08)
    lstSameGroupingListBox.AddRow strAA

    intTotalRecords = intTotalRecords +1

    end if

    end if

    RS_01.MoveNext
    wend
    RS_01.Close
    lstSameGroupingListBox.addrow ""
    lstSameGroupingListBox.AddRow
    lstSameGroupingListBox.AddRow "TOTAL = " + str(intTotalRecords)
    lstSameGroupingListBox.SetFocus

    When the program gets to this point I click on one of the selection.

    Do you want to see my change code also?
    Dave

  12. @David H — I have already run into a similar situation. To my recollection, Xojo can call a ListBox event with an invalid row or column (-1) when you click after the last row or after the last column (in case your column is shorter in width than the ListBox).

    Please insert a line

    if row<0 or column<0 then return

    at the beginning of your event to see if it changes anything.

  13. I can't put your command in in my code as it says row and column
    lstSameGroupingListBox.Row and lstSameGroupingListBox.column
    are unknown.

    Good idea though

    This is how I take care the out of bounds problem.

    strAA = lstSameGroupingListBox.List(lstSameGroupingListBox.ListIndex)
    if lstSameGroupingListBox.ListIndex < 0 then
    MsgBox "we clicked on a blank line"
    exit
    end if
    Thanks for the idea.
    Dave

    PS: This listbox has no cells.

  14. Emile S

    Jul 6 Europe (France, Strasbourg)

    @David H PS: This listbox has no cells.

    Care to explain ?

    @David H MsgBox "we clicked on a blank line"

    This is not an error: a Click in a non Row area * deselect the eventual selected Row(s) / allow you to do some different stuff (depends on what you do with the Listbox.

    * blank line is unknow here, as my Listbox(s) always have alternately colored Rows / Recalls me Blank Areas (™) that can appears (a bug) sometimes. ;)

  15. @David H — I can't figure out your execution flow though. If you want to track down where the problem is after clicking on a row, you need to do it from the first Event raised by the ListBox. So what is important here is the code you have within the CellClick or Change event. So where is your code located exactly?

    This is how I take care the out of bounds problem.
    strAA = lstSameGroupingListBox.List(lstSameGroupingListBox.ListIndex)...

    Well, you are investigating a weird situation which is potentially a bug in Xojo. That means that you cannot assume that ListIndex has a correct value. So, before "strAA = ..." I would check that lstSameGroupingListBox.ListIndex is not below zero before using it. In other words, it would be better to rewrite your code as:

    if lstSameGroupingListBox.ListIndex < 0 then
        MsgBox "we clicked on a blank line"
        return  //Exit is usually not a good solution.
    else  //<<< Here, you have already checked the ListIndex value, so it is safe to use.
        strAA = lstSameGroupingListBox.List(lstSameGroupingListBox.ListIndex)
    end if

    PS: This listbox has no cells.

    A ListBox with "no cells" means that it has no headers and no row whatsoever. In such a case, you would likely end up with -1 as the row and/or the column in an event.

  16. Tim S

    Jul 6 Canterbury, UK

    @David H This is how I take care the out of bounds problem.

    strAA = lstSameGroupingListBox.List(lstSameGroupingListBox.ListIndex) if lstSameGroupingListBox.ListIndex < 0 then MsgBox "we clicked on a blank line" exit end if

    By the time you want to check whether your ListIndex is less than zero, you've already crashed because you've already used it in the strAA = ... statement.

    More generally, I don't see how anyone here can help much until you:

    1) List which event handlers you have implemented for this listbox

    2) Show the code for each of them.

  17. Julian S

    Jul 6 Pre-Release Testers, Xojo Pro UK

    You might have missed https://forum.xojo.com/54725-need-help-with-click-error-on-a-list-box/p2#p444380 because you posted at the same time as me.

  18. Sorry I'm having a bad day.
    if you look at my reply (second one back) you will see how I load my listbox which has no cells.
    The first reply back is how I read an item (the change function)
    I'll try not to cause anyone anymore trouble.

    Julian thanks for the reply I'll check it out in a few minutes

  19. Jeff T

    Jul 6 Pre-Release Testers Midlands of England, Europe
    Edited last week

    you will see how I load my listbox which has no cells.

    Each row has one cell

    .Addrow"" does that

    We dont need to see how you fill it, we need to know what EVENTS you have coded, and what they contain.

    CellTextPaint
    CellBackgroundPaint
    Change
    .. what do you do??

  20. Tim S

    Jul 6 Canterbury, UK

    @David H I'm using the IDE and have 12 Gigs of memory.
    I've used the TRY command as the first line in the CHANGE function of the Listbox and on the mouse down & up and it never gets there. (see my original question)

    I deduce from this that you are at least using the change event and the mouseup and mousedown events. Any particular reason for doing this? If things are to be driven by someone clicking on a row in the listbox I'd be more inclined to start off with the cellclick event. Your cellclick event will be given the row and column of the clicked cell, so you can do your bounds checking there as Stephane suggested before:

    if row<0 or column<0 then return

    as far as "Overall, without seeing real code how can we guess the correct answer ?" is concerned I'm not sure what you mean by real code.

    We want to see the actual code in each of your event handlers for the listbox.

    Upthread you posted:

    Here is the code that I use to load the List box

    Now, where is that code? In the open event handler for the window, or perhaps the open event handler for the listbox itself? Also, I don't see where you open the database and initialise the DB__01 variable.

  21. David H

    Jul 8 Answer
    Edited last week

    Sorry I had to take some time off and look at all the information everyone had given me

    And I want to give a very big THANK YOU to Dale Arends. Your #6 (start from scratch with a 1 window project) got to me.
    So I did a one window program with just one listbox. I didn't have a failure.
    so it started me thinking and I started turning off and on other windows but anything below the first window would fail.
    In looking at the documentation I kept running across the word "COMBO" which seem to be preferred option.

    So I used a combobox instead of a listbox and to my amazement I haven't I haven't click failure yet. Of course I've only been trying for a couple of hours. LOL

    But I really want to thank Dale again because he gave me a starting point I could work with, and while I didn't solve the problem; I believe I have found a work around that I can live with.

    Thanks to everyone who tried to help me (I know I'm NOT the easiest person to work with)
    sometimes I just need to get away and start with the basics to solve a problem
    Dave

or Sign Up to reply!