chongkeng_woon
asked on
TBitmap.Canvas.TextWidth problem
assuming i created a TBitmap (bm) as global variable on top ....then,
function TForm1.test();
function getTextWidth(var bm:TBitmap):integer;
var s:string;
var b : tfont;
begin
s := 'From TransNo: [] To TransNo: [] From Salesman: [] To Salesman: [] From Date: [01/10/2007] To Date: [31/10/2007]';
b := TFont.create;
b.Name := 'Times New Roman';
b.Size := 8;
bm.canvas.Font.Assign(b);
result := bm.canvas.textwidth(s);
end;
begin
aWidth := getTextWidth(bm);
.....
..... (other source code)
.....
.....
aWidth := getTextWidth(bm);
end;
at first time, my aWidth value = 595, while the 2nd time , it return 1950; the source code in between have changed my TBtimap property ...is there anyway i can list out all properties of TBitmap object (e.g. size, width ...) so that i can compare what have been changed before and after ...?
thanks
function TForm1.test();
function getTextWidth(var bm:TBitmap):integer;
var s:string;
var b : tfont;
begin
s := 'From TransNo: [] To TransNo: [] From Salesman: [] To Salesman: [] From Date: [01/10/2007] To Date: [31/10/2007]';
b := TFont.create;
b.Name := 'Times New Roman';
b.Size := 8;
bm.canvas.Font.Assign(b);
result := bm.canvas.textwidth(s);
end;
begin
aWidth := getTextWidth(bm);
.....
..... (other source code)
.....
.....
aWidth := getTextWidth(bm);
end;
at first time, my aWidth value = 595, while the 2nd time , it return 1950; the source code in between have changed my TBtimap property ...is there anyway i can list out all properties of TBitmap object (e.g. size, width ...) so that i can compare what have been changed before and after ...?
thanks
ASKER
the problem is ....i am running this function in my ISAPI WebServer Application, it is quite impossible for me to step through the code and see where it changes ....any idea ?
thanks
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Forced accept.
Computer101
EE Admin
Computer101
EE Admin
What you also can do is to set getTextWidth(bm) in watch, step through the code, and see where it changes.
btw, please notice that you are leaking a TFont each time you call getTextWidth()!