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

Вниз

Фокус ListView   Найти похожие ветки 

 
Илья_С   (2007-09-25 13:54) [0]

Уважаемые мастера.
Скажите, можно ли вызвав какое-нибудь модальное окно
на ListView - ListView сохранял фокус последней выделенной строки,
а не исчезал. Как, например, в StringGrid.
Спасибо.


 
Dib@zol ©   (2007-09-25 14:06) [1]

Пиши обработчик сообщения WM_KILLFOCUS, в нем запоминай в ЛистВиев1.Таг индекс выделенной строки, затем в обраьотчике WM_SETFOCUS (OnFocus кажется) проставляй Selected равным Tag.


 
Германн ©   (2007-09-25 14:21) [2]


> Илья_С   (25.09.07 13:54)

HideSelection:=False;


 
Илья_С   (2007-09-25 14:26) [3]

HideSelection не помогает.
Выделенной строки с цветом не получишь.


 
Palladin ©   (2007-09-25 14:36) [4]

в каком плане ты ее получить хочешь?


 
Илья_С   (2007-09-25 14:47) [5]

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 закрашивается.
Хочется только последнюю выделенную строку при потере фокуса.



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

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

Наверх




Память: 0.49 MB
Время: 0.016 c
2-1195311260
Dru095
2007-11-17 17:54
2007.12.16
как удалить файл с определенной датой создания


2-1195620594
Klopan
2007-11-21 07:49
2007.12.16
Кнопка скрола в меню


2-1195592839
miwgun
2007-11-21 00:07
2007.12.16
пробудился интерес к scrollbar


2-1195344069
ЗДЕСЬ_ПОМОЩИ_НЕТ
2007-11-18 03:01
2007.12.16
И НЕ ИЩИ ЕЁ ЗДЕСЬ!!!!!


10-1141661852
Alex Kryuchkov
2006-03-06 19:17
2007.12.16
СОМ через SSL-соединение