> 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