Results 1 to 3 of 3

Thread: Capture Form as bitmap

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    258
    Hey Guys ,

    Anyone know how I can capture a form as a bitmap in code ?

    Thanks ,

    []P
    Visual Basic 6 SP4 on win98se

    QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!

  2. #2
    Guest
    Try this:

    Code:
    Private Declare Function SetForegroundWindow _
    Lib "user32" (ByVal hwnd As Long) As Long
    
    Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, _
      ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    
    Private Const VK_SNAPSHOT = &H2C
    
    
    Public Function SaveScreen(ByVal theFile As String) As Boolean
    On Error Resume Next
    
        Call keybd_event(VK_SNAPSHOT, 0, 0, 0)
        SavePicture Clipboard.GetData(vbCFBitmap), theFile
    
    SaveScreen = True
    Exit Function
    End Function
    
    Usage
    
    
    Private Sub Command1_Click()
    
        SetForegroundWindow Me.hWnd
        Call SaveScreen("C:\Windows\Desktop\MyForm.bmp")
    
    End Sub

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    258
    Hey Matt ,
    Thanks for the response . I'd like to just BitBlt it into a picturebox . Sorry I changed my mind , this way would have less overhead I believe . Although something is wrong with the code below . My goal is to get an image of frm_Main into a picture box that is used as a priview window . It runs all the way though but leaves the picture box empty . Do you see why ?
    Code:
        Picture1.AutoRedraw = True
    
    Dim frmDC As Long
    
    frmDC = frm_Main.hDc
    BitBlt Picture1.hDc, 0, 0, 0, 0, frmDC, 0, 0, SRCCOPY
    Picture1.Refresh
    Am I going about this the right way ?

    []P
    Visual Basic 6 SP4 on win98se

    QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width