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

Вниз

Как на канве вывести текст вертикально?   Найти похожие ветки 

 
BlackTiger   (2003-11-11 17:25) [0]

В общем-то subj. Очень нужно!


 
Murad   (2003-11-11 17:29) [1]

Смотри LOGFONT... а именно поле lfOrientation


 
Murad   (2003-11-11 17:32) [2]

ПАРДОН ... lfEscapement


 
BlackTiger   (2003-11-11 17:33) [3]

Сам нашел только что, но может еще есть варианты?
//
---------------------------------------------------------------
Question :
How can I write a text vertically in a canvas ?

Answer :
You need to have the Windows unit in your uses clause. It is usually added
automatically and should never be removed. Create a new project, drop a
TPaintbox on the form and size it to take up most of the form. Add a handler
to the paintboxes OnPaint event and replace it with the handler i posted.
Compile and run the project.

> Also, could you comment a little on the
> crucial steps? I can"t figure out how this code works.

FillRect( ClientRect );
Pen.Color := clBlack;
Pen.Width := 2;
Font.Name := "Arial";
Font.Size := 10;
Font.Style := [fsBold];
x0 := 30;
y0 := Height - 30;
MoveTo( x0, 5 );
LineTo( x0, y0 );
LineTo( Width-5, y0 );
TextOut( x0, y0+5,
"Horizontale Achse" );

The first part is straight use of the Delphi Canvas methods to fill the area
of the paintbox with some background and paint to perpendicular lines to
serve as axis of a coordinate grid ( only the upper right quadrant in this
case). A font is selected and the horizontal axis is labelled.

GetObject( Font.Handle, Sizeof(lf), @lf );

This is where the fun starts. GetObject is an API function that fills a
TLogfont record with information about a font, given the fonts handle. Look
at the topic for LOGFONT in win32.hlp to see what information the record
contains.

lf.lfEscapement := 900;

lfEscapement rotates the baseline of the font in units of 1/10 degrees, so
the assignment rotates the font 90 degrees counterclockwise.

Font.Handle := CreateFontIndirect( lf );

We create a new font from the changed information and assign its handle to
the canvas.font. Delphi takes care of disposing properly of the old font
handle.

TextOut( x0-TextHeight("A")-5, y0,
"Vertikale Achse" );

This labels the vertical axis with the rotated font.

DeleteObject( Font.Handle );
Font.Handle := 0;

This is cleanup code that disposes of the created font handle. I"m never
quite sure if this is actually required or if the cleanup task can be left
to Delphi here as well. Since i"m paranoid by nature i prefer to take
the safe route and clean up what i created in code myself.
---------------------------------------------------------------
//


 
Murad   (2003-11-11 17:35) [4]

BaseFont : HFONT - неповернутый шрифт , получаем с него
LogFnt : TLogFont
GetObject(BaseFont, sizeOf(LogFnt), @LogFnt);
Поворачиваем...
LogFnt.lfEscapement := Round(Angle*10);
resFNT : HFONT- повернутый шрифт
resFNT := CreateFontIndirect(LogFnt);


 
RealRascal   (2003-11-11 17:53) [5]

Кажется, я где-то видел процедурку поворота надписи на любой угол, кажется в факью каком-то.


 
Skier   (2003-11-11 17:53) [6]

Этих "процедурок" в сети полно...


 
Murad   (2003-11-11 17:55) [7]

Учти, поворачивать можно только TrueType шрифты

2RealRascal
Чуть выше твоего поста суть этой процедуры :))



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

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

Наверх




Память: 0.46 MB
Время: 0.009 c
1-65900
ak75
2003-11-08 18:00
2003.11.20
TThread. Что не так? И как с этим бороться?


3-65782
inspirion
2003-10-30 21:37
2003.11.20
Мастера требуется Ваш совет!


7-66147
FoX
2003-09-12 14:14
2003.11.20
Автозапуск в безопасном режим


3-65689
SasaR
2003-11-03 12:31
2003.11.20
Locate - быстрее....


1-65929
Chuha
2003-11-11 15:09
2003.11.20
Окна





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
Английский Французский Немецкий Итальянский Португальский Русский Испанский