Solved

Drawing Vertical Text ?

Posted on 2002-03-27
2
432 Views
Last Modified: 2010-05-18
Hi, I need to draw text vertically, ....(simple enuf)

But the font that needs to be drawn, needs to be selected by the user at runtime.

(* This is an extract of my code *)
GetObject(Canvas.Font.Handle, SizeOf(LogFont), @LogFont);
 with LogFont do
 begin
   lfEscapement:= 90 * 10; //this does the rotation
   lfQuality := PROOF_QUALITY;
   lfFaceName:= 'Comic Sans MS';
/* The problem is with the above line, as it needs to be set at runtime */
 end;

 //Assign the new rotated font handle
 NewFont := CreateFontIndirect(LogFont);
 OldFont := SelectObject(Canvas.Handle,NewFont);

 ACanvas.TextOut(0,0, 'Testing...');

 //restore old font and delete new handle
 NewFont := SelectObject(Canvas.Handle,OldFont);
 DeleteObject(NewFont);

(********** END **************)
What I am doing instead of that line is

   S:=Canvas.Font.Name; // string  
// Assume Canvas.Font is some font set by the user at runtime...
   FillChar(lfFaceName,32,#0);
   For j := 1 to Length(S) do
     lfFaceName[j-1]:= S[j]; // For this example assume the user has chosen Comic Sans MS...

Even though the above code is the equivalent to
     lfFaceName[j-1]:= 'Comic Sans MS';

... I only get the correct font displayed if it is hardcoded..????

Help.....???
0
Comment
Question by:CyberKnight
2 Comments
 
LVL 1

Accepted Solution

by:
Fraction earned 10 total points
ID: 6899084
You have probably tested, but doesn't it work with:
StrCopy(lfFaceName, PChar(s));
0
 

Author Comment

by:CyberKnight
ID: 6899277
Wow, Yes, it does work, that was something I didnt test with....(duh !)

Thank you... Great !!!
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now