Recent

Author Topic: Drawing a bitmap with text in KOL-CE  (Read 7142 times)

sandeman

  • Newbie
  • Posts: 3
Drawing a bitmap with text in KOL-CE
« on: August 18, 2008, 10:12:00 pm »
I am trying to draw a bitmap from a resource file on my form with KOL-CE (using a paintbox), but don't get it working. I even don't know if a paintbox is the right control to use.
What I would like is a static bitmap background with variable text on top of it. What would be the best way to do this?

yuriy_sydorov

  • Full Member
  • ***
  • Posts: 158
RE: Drawing a bitmap with text in KOL-CE
« Reply #1 on: August 18, 2008, 10:50:29 pm »
You should use paintbox. It works well. It seems you are doing something wrong in paint code.

sandeman

  • Newbie
  • Posts: 3
Drawing a bitmap with text in KOL-CE
« Reply #2 on: August 19, 2008, 03:23:08 pm »
Could you give a simple code example how to get a bitmap from a resource file onto a paintbox?

And, if I have a paintbox with the bitmap drawn on it, how can I best put text on it? Can I use caption or should I use textout and redraw the whole paintbox every time the text changes?
I understood that I cannot use a label or panel on top of the paintbox because KOL-CE does not support transparency.

sandeman

  • Newbie
  • Posts: 3
Drawing a bitmap with text in KOL-CE
« Reply #3 on: August 20, 2008, 09:49:22 pm »
When I try something like this I get a runtime error:
Code: [Select]
procedure TListForm.PaintBox1MouseDown(Sender: PControl;
  var Mouse: TMouseEventData);
var bitmap:PBitmap;
    MyRect:TRect;
begin
  bitmap:=NewBitmap(77,77);
  bitmap.LoadFromResourceName(0,'mybitmap');
  MyRect:=bitmap.BoundsRect;
  PaintBox1.Canvas.CopyRect(MyRect,bitmap.canvas,MyRect);
  bitmap.Destroy;
end;

The error is not there when I remove the CopyRect line, but of course then my Paintbox stays empty.

rjklindsay

  • Newbie
  • Posts: 1
Re: Drawing a bitmap with text in KOL-CE
« Reply #4 on: August 18, 2009, 11:27:21 pm »
I'm having the same problem.
However, your code will work if you replace:
  bitmap.LoadFromResourceName(0,'mybitmap');
with
  bitmap.LoadFromFile('mybitmap.bmp');

Of course this loads from a file instead of the resources.
It seems there is a bug in LoadFromResourceName function in KOL-CE.

 

TinyPortal © 2005-2018