Board index » delphi » TCustomListBox, horizontal scroll???
jrweb...@socs.uts.EDU.AU (James Richard Webster)
![]() Delphi Developer |
Fri, 13 Feb 1998 03:00:00 GMT
|
jrweb...@socs.uts.EDU.AU (James Richard Webster)
![]() Delphi Developer |
Fri, 13 Feb 1998 03:00:00 GMT
TCustomListBox, horizontal scroll???
G'day all,
Has anyone out there been able to make some derivative of TCustomListBox Later, -- |
Patrick Shiel
![]() Delphi Developer |
Sat, 14 Feb 1998 03:00:00 GMT
Re:TCustomListBox, horizontal scroll???jrweb...@socs.uts.EDU.AU (James Richard Webster) wrote: Quote>G'day all, you can use a regular TListBox. Somewhere in your code after the list box is created, send the following message: SendMessage(MyList.handle,LB_SETHORIZONTALEXTENT,widest,0); where widest is a WORD var in pixels. The listbox needs to be created |
Ruud van der H
![]() Delphi Developer |
Sun, 15 Feb 1998 03:00:00 GMT
Re:TCustomListBox, horizontal scroll???Quotepshie...@csn.net (Patrick Shields) wrote: got a solution. However, I have no idea on how to create the lsitbox with WS_HSCROLL. Do I need to do all thing on my self. Do you have a code fragment for doing this stuff. Thanks. -- |
Patrick Shiel
![]() Delphi Developer |
Sun, 15 Feb 1998 03:00:00 GMT
Re:TCustomListBox, horizontal scroll???rvd...@ect.nl (Ruud van der Ham) wrote: Quote>pshie...@csn.net (Patrick Shields) wrote: already has this attribute. I include the WS_HSCROLL info. in case you were creating your own list box window. Quote>I have the same question (also posted already here) and am glad you with the WS_HSCROLL attribute. In the case where I used this, I have a resizeable form (and FormResize gets called at least once during form creation) so I included the following code in the FormResize event, you could call it other places too: { Form Template - Source and Destination Choices Lists } interface uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, Buttons, type procedure SetCols(howmany:integer); var implementation {$R *.DFM} procedure TDualListDlg.FormCreate(Sender: TObject); begin widest:=0; end; procedure TDualListDlg.FormResize(Sender: TObject); SendMessage(SrcList.handle,LB_SETHORIZONTALEXTENT,widest,0); {gets called after srclist is populated by routine calling this form end. I call this from something like this: Procedure CallLists; begin |
James Richard Webst
![]() Delphi Developer |
Fri, 20 Feb 1998 03:00:00 GMT
Re:TCustomListBox, horizontal scroll???rvd...@ect.nl (Ruud van der Ham) writes: Quote>pshie...@csn.net (Patrick Shields) wrote: tried the SendMessage solution suggested by Patrick, (I saw it in the VB knowledgebase), but it didn't work! I tried it again, after his reply, and this time it did work! The difference? My second attempt involved a TListBox, a TEdit, and TButton on a form. When the user clicked the button, the event handler did this (I think :) ListBox1.Add(Edit1.Text); Now this works (I tried it :), but my original problem was getting a CUSTOM Any suggestions :) ??? Later, -- |
Patrick Shiel
![]() Delphi Developer |
Fri, 20 Feb 1998 03:00:00 GMT
Re:TCustomListBox, horizontal scroll???jrweb...@socs.uts.EDU.AU (James Richard Webster) wrote: Quote>rvd...@ect.nl (Ruud van der Ham) writes: components (VCL) use SendMessage to themselves all the time to do Windows API things. The main thing is that SendMessages(HWND....) always needs a valid window handle which it doesn't have when it is first created, but does by the time your drawItem method is called. Another thing is that you may need to force a window repaint to see the scroll bar as the SendMessage won't take effect during the DrawItem method (of course you need to be careful how you set up the repaint or you may get an endless loop) . Quote>Any suggestions :) ??? requirement, the VCL source for TCustomListBox.CreateParams includes this line: Style := Style or (WS_HSCROLL or LBS_HASSTRINGS or so you should be alright unless your custom control somehow overrides Hope this helps. |