Visualizzazione dei risultati da 1 a 5 su 5
  1. #1

    [vb6]

    salve ragazzi, ciao moderatori,

    qualcuno mi sa dire come posso copiare il contenuto di un form (non attivo e neanche visibile sullo schermo) nella clipboard, possibilmente senza barra del titolo?

    grazie a tutti

  2. #2
    sto diventando matto,

    ho scritto questo codice:


    -------------
    Public Sub PutFormInClipboard()
    Dim lHeight As Long
    Clipboard.Clear
    Call keybd_event(VK_SNAPSHOT, 1, 0, 0)
    DoEvents
    Call keybd_event(VK_SNAPSHOT, 1, KEYEVENTF_KEYUP, 0)

    End Sub
    -----------------

    ma non riesco a copiare il contenuto del form che voglio io.

  3. #3
    Utente di HTML.it L'avatar di MMarzia
    Registrato dal
    Mar 2001
    Messaggi
    1,781
    e il titolo?
    io sono festosamente cicciottello :: e. cartman

    t'amo senza sapere come, nè quando nè da dove,
    t'amo direttamente senza problemi nè orgoglio:
    così ti amo perchè non so amare altrimenti

  4. #4

    acc...

    il titolo è:

    [vb6] copiare un form nella clipboard.

  5. #5
    Sto usando il seguente codice:

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

    Private Const CCHDEVICENAME = 32
    Private Const CCHFORMNAME = 32
    Private Const SRCCOPY = &HCC0020 ' (DWORD) destination = source

    Private Type DEVMODE
    dmDeviceName As String * CCHDEVICENAME
    dmSpecVersion As Integer
    dmDriverVersion As Integer
    dmSize As Integer
    dmDriverExtra As Integer
    dmFields As Long
    dmOrientation As Integer
    dmPaperSize As Integer
    dmPaperLength As Integer
    dmPaperWidth As Integer
    dmScale As Integer
    dmCopies As Integer
    dmDefaultSource As Integer
    dmPrintQuality As Integer
    dmColor As Integer
    dmDuplex As Integer
    dmYResolution As Integer
    dmTTOption As Integer
    dmCollate As Integer
    dmFormName As String * CCHFORMNAME
    dmUnusedPadding As Integer
    dmBitsPerPel As Long
    dmPelsWidth As Long
    dmPelsHeight As Long
    dmDisplayFlags As Long
    dmDisplayFrequency As Long
    End Type

    'API
    Private Declare Function ReleaseDC Lib "user32.dll" (ByVal hWnd As Long, ByVal hdc As Long) As Long
    Private Declare Function OpenClipboard Lib "user32.dll" (ByVal hWnd As Long) As Long
    Private Declare Function EmptyClipboard Lib "user32.dll" () As Long
    Private Declare Function SetClipboardData Lib "user32.dll" (ByVal wFormat As Long, ByVal hMem As Long) As Long
    'if you have problems with this function add the Alias "SetClipboardDataA"
    Private Declare Function CloseClipboard Lib "user32.dll" () As Long
    Private Declare Function SelectObject Lib "gdi32.dll" (ByVal hdc As Long, ByVal hObject As Long) As Long
    Private Declare Function DeleteDC Lib "gdi32.dll" (ByVal hdc As Long) As Long
    Private Declare Function BitBlt Lib "gdi32.dll" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    Private Declare Function CreateDC Lib "gdi32.dll" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, lpInitData As DEVMODE) As Long
    Private Declare Function CreateCompatibleBitmap Lib "gdi32.dll" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
    Private Declare Function CreateCompatibleDC Lib "gdi32.dll" (ByVal hdc As Long) As Long

    'Screen Capture Procedure, coordinates are expressed in pixels
    Public Sub CaptureScreen(Left As Long, Top As Long, Width As Long, Height As Long)
    Dim srcDC As Long
    Dim trgDC As Long
    Dim BMPHandle As Long
    Dim dm As DEVMODE

    srcDC = CreateDC("DISPLAY", "", "", dm)
    trgDC = CreateCompatibleDC(srcDC)
    BMPHandle = CreateCompatibleBitmap(srcDC, Width, Height)
    SelectObject trgDC, BMPHandle
    BitBlt trgDC, 0, 0, Width, Height, srcDC, Left, Top, SRCCOPY
    OpenClipboard Screen.ActiveForm.hWnd
    EmptyClipboard
    SetClipboardData 2, BMPHandle
    CloseClipboard
    DeleteDC trgDC
    ReleaseDC BMPHandle, srcDC
    End Sub

    'Usage: how to capture the entire screen
    'Private Sub Command1_Click()
    ' Form1.Visible = False
    ' CaptureScreen 0, 0, 800, 600
    ' Form1.Visible = True
    ' Picture1 = Clipboard.GetData()
    'End Sub

    'Usage: how to capture a form
    'Private Sub Command2_Click()
    ' CaptureScreen Form1.Left \ Screen.TwipsPerPixelX, Form1.Top \ Screen.TwipsPerPixelY, Form1.Width \ Screen.TwipsPerPixelX, Form1.Height \ Screen.TwipsPerPixelY
    ' Picture1 = Clipboard.GetData()
    'End Sub
    ----------------

    ma non funziona se non visualizzo prima il form a scherm; ma questo non lo posso fare perché il form non si deve vedere a schermo (è un form di preview e non va visto).

    Qualcuno può aiutarmi!?

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.