CreateFontで回転させて印刷出来ない
こんにちは。maruru01です。
APIのCreateFont関数を使用して文字列を回転させ、それを印刷しようとしたのですが、うまくいきません。
どうもCreateFontの情報がPrinterオブジェクトに伝わってないようです。
オブジェクトをPrinterの替わりにForm1にするとちゃんと回転して表示されます。
どうすればうまくいくのでしょうか。
よろしくお願いします。
使用環境:Windows2000(SP2)、Visual Basic 6.0(SP5) EnterpriseEdition
Private Sub Command1_Click()
Dim hdc As Long
Dim FontName As String
Dim FontHeight As Long
Dim hFont As Long
Dim hFontOld As Long
Dim tempStr As String
Const DEFAULT_CHARSET = 1
tempStr = "文字列回転"
hdc = Printer.hdc
FontName = "MS Pゴシック"
FontHeight = 9
hFont = CreateFont(-(FontHeight * 20 / Screen.TwipsPerPixelX), 0, 900, 2700, 0, False, False, False, DEFAULT_CHARSET, False, False, False, False, FontName)
hFontOld = SelectObject(hdc, hFont)
Printer.ScaleMode = vbCentimeters
Printer.CurrentX = 2
Printer.CurrentY = 2
Printer.Print tempStr
DeleteObject SelectObject(hdc, hFontOld)
End Sub
補足
返事が大変遅れましたすみません。 開発環境はMicrosoft Visual Studio 6.0 Enterpriseです SYUにプリンターオブジェクトを設定しています。 Public Sub MOJIK(MX, MY, FO, COR, MO, intAngle) Dim lnghNewFont As Long Dim lnghOriginalFont As Long Dim lngHeight As Long Dim lngWidth As Long 'on error goto Exit Sub ' フォントを作成 With SYU ' ピクセル単位に設定 ' フォントの高さ lngHeight = FO ' フォントの幅 lngWidth = 0 With .Font lnghNewFont = CreateFont(lngHeight, lngWidth, _ intAngle * 10, intAngle * 10, _ .Weight, _ .Italic, _ .Underline, _ .Strikethrough, _ .Charset, _ 0, _ 0, _ 0, _ 0, _ .Name) End With ' 作成したフォントを選択 lnghOriginalFont = SelectObject(.hdc, lnghNewFont) ' 描画開始位置 SYU.CurrentX = MX SYU.CurrentY = MY - SYU.TextHeight("A") ' テキストボックスの内容を描画 SYU.Print MO ' 元のフォントに戻す lnghNewFont = SelectObject(.hdc, lnghOriginalFont) End With ' オブジェクトを破棄 DeleteObject lnghNewFont End Sub