Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General 2 / January 2004



Tip: Looking for answers? Try searching our database.

Problem Q119673

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mallik - 30 Jan 2004 15:41 GMT
Hi Everybody,
 I followed the instructions given in article Q119673 to rotate text.
But the code is not working for me. It is giving me error messages like
File not found:GDI or
Overflow
I would be glad if somebody helped me in this. Please accept my advanced thanks.
Thank you,
Sincerely,
Masala Mallikarjuna
Mike Williams - 30 Jan 2004 18:32 GMT
>   I followed the instructions given in article Q119673 to
> rotate text. But the code is not working for me. It is giving
> me error messages like File not found:GDI or Overflow

That's an old article and was meant for use with VB3 on older versions of
Windows. It uses the GDI library instead of the current GDI32 library, and
it also uses Integers whereas modern versions use Longs. That is why you are
getting both of the errors you mentioned. Try the following instead:

Mike

Option Explicit
Private Declare Function CreateFontIndirect Lib "gdi32" Alias _
"CreateFontIndirectA" (lpLogFont As LOGFONT_TYPE) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc _
As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal _
hObject As Long) As Long
Private Const LF_FACESIZE = 32
Private Type LOGFONT_TYPE
 lfHeight As Long
 lfWidth As Long
 lfEscapement As Long
 lfOrientation As Long
 lfWeight As Long
 lfItalic As Byte
 lfUnderline As Byte
 lfStrikeOut As Byte
 lfCharSet As Byte
 lfOutPrecision As Byte
 lfClipPrecision As Byte
 lfQuality As Byte
 lfPitchAndFamily As Byte
 lfFaceName As String * LF_FACESIZE
End Type

Private Sub Command1_Click()
Dim font As LOGFONT_TYPE
Dim prevFont As Long, hFont As Long, ret As Long
Const FONT_SIZE = 12   ' Desired point size of font
font.lfEscapement = 1800    ' 180-degree rotation
font.lfFaceName = "Arial" + Chr$(0)
' Windows expects the font size to be in pixels and to
' be negative if you are specifying the character height
' you want.
font.lfHeight = (FONT_SIZE * -20) / Screen.TwipsPerPixelY
hFont = CreateFontIndirect(font)
prevFont = SelectObject(Picture1.hdc, hFont)
Picture1.CurrentX = Picture1.Width \ 2
Picture1.CurrentY = Picture1.Height \ 2
Picture1.Print "Rotated Text"
' Clean up by restoring original font.
ret = SelectObject(Picture1.hdc, prevFont)
ret = DeleteObject(hFont)
Picture1.font.Size = 12
Picture1.font.Name = "Arial"
Picture1.FONTSIZE = 12
Picture1.Print "Normal Text"
End Sub
Mallik - 31 Jan 2004 20:39 GMT
Hi Mike,
 The code that you gave is working. I realized the mistakes that I
made. Thank you very much for your help.
Sincerely,
Masala Mallikarjuna
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.