P
Paul Hoad
I'm trying to use MeasureString() to determine the length in pixels of a
string
However to do I need a System.Drawing.Graphics object
to do this I need to create a System.Drawing.Graphics object for which there
is only
two constructors
System.Drawing.Graphics.FromHdc
and
System.Drawing.Graphics.FromHwnd
My application is a C# Console application and I don't have and Forms to
pass the handle
into.
Does anyone know of a way of me overcoming this problem? perhaps I can get
the DesktopWindow in C#?
public SizeF HowBigIsThisText(string myString)
{
Font MyFontObject = new Font("MS San Serif",8);
System.Draing.Graphics gr=System.Drawing.Graphics.FromHwnd(<Don't know
what handle to provide here>)
return gr.MeasureStringmyString,MyFontObject);
}
Many thanks in advance
Dr Paul Hoad
string
However to do I need a System.Drawing.Graphics object
to do this I need to create a System.Drawing.Graphics object for which there
is only
two constructors
System.Drawing.Graphics.FromHdc
and
System.Drawing.Graphics.FromHwnd
My application is a C# Console application and I don't have and Forms to
pass the handle
into.
Does anyone know of a way of me overcoming this problem? perhaps I can get
the DesktopWindow in C#?
public SizeF HowBigIsThisText(string myString)
{
Font MyFontObject = new Font("MS San Serif",8);
System.Draing.Graphics gr=System.Drawing.Graphics.FromHwnd(<Don't know
what handle to provide here>)
return gr.MeasureStringmyString,MyFontObject);
}
Many thanks in advance
Dr Paul Hoad