Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 11
  1. #1

    [VB6] - Testo in una picture

    Ciao ragazzi, salve moderatori.

    ho rappresentato in una picture un rettangolo usando linee.

    Ho bisogno di inserire del testo nella picture ma non vorrei usare le label.
    Questo testo dovrebbe essere scritto in orizzontale ma anche in verticale.

    qualcuno mi può aiutare ?
    grazie anticipatamente.

  2. #2
    girando su internet ho trovato che è possibile scrivere un testo in una picture usando
    questa API:


    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


    ... ma non so usare le API!!!

    help!!

  3. #3
    Finché il testo è in orizzontale puoi usare tranquillamente il metodo Print.
    codice:
    Picture1.Print "Ciao"
    Amaro C++, il gusto pieno dell'undefined behavior.

  4. #4
    ciao Mitaly,

    L'ho provato su una picture nuova ma non visualizzo nulla.
    E cmq il testodovrebbe essere anche ruotato.

  5. #5
    In che evento hai inserito quel codice?
    Amaro C++, il gusto pieno dell'undefined behavior.

  6. #6
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,480
    AutoRedraw della picture deve essere True
    No MP tecnici (non rispondo nemmeno!), usa il forum.

  7. #7
    si, oregon,
    me ne ero scordato, avevo provveduto.

    comunque il problema di scrivere il testo ruotato (es. di un angolo a piacere) rimane

  8. #8
    Ho trovato questo codice in internet:


    ----------------------------------------------------------
    Option Explicit

    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

    Private Type DOCINFO
    cbSize As Long
    lpszDocName As String
    lpszOutput As String
    lpszDatatype As String
    fwType As Long
    End Type

    Private Declare Function CreateFontIndirect Lib "gdi32" Alias _
    "CreateFontIndirectA" (lpLogFont As LOGFONT) As Long

    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 CreateDC Lib "gdi32" Alias "CreateDCA" _
    (ByVal lpDriverName As String, ByVal lpDeviceName As String, _
    ByVal lpOutput As Long, ByVal lpInitData As Long) As Long

    Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc 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 Declare Function StartDoc Lib "gdi32" Alias "StartDocA" _
    (ByVal hdc As Long, lpdi As DOCINFO) As Long

    Private Declare Function EndDoc Lib "gdi32" (ByVal hdc As Long) _
    As Long

    Private Declare Function StartPage Lib "gdi32" (ByVal hdc As Long) _
    As Long

    Private Declare Function EndPage Lib "gdi32" (ByVal hdc As Long) _
    As Long

    Const DESIREDFONTSIZE = 12 ' Could use variable, TextBox, etc.

    Private Sub Command1_Click()
    ' Combine API Calls with the Printer object
    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 = "Hello World"

    lf.lfEscapement = 1800
    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()
    ' Print using API calls only
    Dim OutString As String 'String to be rotated
    Dim lf As LOGFONT 'Structure for setting up rotated font
    Dim temp As String 'Temp string var
    Dim result As Long 'Return value for calling API functions
    Dim hOldfont As Long 'Hold old font information
    Dim hPrintDc As Long 'Handle to printer dc
    Dim hFont As Long 'Handle to new Font
    Dim di As DOCINFO 'Structure for Print Document info

    OutString = "Hello World" 'Set string to be rotated

    ' Set rotation in tenths of a degree, i.e., 1800 = 180 degrees
    lf.lfEscapement = 1800
    lf.lfHeight = (DESIREDFONTSIZE * -20) / Printer.TwipsPerPixelY
    hFont = CreateFontIndirect(lf) 'Create the rotated font
    di.cbSize = 20 ' Size of DOCINFO structure
    di.lpszDocName = "My Document" ' Set name of print job (Optional)

    ' Create a printer device context
    hPrintDc = CreateDC(Printer.DriverName, Printer.DeviceName, 0, 0)

    result = StartDoc(hPrintDc, di) 'Start a new print document
    result = StartPage(hPrintDc) 'Start a new page

    ' Select our rotated font structure and save previous font info
    hOldfont = SelectObject(hPrintDc, hFont)

    ' Send rotated text to printer, starting at location 1000, 1000
    result = TextOut(hPrintDc, 1000, 1000, OutString, Len(OutString))

    ' Reset font back to original, non-rotated
    result = SelectObject(hPrintDc, hOldfont)

    ' Send non-rotated text to printer at same page location
    result = TextOut(hPrintDc, 1000, 1000, OutString, Len(OutString))

    result = EndPage(hPrintDc) 'End the page
    result = EndDoc(hPrintDc) 'End the print job
    result = DeleteDC(hPrintDc) 'Delete the printer device context
    result = DeleteObject(hFont) 'Delete the font object
    End Sub

    Private Sub Form_Load()
    Command1.Caption = "API with Printer object"
    Command2.Caption = "Pure API"
    End Sub
    ---------------------------------------------------------

    che usa la gdi32.dll e stampa un testo ruotato sulla stampante.
    Se lo "manometto" si può trasformare per la mia picture

    qualche aiuto, suggerimento??

  9. #9
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,480
    No MP tecnici (non rispondo nemmeno!), usa il forum.

  10. #10
    mm,

    misa che ci siamo.

    lo provo e vi faccio sapere.
    per ora grazie.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.