Вниз
Скачать: CL | DM;

Длина строки   Найти похожие ветки 

← →
PrettyFly ©   (2003-02-05 15:18) [0]

Есть ли какая-нть функция, определеяющая длину строки, написанную данным шрифтом (в пикселях)?


← →
Skier ©   (2003-02-05 15:21) [1]

1) TCanvas.Font.Assign(...)
2) TCanvas.TextWidth(...)


← →
Игорь Шевченко ©   (2003-02-05 15:32) [2]

function GetTextWidthInPixels(AText: string; AControl: TControl): integer;
var
propInfo: PPropInfo;
thisFont: TFont;
begin
Result := 0;

propInfo := GetPropInfo(AControl.ClassInfo, "Font");

if propInfo <> nil then begin
thisFont := TFont(GetObjectProp(AControl, "Font"));

if Assigned(thisFont) then
with TControlCanvas.Create do
try
Control := AControl;
Font.Assign(thisFont);
Result := TextWidth(AText);
finally
Free;
end;
end;
end;


← →
PrettyFly ©   (2003-02-05 15:41) [3]

Спасиба! А я думал есть стандартная фунукция...


← →
Song ©   (2003-02-05 16:06) [4]

DrawText()


← →
PrettyFly ©   (2003-02-05 16:10) [5]


...
C := TCanvas.Create;
Res := C.TextWidth("la-la-lalala");

Показывает ошибку "Canvas does not allow drawing", почему?



← →
Skier ©   (2003-02-05 16:35) [6]

>PrettyFly
Дружище, а ведь тебе и пример уже дали...
А "Canvas does not allow drawing" потому что не задан
контекст устройства, на котором рисовать см. TCanvas.Handle


← →
PrettyFly ©   (2003-02-05 16:55) [7]

Всё заработало ;)


← →
DarkGreen ©   (2003-02-06 05:28) [8]

The GetTextExtentPoint32 function computes the width and height of the specified string of text. This function supersedes the GetTextExtentPoint function.

BOOL GetTextExtentPoint32(

HDC hdc, // handle of device context
LPCTSTR lpString, // address of text string
int cbString, // number of characters in string
LPSIZE lpSize // address of structure for string size
);



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.46 MB
Время: 0.011 c
14-38485
hatchy
2003-01-26 15:11
2003.02.13
Помогите ....что неправильно???


14-38526
dimich1978
2003-01-29 09:00
2003.02.13
Не Свежая идея


14-38511
OlegKrt
2003-01-28 14:12
2003.02.13
Кто-нибудь может посоветовать генератор отчетов типа как в 1С


7-38595
Lex_!
2002-12-03 11:07
2003.02.13
Запуск программы из моей программы...


3-38101
InokSilver
2003-01-27 06:10
2003.02.13
Как отсортировать по переменному полю?




   Наверх