#1 2014-03-11 15:24:39

tech
Member
Registered: 2014-01-13
Posts: 110

Retrieve the drawGrid associated to a TSQLRecord

Hi,

I'm creating the UI at run-time with the same code on the main demo with TSQLRibbon and I want to retrieve the draw grid associated to a TSQLRecord sub-class to have the possibility to draw some incoherent records with red color.
What I need is exactly the opposite of this function :

class function From(Grid: TDrawGrid): TSQLTableToGrid;

How can'I do that ?

Thanks,

Offline

#2 2014-03-11 20:17:37

tech
Member
Registered: 2014-01-13
Posts: 110

Re: Retrieve the drawGrid associated to a TSQLRecord

I found TSQLRibbonTab.TableToGrid.DrawGrid and I'll use the mark option to draw incoherent records with red color.

Thanks,

Offline

#3 2014-03-14 09:39:38

tech
Member
Registered: 2014-01-13
Posts: 110

Re: Retrieve the drawGrid associated to a TSQLRecord

I've marked the incoherent records then modify the NewDrawCellBackground to color marked when MARKEDROWSCOLORED is defined

{$define MARKEDROWSCOLORED}
// if defined, all Marked[] rows are highligted with a different background color

procedure NewDrawCellBackground(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState;
  {$ifdef USETMSPACK} TabAppearance: TTabAppearance;{$endif} Marked: boolean);
var Grid: TDrawGrid absolute Sender;
begin
  if not Sender.InheritsFrom(TDrawGrid) then
    exit;
{$ifdef USETMSPACK}
  if TabAppearance<>nil then
  with TabAppearance, Grid.Canvas do begin
    Font := Grid.Font;
    if (gdFixed in State) then begin
      Brush.Color := BackGround.Color;
      Font.Color := TextColor;
      Pen.Color := ShadowColor;
      inc(Rect.Bottom,1);
      MoveTo(Rect.Right,Rect.Top);
      LineTo(Rect.Right,Rect.Bottom);
    end else
    if Marked then
      if (gdSelected in State) then begin
        Brush.Color := HighLightColorSelected;
        Font.Color := TextColorHot;
      end else
        Brush.Color := HighLightColor else
      if (gdSelected in State) then begin
        Brush.Color := ColorHot;
        Font.Color := TextColorHot;
      end else
        Brush.Color := ColorTo;
{$else}
  with Grid.Canvas do begin
    Font := Grid.Font;
    if gdFixed in State then begin
      Font.Color := clCaptionText;
      Brush.Color := clGradientInactiveCaption;
      Pen.Color := clGrayText;
      inc(Rect.Bottom,1);
      MoveTo(Rect.Right,Rect.Top);
      LineTo(Rect.Right,Rect.Bottom);
    end else
  {$IFDEF MARKEDROWSCOLORED}
    if Marked then
    begin
        Brush.Color := clLime;
        Font.Color := clWindowText;
    end
    else
    if (gdSelected in State) then begin
      Font.Color := clHighlightText;
      Brush.Color := clHighlight;
    end else begin
      Font.Color := clWindowText;
      Brush.Color := clWindow;
    end;
  {$else}
    if (gdSelected in State) then begin
      Font.Color := clHighlightText;
      Brush.Color := clHighlight;
    end else begin
      Font.Color := clWindowText;
      Brush.Color := clWindow;
    end;
  {$ENDIF}
{$endif}
    FillRect(Rect);
  end;
end;

Is it possible to have a global clMarked variable to be able to change it ?

Offline

Board footer

Powered by FluxBB