Deklaration: 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 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 Private Const PS_DOT = 2 Private Const PS_DASHDOT = 3 Private Const PS_DASHDOTDOT = 4 Private Const PS_NULL = 5 Private Const PS_INSIDEFRAME = 6 Private Const PS_SOLID = 0 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 Peneerstellen 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 ermitteln zum Positionieren in der Mitte des Ausdrucks 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 10.117 mal aufgerufen. |
Neu! sevPopUp 2.0 Dynamische Kontextmenüs! Erstellen Sie mit nur wenigen Zeilen Code Kontextmenüs dynamisch zur Laufzeit. Vordefinierte Styles (XP, Office, OfficeXP, Vista oder Windows 8) erleichtern die Anpassung an die eigenen Anwendung... Buchempfehlung Tipp des Monats März 2024 Dieter Otter UTF-8 Konvertierung von Dateien und Strings VB6 selbst verfügt über keine Funktionen zur UTF-8 Konvertierung von Daten. Mit Hilfe des ADODB.Stream-Objekts lassen sich diese fehlenden Funktionen aber schnell nachrüsten. Access-Tools Vol.1 Über 400 MByte Inhalt Mehr als 250 Access-Beispiele, 25 Add-Ins und ActiveX-Komponenten, 16 VB-Projekt inkl. Source, mehr als 320 Tipps & Tricks für Access und VB |
||||||||||||||||||||
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. |