Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2003.02.13;
Скачать: [xml.tar.bz2];

Вниз

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

 
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 вся ветка

Форум: "Основная";
Текущий архив: 2003.02.13;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.45 MB
Время: 0.01 c
3-38027
wildcow
2003-01-29 10:43
2003.02.13
SQL 2000 использование Distinct


1-38269
vlv
2003-02-05 16:21
2003.02.13
Проблемы с загрузкой строки из ресурсов exe


3-38025
Dracula2000
2003-01-29 09:57
2003.02.13
InterBase 6


3-38064
Ivanov Sergey
2003-01-25 23:43
2003.02.13
ib6.ForsedWrites := Disabled; это опасно?


1-38383
Diod
2003-02-02 07:33
2003.02.13
Фйлы и edit





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский