Lee Blake

Lee Blake

  • NA
  • 18
  • 0

Scrolling text is not smooth.

Dec 4 2007 10:42 AM

Hi all I am trying to make a scrolling text, but I cannot get it to scroll smoothly after the characters start to disappear.

this is my code:

 

if (outString.Length == 0)
{
    for (int l = 0; l < m_horizontalText.Length; l++) 
   { 
      outString += m_horizontalText[l].ToString(); 
   } 
   stringStart = 0; 
   fontSize = (m_horizontalText.Length) * m_font.Size; 
   startPosition = this.ClientSize.Width; 
   fo = new Font(m_font.FontFamily.Name, m_font.Size, GraphicsUnit.Pixel); g = this.CreateGraphics();    
   iWidth = g.MeasureString(m_horizontalText[stringStart].ToString(), fo).Width; // == 11 
}

Point pt = new Point(startPosition, (this.ClientSize.Height / 2)); // Adds visible lines to path.

if (((pt.X + (int)iWidth) > (outString.Length * -1)))

   if (startPosition <= ((int)iWidth * -1)) 
   { 
      if (stringStart == m_horizontalText.Length) 
      { 
         stringStart = 0; 
      } 
      stringStart++; 
      outString = ""; 
      startPosition += (int)iWidth; 
      //fo = new Font(m_font.FontFamily.Name, m_font.Size, GraphicsUnit.Pixel); 
      //g = this.CreateGraphics(); iWidth = g.MeasureString(m_horizontalText[stringStart].ToString(), fo).Width; // == 11 
      for (int l = stringStart; l < m_horizontalText.Length; l++) 
      { 
         outString += m_horizontalText[l].ToString(); 
      } 
   } 
   path.AddString(outString, m_font.FontFamily, (int)m_font.Style, m_font.Size, pt, StringFormat.GenericTypographic); 
}
startPosition--;

// For repeat scrolling.
if ((startPosition <= (startPosition * -1)) && (m_scrollingOffset < 0))

   m_scrollingOffset = (int)(this.Font.SizeInPoints * outString.Length); 
}

// Draws wrapped path. e.Graphics.FillPath(new SolidBrush(this.ForeColor), path);
path.Dispose();

the reason for using this method is that I need a transparent background and this is the only way I have found to achive this.

Thanks in advance,

Lee


Answers (1)