![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Можно ли в ListBox узнать по какой букве в строке был клик
ListBox © (2006-02-04 00:26:00)или по какому слову в строке?
ListBox (2006-02-04 20:35:00) [1]Спасибо!
Gero (2006-02-04 12:59:00) [2]Можно, но в общем случае довольно сложно.
vidiv (2006-02-04 12:56:00) [3]Вот пример изврата:
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;
vidiv (2006-02-04 12:24:00) [4]Без изврата - врядли.