Deklaration: Declare Function EndPage Lib "gdi32.dll" (ByVal hDC As Long) As Long Beschreibung: Parameter:
Rückgabewert: Beispiel: Private Declare Function CreateDC Lib "gdi32" _ Alias "CreateDCA" ( _ ByVal lpDriverName As String, _ ByVal lpDeviceName As String, _ ByVal lpOutput As String, _ lpInitData As Any) As Long Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function GetDeviceCaps Lib "gdi32" ( _ ByVal hdc As Long, _ ByVal nIndex As Long) As Long Private Declare Function StartDoc Lib "gdi32" _ Alias "StartDocA" ( _ ByVal hdc As Long, _ lpdi As DOCINFO) As Long Private Declare Function StartPage Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function EndDoc Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function EndPage Lib "gdi32" (ByVal hdc As Long) 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 CreatePen Lib "gdi32" ( _ ByVal nPenStyle As Long, _ ByVal nWidth As Long, _ ByVal crColor As Long) As Long Private Declare Function TextOut Lib "gdi32.dll" _ Alias "TextOutA" ( _ ByVal hdc As Long, _ ByVal X As Long, _ ByVal Y As Long, _ ByVal lpString As String, _ ByVal nCount As Long) As Long Private Declare Function Ellipse Lib "gdi32.dll" ( _ ByVal hdc As Long, _ ByVal X1 As Long, _ ByVal Y1 As Long, _ ByVal X2 As Long, _ ByVal Y2 As Long) As Long Private Declare Function GetTextExtentPoint32 Lib "gdi32" _ Alias "GetTextExtentPoint32A" ( _ ByVal hdc As Long, _ ByVal lpsz As String, _ ByVal cbString As Long, _ lpSize As POINTAPI) As Long Private Type POINTAPI X As Long Y As Long End Type Private Type DOCINFO cbSize As Long lpszDocName As String lpszOutput As Long lpszDatatype As String fwType As Long End Type ' DOCINFO fwType-Konstanten Private Const DI_APPBANDING = &H1 Private Const DI_ROPS_READ_DESTINATION = &H2 ' einige GetDeviceCaps nIndex-Konstanten Private Const PHYSICALHEIGHT = 111 Private Const PHYSICALOFFSETX = 112 Private Const PHYSICALOFFSETY = 113 Private Const PHYSICALWIDTH = 110 ' CreatePen nPenStyle-Konstanten Private Const PS_DASH = 1 ' Linien mit leeren Zwischenräumen Private Const PS_DOT = 2 ' Punkte mit leeren Zwischenräumen Private Const PS_DASHDOT = 3 ' Linien und Punkte mit leeren Zwischenräumen Private Const PS_DASHDOTDOT = 4 ' Linie, Punkt, Punkt mit leeren Zwischenräumen Private Const PS_NULL = 5 ' Unsichtbar Private Const PS_INSIDEFRAME = 6 ' Der Pen ist Solid wird aber im inneren des Objektes gezeichnet Private Const PS_SOLID = 0 ' Durchgezogene Linie Private Sub Command1_Click() Dim PrinterDC As Long, Retval As Long, Doc As DOCINFO Dim PWidth As Long, PHeight As Long, PYMargin As Long, PXMargin As Long Dim hPen As Long, hOldPen As Long, OutputStr As String, OutputSize As POINTAPI Dim TLeft As Long, TTop As Long, TWidth As Long, THeight As Long ' Drucker Devicekontext erstellen PrinterDC = CreateDC(vbNullString, Printer.DeviceName, vbNullChar, _ ByVal 0&) If PrinterDC = 0 Then Exit Sub ' Ausdruckgröße ermitteln PWidth = GetDeviceCaps(PrinterDC, PHYSICALWIDTH) PHeight = GetDeviceCaps(PrinterDC, PHYSICALHEIGHT) ' Nichtbedruckbare Ränder ermitteln PYMargin = GetDeviceCaps(PrinterDC, PHYSICALOFFSETY) PXMargin = GetDeviceCaps(PrinterDC, PHYSICALOFFSETX) ' Ausdruck für den Spoolmanager definieren With Doc .cbSize = Len(Doc) .lpszDocName = "VB Api Helpline Print Example" End With ' Starten des Ausdrucks StartDoc PrinterDC, Doc ' Beginnen einer Seite StartPage PrinterDC ' roten Pen erstellen hPen = CreatePen(PS_DASHDOT, 0, RGB(255, 0, 0)) ' Pen dem Drucker zuweisen hOldPen = SelectObject(PrinterDC, hPen) ' String für den Ausdruck definieren OutputStr = "VB API HELPLINE" ' Größe der Ausgabe bei aktuellen Fonteinstellungen ermitteln GetTextExtentPoint32 PrinterDC, OutputStr, Len(OutputStr), OutputSize ' Koordinaten zum Positionieren in der Mitte des Ausdrucks ermitteln TWidth = OutputSize.X THeight = OutputSize.Y TTop = (PHeight - (2 * PYMargin) - OutputSize.Y) / 2 TLeft = (PWidth - (2 * PXMargin) - OutputSize.X) / 2 ' Ellipse zeichnen (mit neu erstelltem Pen) Ellipse PrinterDC, TLeft - 50, TTop - 50, TLeft + 50 + TWidth, TTop + _ 50 + THeight ' Text auf die Ellipse platzieren TextOut PrinterDC, TLeft, TTop, OutputStr, Len(OutputStr) ' Alten Pen wiederherstellen SelectObject PrinterDC, hOldPen ' Pen Zerstören DeleteObject hPen ' Abschließen der Seite EndPage PrinterDC ' Beenden des Ausdrucks EndDoc PrinterDC ' Drucker Devicekontext zerstören DeleteDC PrinterDC End Sub Diese Seite wurde bereits 7.606 mal aufgerufen. |
sevWizard für VB5/6 Professionelle Assistenten im Handumdrehen Erstellen Sie eigene Assistenten (Wizards) im Look & Feel von Windows 2000/XP - mit allem Komfort und zwar in Windeseile :-) Buchempfehlung Tipp des Monats Mai 2024 Hermann Röttger Wochentage eines Datumsbereichs ermitteln Wochentage eines Datumsbereichs ermitteln, optional mit Feiertagsberechnung TOP Entwickler-Paket TOP-Preis!! Mit der Developer CD erhalten Sie insgesamt 24 Entwickler- komponenten und Windows-DLLs. Die Einzelkomponenten haben einen Gesamtwert von 1605.50 EUR... |
||||||||||||
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein. |