Jump to content


Photo

ComboBoxItem Bug


  • Please log in to reply
4 replies to this topic

#1 Markus

Markus
  • Members
  • 54 posts

Posted 09 November 2006 - 03:52 PM

When using a ComboBoxItem with its style property set to cbDropDownList there's an "index exceeds maximum" access violation when you're clicking on the lower left point of the drop-down list. Make sure the last item in the list is not highlighted to reproduce this error, i.e. move your mouse cursor below the last item.

This is because TNxPopupList.AcquireValue() calculates an ItemIndex that exceeds the maximum (as the error message suggests) as the Y coordinate passed to the function is greater than expected:

CODE
FItemIndex := Y div FItemHeight + VertScrollBar.Position;  // AV if Y is greater than count * ItemHeight

It compiles, ship it!

#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 09 November 2006 - 06:52 PM

Hello Markus,

Try to replace this method with:

CODE
procedure TNxPopupList.AcquireValue(X, Y: Integer);
begin
  if PtInRect(ControlRect, Point(X, Y)) then
  begin
    FItemIndex := Y div FItemHeight + VertScrollBar.Position;
    if InRange(FItemIndex, 0, Pred(FItems.Count))
      then DoInput(Items[FItemIndex]);
  end;
end;


Please tell me if now is fine.

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 Markus

Markus
  • Members
  • 54 posts

Posted 09 November 2006 - 09:10 PM

Hi Boki,

this works. However, when using an older version of your components (one or two months) the PopupList behavior is completely different: There's always a highlighted item in the list even if you're leaving the control (in this case the last highlighted item stays highlighted) and the reported bug does not appear. With the latest version there's some kind of hover behavior that makes it possible to not have a highlighted item in the list.

This bug seems to be a regression introduced in one of the last updates.

Cheers,
Markus
It compiles, ship it!

#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 09 November 2006 - 09:26 PM

Hello Markus,

I hope that now in new release, all will be fine.

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#5 Markus

Markus
  • Members
  • 54 posts

Posted 09 November 2006 - 09:58 PM

Hi Boki,

QUOTE (Boki (Berg) @ Nov 9 2006, 09:26 PM) <{POST_SNAPBACK}>
I hope that now in new release, all will be fine.


Well, I bet it won't be fine unless you're going to change something.

Cheers,
Markus
It compiles, ship it!




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users