![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Фокус ListView [D6]
Илья_С © (2007-09-25 13:54:00)Уважаемые мастера.
Скажите, можно ли вызвав какое-нибудь модальное окно
на ListView - ListView сохранял фокус последней выделенной строки,
а не исчезал. Как, например, в StringGrid.
Спасибо.
Илья_С (2007-09-25 14:47:00) [1]procedure TMain_f.DrawListView(const AListView:TListView; Item: TListItem;
SubItem: Integer; State: TCustomDrawState; Tag:Integer; Image1,Image2:TImage);
var
dbitmap:TBitmap;
OldBkMode:Integer;
Rect:TRect;
s:string;
format:Integer;
begin
format:=0;
AListView.Canvas.Font.Style:=AListView.Canvas.Font.Style-[fsBold];
if cdsSelected in State then
begin
AListView.Canvas.Font.Color:=clHighLightText;
end
else
begin
if Item.SubItems[2] = '0' then
begin
AListView.Canvas.Brush.Color:=clinfoBK;
if Item.Caption <> '1' then
AListView.Canvas.Font.Color:=clRed
else
AListView.Canvas.Font.Color:=clWindow;
end
else
AListView.Canvas.Font.Color:=$00000000;
end;
if Item.Caption = '1' then
AListView.Canvas.Brush.Color:=clRed;
{ else
if Item.Caption = '3' then
AListView.Canvas.Brush.Color:=clLime;
}
if (SubItem = 1) then
begin
DBitmap:=TBitmap.Create;
if Item.Caption = '0' then
begin
DBitmap.Assign(Image1.Picture.Bitmap);
DBitmap.TransparentColor:=$00000000;
DBitmap.Transparent:=True;
end
else
if Item.Caption = '1' then
begin
DBitmap.Assign(Image2.Picture.Bitmap);
DBitmap.TransparentColor:=$00000000;
DBitmap.Transparent:=True;
end;
AListView.Canvas.Draw(Item.Left+8,Item.Top-1,DBitmap);
DBitmap.Free;
end else
if (SubItem > 1) then
begin
OldBkMode := SetBkMode(AListView.Canvas.Handle, TRANSPARENT);
Rect.Left := LVIR_BOUNDS;
Rect.Top := (SubItem);
SendMessage(AListView.Handle, LVM_GETSUBITEMRECT, Item.Index, LParam(@Rect));
Rect.Left:=Rect.Left+2;
Rect.Right:=Rect.Right-2;
s:=Item.SubItems[SubItem-1];
{ if cdsFocused in State then
begin
AListView.Canvas.Brush.Color:= clLime;
AListView.Canvas.FillRect(Item.DisplayRect(drBounds));
AListView.Canvas.TextOut(Rect.Left+2,Rect.Top+2,s);
end else
} if Item.Caption <> '1' then
if cdsSelected in State then
begin
AListView.Canvas.Brush.Color:= clHighLight;
// AListView.Canvas.FillRect(Item.DisplayRect(drBounds));
AListView.Canvas.FillRect(Rect);
AListView.Canvas.TextOut(Rect.Left+2,Rect.Top+2,s);
end
else
if (SubItem = 7) and (s = 'Ж') then
AListView.Canvas.Brush.Color:=RGB(246,221,140) //$00FFB7FF //$000080FF //$0040C5F7
else
if (SubItem = 7) and (s = 'М') then
AListView.Canvas.Brush.Color:=clYellow;
AListView.Canvas.FillRect(Rect);
if AListView.Columns[SubItem].Tag = 0 then
format:=DT_LEFT
else
if AListView.Columns[SubItem].Tag = 1 then
format:=DT_CENTER
else
if AListView.Columns[SubItem].Tag = 2 then
format:=DT_RIGHT;
DrawTextEx(AListView.Canvas.Handle, PChar(s), Length(s), Rect, DT_WORD_ELLIPSIS or format, nil);
SetBkMode(AListView.Canvas.Handle, OldBkMode);
end;
with AListView.Canvas.Font do
if Assigned(OnChange) then OnChange(AListView.Canvas.Font);
end;
Вот код: HideSelection = False - все clHighLight закрашивается.
Хочется только последнюю выделенную строку при потере фокуса.
Palladin (2007-09-25 14:36:00) [2]в каком плане ты ее получить хочешь?
Илья_С (2007-09-25 14:26:00) [3]HideSelection не помогает.
Выделенной строки с цветом не получишь.
Германн (2007-09-25 14:21:00) [4]
> Илья_С (25.09.07 13:54)
HideSelection:=False;
Dib@zol (2007-09-25 14:06:00) [5]Пиши обработчик сообщения WM_KILLFOCUS, в нем запоминай в ЛистВиев1.Таг индекс выделенной строки, затем в обраьотчике WM_SETFOCUS (OnFocus кажется) проставляй Selected равным Tag.