Borland C ++ Builder FAQ
The content The last update: 12/12/2008

How to deduce the text on circles?

The author: it is unknown
The text gave: KAV
The initial link: - - -

void DrawCircularText (TCanvas *Canvas, AnsiString asFontName, int iHeight, char *szText, int iAngle, int iR, int iCX, int iCY, int iSector) 
{  
  LOGFONT lf//we create object for a non-standard font 
  HFONT hPrevFont, hFont;  
  int iPass = iSector/lstrlen (szText); //distance between letters 
  ZeroMemory (&lf,sizeof (lf));  
  lf.lfCharSet=RUSSIAN_CHARSET;//for Russian 
  lf.lfWeight = 900; //that though it was visible! Though it is possible to remove 
  for (int i=0; i <lstrlen (szText); i ++)  
  {  
    lf.lfEscapement = 10*iAngle - (10*iPass * (i-1));//a corner 
    lstrcpy (lf.lfFaceName, asFontName.c_str ());//font name 
    lf.lfHeight = iHeight;//we install height 
    hFont = CreateFontIndirect (&lf);//we create immediately a font 
    hPrevFont = SelectObject (Canvas-> Handle, hFont);//we do a font hFont 
    Canvas-> TextOut (iCX+iR*sin ((- 180+iAngle - (i-1) *iPass) *3.14/180), iCY+iR*cos ((- 180+iAngle - (i-1) *iPass) *3.14/180), szText [i]);//we deduce the character 
    hFont = SelectObject (Canvas-> Handle, hPrevFont); //reversely we change a font 
    DeleteObject (hFont);//it is deleted 
  } 
}
Changing argument iAngle, it is possible to rotate starting point - center. And changing iSector it is possible to deduce the text both on circles, and on an arc (it is set in degrees). For certain many saw such эффектик. Any text is twisted round center and its radius - distance from center to letters changes. And here it is possible same to make. For this purpose it is necessary to cause this procedure on the timer where before a call to change iAngle and iR (variables to get). Only before each drawing, it is necessary to clear in this function already drawn that does not remain old. And if it is immediate on an outline becomes slowly and blinks, but it is necessary to draw on битмапе and therefrom the image to copy.