Link to home
Start Free TrialLog in
Avatar of chongkeng_woon
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


Avatar of MerijnB
MerijnB
Flag of Netherlands image

while in the debugger you can ctrl+click on a variable name, or right click and choose 'inspect', maybe this can help you.

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()!
Avatar of chongkeng_woon
chongkeng_woon

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
ASKER CERTIFIED SOLUTION
Avatar of MerijnB
MerijnB
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Forced accept.

Computer101
EE Admin