Images in TColumn

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #34659
    Pedro-Juan
    Participant

    Hello.

    Somebody knows how to obtain those triangles that appear in the heads of the TColumn in a Grid to indicate the arrangement?

    I have obtained some images, but he appears bad (BMP). I have turned them to png, but he appears bad.

    I have tried also it with images of arrow up/down of 16×16, but it is very great (superior and inferior of the head arrive until the edge).

    I have reduced them with a tool of images, but appears bad again.

    When it does not appears bad, they are not transparent…

    D7.

    Thank you very much and a greeting.

    #46176
    Support
    Keymaster

    Hello

    You mean arrows in the TsDBGrid component?

    DrawColorArrow procedure used there, you can see an example of using in the acDBGrid.pas file.

    Or maybe I not quite understand you?

    #46190
    Pedro-Juan
    Participant
    'Support' wrote:

    Hello

    You mean arrows in the TsDBGrid component?

    DrawColorArrow procedure used there, you can see an example of using in the acDBGrid.pas file.

    Or maybe I not quite understand you?

    Hello

    Yes, I mean arrows in the TsDBGrid component.

    DownArrow.png

    UpArrow.png

    Both images are from a sAlphaImageList and both are .png. (16×16)

    D7 Last version of Beta AC 7.45

    How can I do transparent it? I have tried with many images and always the same.

    Thanks.

    #46197
    HeDiBo
    Participant
    'Pedro-Juan' wrote:

    How can I do transparent it? I have tried with many images and always the same.

    I believe the background should be Fuchsia (hex FF00FF). I use this picture in my application:

    [attachment=4983:ICON32Fuchsia.bmp]

    That comes out transparent.

    Hope it helped.

    #46198
    Pedro-Juan
    Participant
    'HeDiBo' wrote:

    I believe the background should be Fuchsia (hex FF00FF). I use this picture in my application:

    [attachment=4983:ICON32Fuchsia.bmp]

    That comes out transparent.

    Hope it helped.

    Hello.

    Some of which I have used previously also were fuchsia in background, and they were not transparent.

    I will continue trying…

    Thanks for you interest

    #46206
    Support
    Keymaster

    Pedro-Juan, can you provide an example? How you draw this arrow?

    #46223
    Pedro-Juan
    Participant
    'Support' wrote:

    Pedro-Juan, can you provide an example? How you draw this arrow?

    Yes, here

    TestImageColumn

    Thanks.

    #46269
    Support
    Keymaster

    Thank you.

    I have changed your code, look it please [

    Code:
    procedure TFMain.sDBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
    DataCol: Integer; Column: TColumn; State: TGridDrawState);

    var
    Png : TPNGGraphic;
    Ndx : integer;

    function GetColsWidth: Integer;
    var I: Integer;
    begin
    Result := 0;
    for I := 0 to Column.Index do begin
    Result := Result + TDBGrid(Sender).Columns.Items.Width;
    end;
    Result := Result + 10 + (Column.Index);
    end;

    begin
    with TDBGrid(Sender) do begin
    if Column.Index = nColumn then begin
    Png := TPNGGraphic.Create;
    try
    Ndx := integer(lDesc);
    DataModule1.sAlphaImageList.Items[Ndx].ImgData.Seek(0, 0);
    Png.LoadFromStream(DataModule1.sAlphaImageList.Items[Ndx].ImgData);
    if (RowHeights[0] < Png.Height + 4) then RowHeights[0] := (Png.Height + 4);
    Canvas.Draw((GetColsWidth – Png.Width),(RowHeights[0] – Png.Height) div 2, Png);
    finally
    Png.Free;
    end;
    end
    else DefaultDrawColumnCell(Rect,DataCol,Column,State);
    end;
    end;

    #46270
    Support
    Keymaster
    'Support' wrote:

    Thank you.

    I have changed your code, look it please [

    Code:
    procedure TFMain.sDBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
    DataCol: Integer; Column: TColumn; State: TGridDrawState);

    var
    Png : TPNGGraphic;
    Ndx : integer;

    function GetColsWidth: Integer;
    var I: Integer;
    begin
    Result := 0;
    for I := 0 to Column.Index do begin
    Result := Result + TDBGrid(Sender).Columns.Items.Width;
    end;
    Result := Result + 10 + (Column.Index);
    end;

    begin
    with TDBGrid(Sender) do begin
    if Column.Index = nColumn then begin
    Png := TPNGGraphic.Create;
    try
    Ndx := integer(lDesc);
    DataModule1.sAlphaImageList.Items[Ndx].ImgData.Seek(0, 0);
    Png.LoadFromStream(DataModule1.sAlphaImageList.Items[Ndx].ImgData);
    if (RowHeights[0] < Png.Height + 4) then RowHeights[0] := (Png.Height + 4);
    Canvas.Draw((GetColsWidth – Png.Width),(RowHeights[0] – Png.Height) div 2, Png);
    finally
    Png.Free;
    end;
    end
    else DefaultDrawColumnCell(Rect,DataCol,Column,State);
    end;
    end;

    TBitmap can't draw a Png with transaprency, you should use TPNGGraphic here.

    #46276
    Pedro-Juan
    Participant

    Hi.

    Now works OK.

    Thank you very much and a greeting.

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.