|
-
Feb 16th, 2006, 12:05 PM
#1
Thread Starter
New Member
VB.NET, Problem with the Fonts Rotation
Having VB.NET problem. Please help.
Running the following code:
Function CreateRotatedFont(ByVal fontname As String, ByVal angleInDegrees As Integer) As Font
Dim lf As New LogFont()
' Create graphics object for the form.
Dim g As Graphics = Me.CreateGraphics()
' Scale a 12 point font for current screen DPI.
lf.Height = Fix(-16.0F * g.DpiY / DPISETTING)
' Convert rotation angle to tenths of degrees.
lf.Escapement = angleInDegrees * 10
' Orientation is the same as
' Escapement in mobile platforms.
lf.Orientation = lf.Escapement
lf.Width = 0
lf.Weight = 0
lf.Italic = 0
lf.Underline = 0
lf.StrikeOut = 0
lf.CharSet = LogFontCharSet.Default
lf.OutPrecision = LogFontPrecision.Default
lf.ClipPrecision = LogFontClipPrecision.Default
lf.Quality = LogFontQuality.ClearType
lf.PitchAndFamily = LogFontPitchAndFamily.Default
lf.FaceName = fontname
Try
Return System.Drawing.Font.FromLogFont(lf)
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
' Explicitly dispose any drawing objects created.
g.Dispose()
End Try
End Function
When executing the line:
Return System.Drawing.Font.FromLogFont(lf)
I am getting the following exception:
"No PInvoke conversion exists for value passed to Object-typed parameter."
Does anybody know how to solve this problem?
Thank you very much in advance.
-
Feb 16th, 2006, 12:44 PM
#2
Re: VB.NET, Problem with the Fonts Rotation
Try casting lf as an Object before passing it to the method. I don't know if it will work but it's worth a try.
Also, how have you defined your LogFont type? The way you're instantiating it looks like it's a class. It's supposed to be a structure, which may have a bearing.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|