Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2006.02.19;
Скачать: CL | DM;

Вниз

Можно ли в ListBox узнать по какой букве в строке был клик   Найти похожие ветки 

 
ListBox   (2006-02-04 00:26) [0]

или по какому слову в строке?


 
vidiv ©   (2006-02-04 12:24) [1]

Без изврата - врядли.


 
vidiv ©   (2006-02-04 12:56) [2]

Вот пример изврата:

procedure TForm1.ListBox1MouseUp(Sender: TObject; Button: TMouseButton;
 Shift: TShiftState; X, Y: Integer);
var ir: TRect;
   i,j:integer;
   s:string;
   ListBox:TListBox;
begin
 ListBox := Sender as TListBox;
 j := ListBox.ItemAtPos(Point(X, Y), True);
 if j>=0 then begin
   ListBox.Canvas.Font := ListBox.Font;
   ir := ListBox.ItemRect(j);
   x := x - ir.Left - 2;
   s := ListBox.Items[j];
   j := 0;

   for i:=1 to length(s) do begin
     if ListBox.Canvas.TextWidth(copy(s, 1, i)) > x then begin
         j := i;
         break
       end;
   end;
   if j > 0 then begin
     showmessage("Вы кликнули по букве номер "+inttostr(j));
   end else begin
     showmessage("Вы не попали по букве");
   end;
 end;
end;


 
Gero ©   (2006-02-04 12:59) [3]

Можно, но в общем случае довольно сложно.


 
ListBox   (2006-02-04 20:35) [4]

Спасибо!



Страницы: 1 вся ветка

Текущий архив: 2006.02.19;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.042 c
2-1138550619
13
2006-01-29 19:03
2006.02.19
ActionMainMenuBar


15-1138388817
cyborg
2006-01-27 22:06
2006.02.19
Есть оказывается там люди


15-1138248576
вурдалак
2006-01-26 07:09
2006.02.19
RAID0+1 дома...


2-1138733532
ViktorZ
2006-01-31 21:52
2006.02.19
Работа с БД.


2-1138916110
san6
2006-02-03 00:35
2006.02.19
Может подскажет кто-нибудь?