TsListBox Problem with PaintListBox Procedure

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #34121
    mcone
    Participant

    The v 7.22 PaintListBox returns a List index out of bounds (0) error at this line when displaying a TsListBox:

    Code:
    DrawItemStruct.itemData := Longint(Pointer(Items.Objects));

    The pertinent error information from MadExcept is:

    Code:
    exception number : 1
    exception class : EStringListError
    exception message : List index out of bounds (0).

    main thread ($1f10):
    0087ea6a +016e vTube.exe sListBox 146 +0 PaintListBox
    0087ebe9 +0075 vTube.exe sListBox 146 +0 TsCustomListBox.WMPaint
    00550364 +02d4 vTube.exe Controls TControl.WndProc
    00554c2c +0568 vTube.exe Controls TWinControl.WndProc
    004e6080 +00f0 vTube.exe StdCtrls TCustomListBox.WndProc
    0087ee19 +01e9 vTube.exe sListBox 146 +0 TsCustomListBox.WndProc
    0067ca10 +0030 vTube.exe acSBUtils TacMainWnd.CallPrevWndProc
    00674f7c +06a4 vTube.exe acSBUtils TacScrollWnd.acWndProc
    0067a200 +00e4 vTube.exe acSBUtils TacBaseWnd.acWndProc
    0067569e +06e2 vTube.exe acSBUtils TacEditWnd.acWndProc
    005542cc +002c vTube.exe Controls TWinControl.MainWndProc
    004a8698 +0014 vTube.exe Classes StdWndProc
    77cf00e3 +002b ntdll.dll KiUserCallbackDispatcher
    767ecd7c +0047 USER32.dll SendMessageW
    0067532b +036f vTube.exe acSBUtils TacEditWnd.acWndProc
    005542cc +002c vTube.exe Controls TWinControl.MainWndProc
    004a8698 +0014 vTube.exe Classes StdWndProc
    77cf00e3 +002b ntdll.dll KiUserCallbackDispatcher
    767ecd7c +0047 USER32.dll SendMessageW
    0063d571 +0225 vTube.exe sVclUtils SkinPaintTo
    0063d659 +030d vTube.exe sVclUtils SkinPaintTo
    00640154 +093c vTube.exe sVclUtils AnimShowControl
    005e849d +008d vTube.exe sPageControl TsPageControl.CNNotify
    00550364 +02d4 vTube.exe Controls TControl.WndProc
    00554c2c +0568 vTube.exe Controls TWinControl.WndProc
    005ec169 +1209 vTube.exe sPageControl TsPageControl.WndProc
    0054ff88 +0024 vTube.exe Controls TControl.Perform
    00554d7f +0023 vTube.exe Controls DoControlMsg
    00555809 +000d vTube.exe Controls TWinControl.WMNotify
    00550364 +02d4 vTube.exe Controls TControl.WndProc
    00554c2c +0568 vTube.exe Controls TWinControl.WndProc
    0057734c +0594 vTube.exe Forms TCustomForm.WndProc
    005542cc +002c vTube.exe Controls TWinControl.MainWndProc
    004a8698 +0014 vTube.exe Classes StdWndProc
    77cf00e3 +002b ntdll.dll KiUserCallbackDispatcher
    767ecd7c +0047 USER32.dll SendMessageW
    739e8764 +0048 comctl32.dll #342
    767f0ad1 +0016 USER32.dll CallWindowProcW
    00554d2c +00d8 vTube.exe Controls TWinControl.DefaultHandler
    005509e1 +0015 vTube.exe Controls TControl.WMLButtonDown
    0050bad1 +000d vTube.exe ComCtrls TPageControl.WMLButtonDown
    00550364 +02d4 vTube.exe Controls TControl.WndProc
    00554c2c +0568 vTube.exe Controls TWinControl.WndProc
    005ec169 +1209 vTube.exe sPageControl TsPageControl.WndProc
    004a8698 +0014 vTube.exe Classes StdWndProc
    005542cc +002c vTube.exe Controls TWinControl.MainWndProc
    004a8698 +0014 vTube.exe Classes StdWndProc
    767e7df5 +000a USER32.dll DispatchMessageW
    0058044d +011d vTube.exe Forms TApplication.ProcessMessage
    00580492 +000a vTube.exe Forms TApplication.HandleMessage
    005807bd +00c9 vTube.exe Forms TApplication.Run
    0097481e +0366 vTube.exe vTube 235 +47 initialization
    77323675 +0010 kernel32.dll BaseThreadInitThunk

    The temporary solution to get the code working is to rem out the DrawItemStruct line.

    Code:
    //DrawItemStruct.itemData := Longint(Pointer(Items.Objects));

    I cannot see any observable problems at runtime after I rem out the code. But I assume that you need it there and provide this post so that you can take a look at fixing the problem.

    Mike

    #43951
    mcone
    Participant

    This problem continues in v7.23.

    #43976
    Support
    Keymaster

    Please check the version 7.24 – I have added some checks there, but I can't understand why you have this error.

    Maybe you can show me a demo?

    Problematic line can't be commented because Data property may be used in many projects…

    #44002
    mcone
    Participant

    I found the problem – and it was my fault. Apparently v6 must have been tolerant of this mistake but v7 was not. Thank you for checking anyway – and my apologies.

    Example of logic error:

    Code:
    sListbox_EntityControl.items.clear;

    for iX := 1 To iEntSize do
    begin
    sListbox_EntityControl.items[iX-1] := szText;
    end;

    Repaired logic:

    Code:
    sListbox_EntityControl.items.clear;

    for iX := 1 To iEntSize do
    begin
    sListbox_EntityControl.items.add(szText);
    end;

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.