all groups > dotnet drawing api > august 2006 >
You're in the

dotnet drawing api

group:

Using LogFont Class in C#


Using LogFont Class in C# balu
8/31/2006 2:52:27 AM
dotnet drawing api:
When i try to use the below code which i copied from msdn, i am getting
the error like "No PInvoke conversion exists for value passed to
Object-typed parameter."

LogFont logf = new Microsoft.WindowsCE.Forms.LogFont();

// Create graphics object for the form, and obtain
// the current DPI value at design time. In this case,
// only the vertical resolution is petinent, so the DpiY
// property is used.

Graphics g = this.CreateGraphics();
// Scale an 18-point font for current screen vertical DPI.
logf.Height = (int)(-18f * g.DpiY / curDPI);

// Convert specified rotation angle to tenths of degrees.
logf.Escapement = angleInDegrees * 10;

// Orientation is the same as Escapement in mobile
platforms.
logf.Orientation = logf.Escapement;

logf.FaceName = fontname;

// Set LogFont enumerations.
logf.CharSet = LogFontCharSet.Default;
logf.OutPrecision = LogFontPrecision.Default;
logf.ClipPrecision = LogFontClipPrecision.Default;
logf.Quality = LogFontQuality.ClearType;
logf.PitchAndFamily = LogFontPitchAndFamily.Default;

// Explicitly dispose any drawing objects created.
g.Dispose();

return Font.FromLogFont(logf);

Can anybody help me regarding this.
Re: Using LogFont Class in C# Bob Powell [MVP]
8/31/2006 9:02:16 PM
I'm assuming that you've got a prototype for the PInvoke method somewhere...
you'll have to change the parameter to something like IntPtr and give it an
attribute such as MarshalAs(LPStruct)

This is a guess here I'm no longer a PPC expert..

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.



[quoted text, click to view]

AddThis Social Bookmark Button