hatecapletters
asked on
watermark on stringgrid
I need to know how to place an image (preferably transparent) on a stringgrid. It should be overwritten with any row-col lines, and the content of the cells
This will place the graphic in EACH CELL.
In order to fill the entire grid with an image, you will need to "chop up" the image.
I have some code at home that does this an will post it tomorrow.
In order to fill the entire grid with an image, you will need to "chop up" the image.
I have some code at home that does this an will post it tomorrow.
Hi Ed, take a closer look at the code, c'mon don't be shy now :-)
Cheers,
Raymond.
Cheers,
Raymond.
ASKER
sorry for the delay, but I've been busy with other things.. I've tried just about everything with your suggstions, but I haven't been able to get it right so far..
What happens that is not right?
ASKER
i don't get the image ti show.. maybe its because its not as big as the entire stringgrid ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok, that works :-) (only with bmp's but what the heck). now there's just one problem: it overwrites the fixed rows, is there a way around that ?
Yes, change it to this:
procedure TForm1.StringGrid1DrawCell (Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
with Sender as TStringGrid do
begin
if not State in gdFixed then
begin
Canvas.CopyRect(Rect, BackgroundImage.Canvas, Rect);
Canvas.textout(rect.left+2 , rect.top+2, cells[ACol, ARow]);
if gdFocused in State then
Canvas.DrawFocusRect(Rect) ;
end;
end;
end;
procedure TForm1.StringGrid1DrawCell
Rect: TRect; State: TGridDrawState);
begin
with Sender as TStringGrid do
begin
if not State in gdFixed then
begin
Canvas.CopyRect(Rect, BackgroundImage.Canvas, Rect);
Canvas.textout(rect.left+2
if gdFocused in State then
Canvas.DrawFocusRect(Rect)
end;
end;
end;
EddieShipman changed the proposed answer to a comment
OOPS, should read:
if not (gdFixed in State)
if not (gdFixed in State)
ASKER
that works :-)
thank you to Eddie too. If I had more points on my account, I would have offered some to you too.
thank you to Eddie too. If I had more points on my account, I would have offered some to you too.
Hey no problem, I couldn't find the source that I mentioned earlier in the thread.
Be aware, however, that the effect is not very appealing...
Good Luck...
Be aware, however, that the effect is not very appealing...
Good Luck...
ASKER
actually I'm quite happy with the effect, after I put canvas.brush.style := bsclear; right before canvas.textout... :-)
procedure TForm1.DrawGrid1DrawCell(S
begin
with Sender as TStringGrid do
begin
Canvas.CopyRect(Rect, BackgroundImage.Canvas, Rect);
canvas.textout(rect.x+2, rect.y+2, cells[col, row]);
if gdFocused in State then
Canvas.DrawFocusRect(Rect)
end;
end;
Cheers,
Raymond.