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!
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!
Comment