Components for Delphi and C++ Builder.

Go to Russian forum
Go to EhLib.com
It is currently 12 Jul 2024, 21:27

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: 18 Oct 2023, 20:06 
Offline

Joined: 13 Jul 2019, 19:08
Posts: 92
to solve the "StyleElements" problem I did the following

Could you leave this fixed so I don't need to change it when I update the version.

Code:
procedure TCustomGridEh.WndProc(var Message: TMessage);
{$IFDEF FPC_CROSSP}
begin
  inherited WndProc(Message);
end;
{$ELSE}
var
  OldControlStyle: TControlStyle;
  AWMMouse: TWMMouse;
begin
  OldControlStyle := ControlStyle;
  case Message.Msg of
    WM_LBUTTONDBLCLK, WM_RBUTTONDBLCLK, WM_MBUTTONDBLCLK:
    begin
      AWMMouse.Msg := Message.Msg;
      AWMMouse.Keys := LongInt(Message.wParam);
      AWMMouse.XPos := Message.lParamlo;
      AWMMouse.YPos := Message.lParamhi;
      if not WMCheckCanSendDoubleClicks(AWMMouse) then
        ControlStyle := ControlStyle - [csDoubleClicks];
    end;
  end;
Try
  try
    inherited WndProc(Message);
  finally
    if OldControlStyle <> ControlStyle then
      ControlStyle := OldControlStyle;
  end;
Except  // mute
End;
end;
{$ENDIF}


Did anything else change the way Footer Hints are created ?
You could test with TMS Hint that creates HTML-style hints
https://www.tmssoftware.com/site/tmsfncuipack.asp#downloads

Code:
procedure TCustomDBGridEh.CMHintShow(var Message: TCMHintShow);
var
  Cell: TGridCoord;
  Column: TColumnEh;
  TextWidth, DataRight, RightIndent, EmptyVar: Integer;
  s: String;
  ARect: TRect;
  WordWrap: Boolean;
  TextWider: Boolean;
  AAlignment: TAlignment;
  TopIndent: Integer;
  IsDataToolTips: Boolean;
  Footer: TColumnFooterEh;
{$IFDEF CIL}
  AHintInfo: THintInfo;
{$ENDIF}
  Params: TDBGridEhDataHintParams;
  Processed: Boolean;
  InCellCursorPos: TPoint;
  DataRect: TRect;
  FBackground: TColor;
  IsTitleTypeCell: Boolean;
  NewHeight: Integer;
  FilterButtonWidth: Integer;
  XFrameOffs: Integer;
  FooterNode: TGroupDataTreeNodeEh;
  FooterColumnItem: TGridDataGroupFooterColumnItemEh;
  VarValue: Variant;
  AreaRow: Integer;
  phi: PHintInfo;
  GroupRow: Boolean;

  function GetToolTipsColumnText(Column: TColumnEh): String;
  var KeyIndex: Integer;
  begin
    Result := '';
    if Column.GetBarType in [ctKeyImageList, ctCheckboxes] then
    begin
      if Column.GetBarType = ctKeyImageList
        then KeyIndex := Column.KeyList.IndexOf(Column.Field.Text)
      else KeyIndex := Integer(Column.CheckboxState);
      if (KeyIndex > -1) and (KeyIndex < Column.PickList.Count)
        then Result := Column.PickList.Strings[KeyIndex];
    end
    else if Column.Field <> nil
      then Result := Column.DisplayText;
  end;

begin
  inherited;
  Processed := False;
  if Message.Result = 0 then
  begin
{$IFDEF CIL}
    if Message.OriginalMessage.LParam = 0 then Exit;
    AHintInfo := Message.HintInfo;
{$ENDIF}
    IsDataToolTips := False;
    Cell := MouseCoord(HitTest.X, HitTest.Y);
    if (Cell.X < IndicatorOffset) or (Cell.Y < 0) then Exit;
    Column := Columns[RawToDataColumn(Cell.X)];

    if (Cell.Y = GetTitleRows - 1) and (Column.Title.Hint <> '') then
    begin

{$IFDEF CIL}
      AHintInfo.HintStr := GetShortHint(Columns[RawToDataColumn(Cell.X)].Title.Hint);
      AHintInfo.CursorRect := CellRect(Cell.X, Cell.Y);
      Message.HintInfo := AHintInfo;
{$ELSE}
      Message.HintInfo^.HintStr := GetShortHint(Columns[RawToDataColumn(Cell.X)].Title.Hint);
      Message.HintInfo^.CursorRect := CellRect(Cell.X, Cell.Y);
{$ENDIF}
    end
    else if (Mouse.Capture = 0) and (GetKeyState(VK_CONTROL) >= 0) then
    begin
      ARect := CellRect(Cell.X, Cell.Y);
      if RowPanel.Active then
      begin
        if Cell.Y = GetTitleRows - 1
          then IsTitleTypeCell := True
          else IsTitleTypeCell := False;
        Column := GetColumnInRowPanelAtPos(
          Point(HitTest.X-ARect.Left+HorzAxis.RolStartVisPos,
                HitTest.Y-ARect.Top), IsTitleTypeCell);
        if Column = nil then Exit;
        if IsTitleTypeCell then
          DataRect := Rect(Column.FRowPlacement.Left, Column.FRowPlacement.Top,
            Column.FRowPlacement.Left+Column.FRowPlacement.Width,
            Column.FRowPlacement.Top+Column.FRowPlacement.Height)
        else
          DataRect := Rect(Column.FRowPlacement.DataCellLeft, Column.FRowPlacement.Top,
            Column.FRowPlacement.DataCellLeft+Column.FRowPlacement.DataCellWidth,
            Column.FRowPlacement.Top+Column.FRowPlacement.Height);
        OffsetRect(DataRect, ARect.Left, ARect.Top);
        OffsetRect(DataRect, -HorzAxis.RolStartVisPos, 0);
        ARect := DataRect;
      end;
      InCellCursorPos := Point(HitTest.X-ARect.TopLeft.X, HitTest.Y-ARect.TopLeft.Y);
      WordWrap := False;
      AAlignment := taLeftJustify;
      if FHintFont = nil then
        FHintFont := TFont.Create;
      if Column.UseRightToLeftAlignment then
      begin
        OffsetRect(ARect, ClientWidth - ARect.Right - ARect.Left, 0);
      end;
      DataRight := ARect.Left + Column.Width;
      if (Cell.Y = GetTitleRows - 1) and Column.Title.ToolTips then
      begin
        if Column.Title.Alignment = taCenter then
          XFrameOffs := 0
        else if  (dghFixed3D in OptionsEh) and not (TitleParams.GetActualFillStyle = cfstThemedEh) then
          XFrameOffs := 2
        else
          XFrameOffs := 3;

        Dec(ARect.Right, XFrameOffs);
        Dec(DataRight, XFrameOffs);

        Inc(ARect.Left, Column.Title.ImageAreaWidth);

        if Column.Title.GetSortMarkingWidth > 2 then
        begin
          Dec(ARect.Right, Column.Title.GetSortMarkingWidth - 2);
          Dec(DataRight, Column.Title.GetSortMarkingWidth - 2);
        end;
        if STFilter.Visible and
           Column.STFilter.Visible and
           (STFilter.Location = stflInTitleFilterEh) then
        begin
          if Flat then
          begin
            FilterButtonWidth := FlatButtonWidth;
            if not ThemesEnabled then
              Inc(FilterButtonWidth);
          end else
            FilterButtonWidth := GetSystemMetrics(SM_CXVSCROLL);

          if (ARect.Right - ARect.Left) div 2 < FilterButtonWidth then
            FilterButtonWidth := (ARect.Right - ARect.Left) div 2;

          Dec(ARect.Right, FilterButtonWidth);
          Dec(DataRight, FilterButtonWidth);
        end;

        if HitTest.X > ARect.Right then
          s := ''
        else if IsUseMultiTitle = True then
        begin
          s := FLeafFieldArr[RawToDataColumn(Cell.X)].FLeaf.Text;
          ARect.Top := ARect.Bottom - FLeafFieldArr[Cell.X - IndicatorOffset].FLeaf.Height + 1;
          if HitTest.Y < ARect.Top then Exit;
        end
        else
          s := Column.Title.Caption;
        WordWrap := (IsUseMultiTitle = True) or (TitleHeight <> 0) or (TitleLines <> 0);
        AAlignment := Column.Title.Alignment;
        FHintFont.Assign(Column.Title.Font);
        Canvas.Font.Assign(FHintFont);
        if Column.Title.Orientation = tohVertical then
        begin
          WordWrap := False;
          OverturnUpRect(ARect);
        end;
      end else if (Cell.Y >= TopDataOffset) and
        (Cell.Y < DataRowCount + TopDataOffset) and
        DataLink.Active then
      begin
        InstantReadRecordEnter(Cell.Y - TopDataOffset);
        Params := nil;
        try
          GroupRow := DataGrouping.IsGroupingWorks and
                     (DataGrouping.GroupDataTree.FlatVisibleCount > 0) and
                     (InstantReadCurDataNode.NodeType in [dntDataGroupEh, dntDataGroupFooterEh]);
          if not GroupRow then
          begin

            IsDataToolTips := True;
            if RowDetailPanel.Visible and (Row = Cell.Y) then
            begin
              NewHeight := CalcRowDataRowHeight(Cell.Y-TopDataOffset);
              if ARect.Bottom - ARect.Top > NewHeight then
                ARect.Bottom := ARect.Top + NewHeight;
            end;

            Params := TDBGridEhDataHintParams.Create;

            Processed := False;
      {$IFDEF CIL}
            w ith AHintInfo do
      {$ELSE}
            phi := Message.HintInfo;
      {$ENDIF}
            Params.HintPos := ScreenToClient(phi.HintPos);
            Params.HintMaxWidth := phi.HintMaxWidth;
            Params.HintColor := phi.HintColor;
            Params.ReshowTimeout := phi.ReshowTimeout;
            Params.HideTimeout := phi.HideTimeout;
            Params.HintStr := Hint;
            Params.CursorRect := ARect;
            Params.HintFont := FHintFont;
            Params.HintFont.Assign(Screen.HintFont);

            if Assigned(FOnDataHintShow) then
              OnDataHintShow(Self, HitTest, Cell, InCellCursorPos, Column, Params, Processed);
            if not Processed and Assigned(Column) and Assigned(Column.FOnDataHintShow) then
              Column.OnDataHintShow(Self, HitTest, Cell, InCellCursorPos, Column, Params, Processed);

            if not Processed then
              DefaultFillDataHintShowInfo(HitTest, Cell, Column, Params);

      {$IFDEF CIL}
            w ith AHintInfo do
      {$ELSE}
      {$ENDIF}
            phi.CursorRect := Params.CursorRect;
            phi.HintPos := ClientToScreen(Params.HintPos);
            phi.HintMaxWidth := Params.HintMaxWidth;
            phi.HintColor := Params.HintColor;
            phi.ReshowTimeout := Params.ReshowTimeout;
            phi.HideTimeout := Params.HideTimeout;
            phi.HintStr := Params.HintStr;
            //phi.HintData := FGridHintCustomData;
            Processed := True;

          end;
        finally
          InstantReadRecordLeave;
          FreeAndNil(Params);
        end;
      end
      else if (FullFooterRowCount > 0) and
              (Cell.Y > RowCount - 1) then
      begin
        AreaRow := Cell.Y - RowCount;
        if DataGrouping.Active and (AreaRow < DataGrouping.Footers.VisibleItemsCount) then
        begin
          FooterNode := DataGrouping.GroupDataTree.Root;
          FooterColumnItem := FooterNode.FooterItems[AreaRow].DataGroupFooter.ColumnItems[Column.Index];
          Canvas.Brush.Color := CheckSysColor(FooterColumnItem.Color);
          Canvas.Font := FooterColumnItem.Font;
          VarValue := Null;
          if DataLink.Active then
            VarValue := FooterNode.FooterItems[AreaRow].FooterValues[Column.Index];
          S := FooterColumnItem.ConvertToDisplayText(VarValue);
          WordWrap := False;
          AAlignment := FooterColumnItem.Alignment;
          FBackground :=FooterColumnItem.Color;
        end else
        begin
          Footer := Column.ColumnUsedFooter(Cell.Y - RowCount - DataGrouping.Footers.VisibleItemsCount);

        //New code
          if Column.DynProps.FindDynVar('FooterHint') <> nil then begin   // Luciano
            phi := Message.HintInfo;
            phi.CursorRect := ARect;
            phi.HintStr := Column.DynProps['FooterHint'].AsString;
            Processed := True;
          end;


          if not Footer.ToolTips then Exit;

          FHintFont.Assign(Footer.Font);
          Canvas.Font.Assign(FHintFont);
          WordWrap := Footer.WordWrap;
          AAlignment := Footer.Alignment;
          S := GetFooterValue(Footer, Column);
          FBackground := Footer.Color;
          GetFooterParams(RawToDataColumn(Cell.X), Cell.Y - RowCount, Column,
            Canvas.Font, FBackground, AAlignment, [], S);
        end;
      end else
        Exit;

      phi := Message.HintInfo;
      if not Processed then
      begin

        if WordWrap then RightIndent := 2 else RightIndent := 0;
        if IsDataToolTips and (Column.GetBarType in [ctKeyImageList, ctCheckboxes]) then
          TextWider := True
          {$IFDEF FPC}
        else
          TextWider := CheckHintTextRect(0,
          {$ELSE}
        else
          TextWider := CheckHintTextRect(Self.DrawTextBiDiModeFlagsReadingOnly,
          {$ENDIF}
                              Self.Canvas, RightIndent, FInterlinear,
                              s, ARect, WordWrap, not WordWrap, TextWidth, EmptyVar, taLeftJustify, False);

        if Flat
          then TopIndent := 2
          else TopIndent := 1;

  {$IFDEF CIL}
  {$ELSE}
  {$ENDIF}
        if TextWider or ((AAlignment = taRightJustify) and (DataRight - 2 > ARect.Right)) then
        begin
          phi.HintStr := s;
          phi.CursorRect := ARect;
          case AAlignment of
            taLeftJustify:
              phi.HintPos := Point(ARect.Left - 1, ARect.Top - TopIndent);
            taRightJustify:
              phi.HintPos := Point(DataRight + 1 - TextWidth - 7, ARect.Top - TopIndent);
            taCenter:
              phi.HintPos := Point(DataRight + 1 - TextWidth - 6 +
                TextWidth div 2 - (DataRight - ARect.Left - 4) div 2, ARect.Top - TopIndent);
          end;
          if Column.UseRightToLeftAlignment then
            phi.HintPos.X := ClientWidth - phi.HintPos.X;
          phi.HintPos := ClientToScreen(phi.HintPos);
          if WordWrap then
            phi.HintMaxWidth := ARect.Right - ARect.Left - 4;
        end
        else
          phi.HintStr := '';
      end;
  {$IFDEF CIL}
  {$ELSE}
  {$ENDIF}
  //    phi.HintWindowClass := THintWindowEh;   Luciano
  //    phi.HintData := FHintFont;
    end;
{$IFDEF CIL}
    Message.HintInfo := AHintInfo;
{$ENDIF}
  end;
end;


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group