Announcement

Collapse
No announcement yet.

TString Grid Bild hinzufügen...

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • TString Grid Bild hinzufügen...

    Problemdefinition: Übersetzung von Pascal-Code in C++Builder ...
    Aufgabe: Wie kann ich einer Zelle in einem StringGrid ein Bild hinzufügen?

    Da ich kein Pascal-Fuchs bin (+g+), nun meine noch falsche Übersetzung:

    void __fastcall TFrm_NewProject::StringGrid1DrawCell(TObject *Sender,
    int ACol, int ARow, TRect &Rect, TGridDrawState State)
    {
    String *s;

    s = (Sender as TStringGrid)->Cells[Col, Row];

    // Draw ImageList Index in all Rows in Col 1
    if (Col = 1)
    {
    with (Sender as TStringGrid)
    do
    {
    // Clear current cell rect
    Canvas->FillRect(Rect);
    // Draw image index 0 in ImageList1 in the cell
    IL_Register->Draw(Canvas, Rect.Left, Rect.Top, 0);
    // Draw the text in the cell
    Canvas->TextOut(Rect.Left + Image1.Width + 2, Rect.Top, s);
    }
    }
    }
    Hier der Pascal - Code:

    procedure TForm1.StringGrid1DrawCell(Sender: TObject; Col,
    Row: Longint; Rect: TRect; State: TGridDrawState);
    var
    s: string;
    begin
    s := (Sender as TStringGrid).Cells[Col, Row];

    // Draw ImageList Index in all Rows in Col 1
    if Col = 1 then
    with (Sender as TStringGrid) do
    begin
    // Clear current cell rect
    Canvas.FillRect(Rect);
    // Draw image index 0 in ImageList1 in the cell
    ImageList1.Draw(Canvas, Rect.Left, Rect.Top, 0);
    // Draw the text in the cell
    Canvas.TextOut(Rect.Left + Image1.Width + 2, Rect.Top, s);
    end;
    end;

    Das mit dem 'width' ist aufjedenfall falsch und sicher nicht der einzigste Bug :-) Kann da jmd. noch mal kurz vorbeischauen?

    Es kennt sicher jmd. von euch ein wenig C++, nur über die Schlüsselwörter von Pascal finde ich auch nix in dr C++ Hilfe :-(

    Schon mal vielen Dank!

  • #2
    Hier nocheinmal in ordentlicher Form:

    Problemdefinition: Übersetzung von Pascal-Code in C++Builder ...<BR>Aufgabe: Wie kann ich einer Zelle in einem StringGrid ein Bild hinzufügen?<BR>Da ich kein Pascal-Fuchs bin (+g+), nun meine noch falsche Übersetzung:<P><PRE>void __fastcall TFrm_NewProject::StringGrid1DrawCell(TObject *Sender,
    int ACol, int ARow, TRect &Rect, TGridDrawState State)
    {
    String *s;

    s = (Sender as TStringGrid)->Cells[Col, Row];

    // Draw ImageList Index in all Rows in Col 1
    if (Col = 1)
    {
    with (Sender as TStringGrid)
    do
    {
    // Clear current cell rect
    Canvas->FillRect(Rect);
    // Draw image index 0 in ImageList1 in the cell
    IL_Register->Draw(Canvas, Rect.Left, Rect.Top, 0);
    // Draw the text in the cell
    Canvas->TextOut(Rect.Left + Image1.Width + 2, Rect.Top, s);
    }
    }
    }</PRE><P>Hier der Pascal - Code:<P><PRE>procedure TForm1.StringGrid1DrawCell(Sender: TObject; Col,
    Row: Longint; Rect: TRect; State: TGridDrawState);
    var
    s: string;
    begin
    s := (Sender as TStringGrid).Cells[Col, Row];

    // Draw ImageList Index in all Rows in Col 1
    if Col = 1 then
    with (Sender as TStringGrid) do
    begin
    // Clear current cell rect
    Canvas.FillRect(Rect);
    // Draw image index 0 in ImageList1 in the cell
    ImageList1.Draw(Canvas, Rect.Left, Rect.Top, 0);
    // Draw the text in the cell
    Canvas.TextOut(Rect.Left + Image1.Width + 2, Rect.Top, s);
    end;
    end;</PRE><P>Das mit dem 'width' ist aufjedenfall falsch und sicher nicht der einzigste Bug :-) Kann da jmd. noch mal kurz vorbeischauen?
    Es kennt sicher jmd. von euch ein wenig C++, nur über die Schlüsselwörter von Pascal finde ich auch nix in dr C++ Hilfe :-(
    Schon mal vielen Dank

    Comment


    • #3
      Hat denn hier niemand eine Idee, wie man den obigen Code in C++ Builder Code transformieren kann?

      Hier nocheinmal der Pascal-Code:

      <PRE>
      procedure TForm1.StringGrid1DrawCell(Sender: TObject; Col,
      Row: Longint; Rect: TRect; State: TGridDrawState);
      var
      s: string;
      begin
      s := (Sender as TStringGrid).Cells[Col, Row]; // Draw ImageList Index in all Rows in Col 1
      if Col = 1 then
      with (Sender as TStringGrid) do
      begin
      // Clear current cell rect
      Canvas.FillRect(Rect);
      // Draw image index 0 in ImageList1 in the cell
      ImageList1.Draw(Canvas, Rect.Left, Rect.Top, 0);
      // Draw the text in the cell
      Canvas.TextOut(Rect.Left + Image1.Width + 2, Rect.Top, s);
      end;
      end;
      </PRE>

      Ich wäre euch sehr dankbar

      Comment


      • #4
        Hat denn hier niemand eine Idee, wie man den obigen Code in C++ Builder Code transformieren kann?

        Hier nocheinmal der Pascal-Code:

        <PRE>
        procedure TForm1.StringGrid1DrawCell(Sender: TObject; Col,
        Row: Longint; Rect: TRect; State: TGridDrawState);
        var
        s: string;
        begin
        s := (Sender as TStringGrid).Cells[Col, Row]; // Draw ImageList Index in all Rows in Col 1
        if Col = 1 then
        with (Sender as TStringGrid) do
        begin
        // Clear current cell rect
        Canvas.FillRect(Rect);
        // Draw image index 0 in ImageList1 in the cell
        ImageList1.Draw(Canvas, Rect.Left, Rect.Top, 0);
        // Draw the text in the cell
        Canvas.TextOut(Rect.Left + Image1.Width + 2, Rect.Top, s);
        end;
        end;
        </PRE>

        Ich wäre euch sehr dankbar

        Comment

        Working...
        X