• User

    Salvare la schermata in file jpg

    Ciao a tutto il forum,
    programmo in vb.net ed avrei la necessità di salvare la schermata del desktop in un file jpg quando si preme un button, ma non so proprio da dove potrei iniziare.
    Potete aiutarmi ?


  • Super User

    Trovato online:

    DECLARES:
    Public Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
    
    Public Declare Function BitBlt Lib "gdi32" (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
    
    Public Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal
    hdc As Long) As Long
    
    CODE:
    
      Dim x As Integer, y As Integer, nWidth As Integer, nHeight As Integer
      Dim dwRop As Long, hSrcDC As Long, hDestDC As Long
      Dim strFName As String
    
        Dim strTime As String ' part of the file name
        strTime = Replace(Now, "/", "_")
        strTime = Replace(strTime, ":", "_")
        strTime = Replace(strTime, " ", "_")
        Picture1.Width = Screen.Width
        Picture1.Height = Screen.Height
       
        strFName = "Peek_pic" & strTime & ".bmp"
        Let nWidth = Screen.Width
        Let nHeight = Screen.Height
        Let dwRop = SRCCOPY
        Let hDestDC = Picture1.hdc
        Let hSrcDC = GetDC(0)
        Call BitBlt(hDestDC, 0, 0, nWidth, nHeight, hSrcDC, 0, 0, dwRop)
        Call ReleaseDC(0, hSrcDC)
        Picture1.FontName = "Tahoma"
        Picture1.FontSize = "16.5"
        Picture1.FontBold = True
        Picture1.Print Date & " " & Time
        SavePicture Picture1.Image, App.Path & "\" & strFName 
    

  • Super User

    Trovato online:

    DECLARES:
    Public Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
    
    Public Declare Function BitBlt Lib "gdi32" (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
    
    Public Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal
    hdc As Long) As Long
    
    CODE:
    
      Dim x As Integer, y As Integer, nWidth As Integer, nHeight As Integer
      Dim dwRop As Long, hSrcDC As Long, hDestDC As Long
      Dim strFName As String
    
        Dim strTime As String ' part of the file name
        strTime = Replace(Now, "/", "_")
        strTime = Replace(strTime, ":", "_")
        strTime = Replace(strTime, " ", "_")
        Picture1.Width = Screen.Width
        Picture1.Height = Screen.Height
       
        strFName = "Peek_pic" & strTime & ".bmp"
        Let nWidth = Screen.Width
        Let nHeight = Screen.Height
        Let dwRop = SRCCOPY
        Let hDestDC = Picture1.hdc
        Let hSrcDC = GetDC(0)
        Call BitBlt(hDestDC, 0, 0, nWidth, nHeight, hSrcDC, 0, 0, dwRop)
        Call ReleaseDC(0, hSrcDC)
        Picture1.FontName = "Tahoma"
        Picture1.FontSize = "16.5"
        Picture1.FontBold = True
        Picture1.Print Date & " " & Time
        SavePicture Picture1.Image, App.Path & "\" & strFName