Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi 6 TListBox OnMeasureItem() and OnDrawItem() never called for lbOwnerDrawVariable() list box

I have a Delphi 6 app with a TListBox control set to lbOwnerDrawVariable. At run-time I add a single string to the list box. I have event handlers for OnMeasureItem() and OnDrawItem() and I set breakpoints on the very first line of code in each event handler. However neither of them are ever called. Not once. Not even if I make an Explicit Refresh or Repaint call on the list box.

This is really basic stuff so what is it that I am doing wrong that could inhibit the calling of those event handlers and subsequently disrupting my owner draw code? The single string does show in the list box properly. I threw in an OnClick() event handler just to see if it worked and did.

like image 591
Robert Oschler Avatar asked Jan 18 '23 01:01

Robert Oschler


1 Answers

The OnMeasureItem and OnDrawItem events are (indirectly) triggered in response to the WM_MEASUREITEM and WM_DRAWITEM messages from Windows. Make sure you do not have any message handlers in your app that are filtering out that message, or the VCL's internal CN_MEASUREITEM and CN_DRAWITEM messages.

like image 197
Remy Lebeau Avatar answered Feb 01 '23 23:02

Remy Lebeau