Re: How to get the pixel width of a string?

From: Fabian Schmied (REMOVETHISfabianDOTschmied_at_fhs-hagenbergDOTacDOTat)
Date: 10/18/04


Date: Mon, 18 Oct 2004 18:53:53 +0200


> I am trying to get the pixel width of a string. It's probably a very
> simple
> task, but I cannot figure it out easily.
> The class I am using is: System.Drawing.Font

This is not a DirectX question, but a GDI+ question. (Hint: Take a look at
Graphics.MeasureString.)

Fabian



Relevant Pages

  • Re: When I type fff the first two letters are closer than the last two
    ... the layout is in fact very dependent on resolution. ... lines up with the pixel positions. ... Both the character outline, and the "bounding box" that says how wide ... but if you have a string of the same letter the ...
    (microsoft.public.word.pagelayout)
  • Re: Detection of caption (text) wrapping, how?
    ... Also a lot depends on exactly how you want to shorten the text if it does not fit, perhaps adding some dots at the end to signify it has been shortened or perhaps just removing the characters that do not fit. ... One very simple method would be to check the available pixel width for the button's Caption against the actual pixel width of the text you intend to use and remove one character from the end of the intended text string until it will fit. ...
    (microsoft.public.vb.general.discussion)
  • Re: Scrolling text in a stationary label help needed
    ... TextWidth of the entire string by the TextWidth of a single space character. ... When the time comes to move the string to the left by one pixel the ... Private Sub Form_Load ...
    (microsoft.public.vb.general.discussion)
  • Re: Scrolling text in a stationary label help needed
    ... Using the TextWidth function to get your values you can simply divide the TextWidth of the entire string by the TextWidth of a single space character. ... At the moment the first time the string is printed into the Picture box it is printed at x coordinate zero. ... When the time comes to move the string to the left by one pixel the following happens. ...
    (microsoft.public.vb.general.discussion)
  • Re: String Length in Pixels
    ... > I have a listbox on a userform and I use the device ... > content of the form to calculate the string length, ... > creating a font and assigning to the form, ... There's about a 2 pixel border around all "3D" controls. ...
    (microsoft.public.vb.general.discussion)