Visual Basic, .NET, ASP, VBScript
 

   
   
     

Форум - Общий форум

Страница: 1 |

 

  Вопрос: Поворот текста Добавлено: 12.12.07 19:47  

Автор вопроса:  ZoomerSD | ICQ: 148640473 
Обясните мне тупому, почему, две одинаковые процедуры,(разница только в названии переменных) выдают разные результаты?!?!
Задача: вывести на принтер вертикальны текст.
Решение:
   Private Declare Function CreateFontIndirect Lib "gdi32" Alias _
   "CreateFontIndirectA" (lpLogFont As LOGFONT) As Long
   Private Declare Function DeleteObject Lib "gdi32" _
   (ByVal hObject As Long) As Long
   Private Declare Function SelectObject Lib "gdi32" _
   (ByVal hdc As Long, ByVal hObject As Long) As Long
   Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" _
   (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, _
   ByVal lpString As String, ByVal nCount As Long) As Long ' or Boolean

   Private Const LF_FACESIZE = 32

   Private Type LOGFONT
      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
   Const DESIREDFONTSIZE = 12

Private Sub Command1_Click()
      Dim OutString As String
      Dim lf As LOGFONT
      Dim result As Long
      Dim hOldfont As Long
      Dim hPrintDc As Long
      Dim hFont As Long
      Printer.Print "Printer Object"
      hPrintDc = Printer.hdc
      OutString = "Test"
      lf.lfEscapement = 900
      lf.lfHeight = (DESIREDFONTSIZE * -20) / Printer.TwipsPerPixelY
      hFont = CreateFontIndirect(lf)
      hOldfont = SelectObject(hPrintDc, hFont)
      result = TextOut(hPrintDc, 1000, 1000, OutString, Len(OutString))
      result = SelectObject(hPrintDc, hOldfont)
      result = DeleteObject(hFont)
      Printer.Print "xyz"
      Printer.EndDoc
End Sub

Private Sub Command2_Click()
    Dim strLine As String
    Dim resFont, resFont2, Res As Long
    Dim fon As LOGFONT
    Printer.Print "hELLO wORLD"
    fon.lfHeight = (20 * -20) / Printer.TwipsPerPixelY
    fon.lfEscapement = 900
    resFont = CreateFontIndirect(fon)
    resFont2 = SelectObject(Printer.hdc, resFont)
    Res = TextOut(Printer.hdc, 500, 500, "Test", Len("Test"))
    Res = SelectObject(Printer.hdc, resFont2)
    Res = DeleteObject(resFont)
    Printer.Print "End"
    Printer.EndDoc
End Sub

Почему Гейтс их подери, при нажатии на command1, текст печатается вертикально, при нажатии на command2 нет!!!

Ответить

  Ответы Всего ответов: 1  

Номер ответа: 1
Автор ответа:
 EUGY



Вопросов: 0
Ответов: 454
 Профиль | | #1 Добавлено: 12.12.07 21:21
эта лажа документирована
RESOLUTION
To work around this problem, either print using the API only, or do not reference the Printer object while printing with the API functions.

Короче, не ссылайтесь на объект Printer в вызове Api-функций.
http://support.microsoft.com/kb/q175535/

Ответить

Страница: 1 |

Поиск по форуму



© Copyright 2002-2011 VBNet.RU | Пишите нам