TIP: Click on subject to list as thread! ANSI
echo: delphi
to: SIMON HUGGINS
from: MARTIN MAAT
date: 1997-05-10 10:19:00
subject: Owner draw listboxes

Hallo Simon
 SH>> I have managed to create code which deals with putting items 
 SH>> wider than the list box onto two lines but not yet managed to get 
 SH>> this working for more than that. i.e. to recognise how many then 
 SH>> loop through for each one.
 MM> What is your problem exactly?
 SH> Well, I've got long lines of text and I'm trying to find a way of
 SH> displaying them in a listbox. I have worked out a clumsy way of 
 SH> doing it. Find the first word by checking for spaces, grab it, 
 SH> change the spaces to asterisks * (so that I can use pos to check 
 SH> for the next space) 
You can do that without changing the spaces you already found. Just add the 
returned value plus 1 to the working variable holding the pointer of the 
string to be searched and call pos again.
 SH> and see if the temporary line plus this new word exceeds the 
 SH> boundary. Repeat until it does then do this a second time.
Stop this immediately and check out the DrawTextEx API function! :-) Notice 
the DT_WORDBREAK option. It returns the height needed in pixels. Call this 
function once in MeasureItem with DT_CALCRECT and assign the result to 
Height. Then in DrawItem, use it to display your text.
 SH> I can't seem to access height in OnDrawItem
Luckily, you don't need it there, for you did all necessary preparations in 
MeasureItem. In DrawItem, you just draw till you're done, knowing there's 
just enough height for you.
Groeten, Martin.
--- FMail/386 1.02
---------------
* Origin: -=[ E-mail: m_maat@knoware.nl .......... ]=- (2:286/420.1)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.