Robert Covington wrote: > > On Friday, July 25, 2003, at 03:40 PM, Alain Pastor wrote: > >> >> >> Bernie Wylde wrote: >> >>> Dear All, >>> It appears we can create list boxes in a number of different ways. >>> What appears to be the simplest and most straightforward method (to >>> me) is described on page 44 of the manual where it recommends >>> creating an 'ldes' resource with Resorcerer 2.4 or a template in any >>> resource editor. As I'm not about to fork out $256.00 for Resorcerer, >>> can anyone get me started on creating a template in say ResEdit? >>> Alternatively, there's a demo file on the CD, 'simple list in Carbon' >>> which eliminates the need for a resource editor. The problem I have >>> with this method is that a click on the list box doesn't generate a >>> button click event. So, do we instead have to detect mouse clicks and >>> calculate the selected cell from mouse position? >>> Hope I've made this clear. Any help appreciated. >> >> >> Bernie, >> >> maybe that one can help: > > > That's interesting. > > I was going to suggest an embed, but that's beyond my technology. > > How do you get the ID of the list element clicked? It give the > ListboxID for ID each time , which is only natural I suppose, but gives > no element info. > Do you then need to go to a Mouse based approach after the click? > > Robert Bob > > local fn DoDialog > dim as long evnt, id > evnt = dialog( 0 ) > id = dialog( evnt ) > > select evnt > case _wndClose > end > case _btnClick > // where from here? > end select > end fn > You just have to retrieve the list handle and work with the List Manager calls. For example to get the selected text in the list, you could do the following: clear local mode local fn GetSelectedListItemText$( btnID as long ) dim as point cell,dum dim as handle @ listH dim as long @ actualSize Dim As Short @ dataLen Dim As Str255 txt def GetButtonData( btnID, _kControlListBoxPart, ¬ _kControlListBoxListHandleTag, sizeof(listH), listH, actualSize ) long if listH dataLen = 255 dum = fn LGetSelect( _ZTrue, cell, listH ) LGetCell( @txt[1], dataLen, cell, listH ) txt[0] = dataLen end if end fn = txt to get the selected line: clear local mode local fn GetSelectedLine( btnID as long ) dim as point cell,dum dim as handle @ listH dim as long @ actualSize def GetButtonData( btnID, _kControlListBoxPart, ¬ _kControlListBoxListHandleTag, sizeof(listH), listH, actualSize ) long if listH dum = fn LGetSelect( _ZTrue, cell, listH ) end if end fn = cell.v% + 1 Alain