vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
Erstellen von dynamischen Kontextmen?s - wann immer Sie sie brauchen!  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2025
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

Visual-Basic Einsteiger
Re: Formular ausdrucken lassen 
Autor: scorpy
Datum: 08.01.06 20:27

also gut... mein code sieht jetzt so aus:
Option Explicit
 
' benötigte API - Deklaration
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 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
 
Private Declare Function CreateFontIndirect Lib "gdi32" _
  Alias "CreateFontIndirectA" ( _
  lpLogFont As LOGFONT) As Long
 
Private Declare Function MulDiv Lib "kernel32.dll" ( _
  ByVal nNumber As Long, _
  ByVal nNumerator As Long, _
  ByVal nDenominator As Long) As Long
 
Private Declare Function GetDeviceCaps Lib "gdi32" ( _
  ByVal hdc As Long, ByVal nIndex As Long) As Long
 
' Konstanten
Private Const LF_FACESIZE = 32
Private Const DEFAULT_CHARSET = 1
Private Const ANTIALIASED_QUALITY = 4
Private Const FW_NORMAL = 400
Private Const FW_BOLD = 700
Private Const OUT_TT_PRECIS = 4
Private Const VARIABLE_PITCH = 2
Private Const LOGPIXELSY = 90
 
' FONT-Struktur
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
' Text in beliebigem Winkel ausdrucken
' z.B. auf dem Drucker oder auch in eine PictureBox
Public Sub PrintRotatedText(ByRef oPrinter As Object, _
  ByVal nPosX As Long, _
  ByVal nPosY As Long, _
  ByVal sText As String, _
  Optional ByVal nWinkel As Long = 0, _
  Optional ByVal nSize As Variant, _
  Optional ByVal bBold As Variant, _
  Optional ByVal bItalic As Variant, _
  Optional ByVal bUnderline As Variant, _
  Optional ByVal sFontName As Variant)
 
  Dim hdc As Long
  Dim hFontOld As Long
  Dim nRetVal As Long
  Dim hFont As Long
  Dim oFont As LOGFONT
 
  ' falls optionale Parameter nicht angegeben,
  ' Standard-Werte verwenden
  With oPrinter.Font
    If IsMissing(nSize) Then nSize = .Size
    If IsMissing(bBold) Then bBold = .Bold
    If IsMissing(bItalic) Then bItalic = .Italic
    If IsMissing(bUnderline) Then bUnderline = .Underline
    If IsMissing(sFontName) Then sFontName = .Name
  End With
 
  ' Position in Pixel umrechnen
  With oPrinter
    hdc = .hdc
    nPosX = .ScaleX(nPosX, .ScaleMode, vbPixels)
    nPosY = .ScaleY(nPosY, .ScaleMode, vbPixels)
  End With
 
  ' Neues Font-Objekt erstellen
  With oFont
    .lfHeight = -MulDiv(nSize, GetDeviceCaps(hdc, LOGPIXELSY), 72)
    .lfEscapement = CLng(nWinkel * 10)
    .lfWeight = IIf(bBold, FW_BOLD, FW_NORMAL)
    .lfItalic = Abs(bItalic)
    .lfUnderline = Abs(bUnderline)
    .lfCharSet = DEFAULT_CHARSET
    .lfFaceName = sFontName
    .lfOutPrecision = OUT_TT_PRECIS
    .lfQuality = ANTIALIASED_QUALITY
    .lfPitchAndFamily = VARIABLE_PITCH
  End With
  hFont = CreateFontIndirect(oFont)
  hFontOld = SelectObject(hdc, hFont)
 
  ' Text ausgeben
  Call TextOut(hdc, nPosX, nPosY, sText, Len(sText))
 
  ' Ursprüngliche Schrift wiederherstellen
  Call SelectObject(hdc, hFontOld)
 
  ' Objekte zerstören
  Call DeleteObject(hFont)
End Sub
 
 
 
Private Sub cmdNEU_Click()
cmdPRINT.Visible = True
 
End Sub
 
Private Sub cmdPRINT_Click()
cmdPRINT.Visible = False
 
' Text im Winkel von 180° auf Drucker ausgeben
Printer.ScaleMode = vbMillimeters
Printer.Print
PrintRotatedText Printer, 20, 50, txtVName.Text, 180
Printer.EndDoc
End Sub
 
Private Sub Form_Load()
cmdNEU.Visible = False
 
End Sub
..so..und jetzt weiß ich net weiter...
wie kann ich das alles in den text einfügen...den ich im ersten beitrag geschreiben habe?
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Formular ausdrucken lassen904scorpy08.01.06 19:08
Re: Formular ausdrucken lassen469ModeratorDieter08.01.06 19:11
Re: Formular ausdrucken lassen528scorpy08.01.06 19:41
Re: Formular ausdrucken lassen447scorpy08.01.06 20:27
Re: Formular ausdrucken lassen446scorpy09.01.06 14:21
Re: Formular ausdrucken lassen449Desatrous10.01.06 11:20
Re: Formular ausdrucken lassen447scorpy10.01.06 16:44
Re: Formular ausdrucken lassen442scorpy10.01.06 18:22
Re: Formular ausdrucken lassen432Desatrous11.01.06 08:16
Re: Formular ausdrucken lassen428scorpy11.01.06 15:40
Re: Formular ausdrucken lassen410Sanny11.01.06 15:52
Re: Formular ausdrucken lassen421Desatrous11.01.06 15:55
Re: Formular ausdrucken lassen445scorpy11.01.06 16:28
Re: Formular ausdrucken lassen433scorpy11.01.06 16:36
Re: Formular ausdrucken lassen430Desatrous12.01.06 08:13
Re: Formular ausdrucken lassen432scorpy12.01.06 16:38
Re: Formular ausdrucken lassen435Desatrous13.01.06 09:12
Re: Formular ausdrucken lassen720scorpy09.01.06 16:11

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2025 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
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.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel