Results 1 to 2 of 2

Thread: Save a form's face as an image file

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2001
    Posts
    57

    Red face Save a form's face as an image file

    It is easy to print a form's details directly by printer:

    Printer.Print Form1

    How about saving it as an image (BMP or JPG) file ?

    I have a SaveScreen function but it also save the title bar of an active window.

    Pls help...

  2. #2
    Megatron
    Guest
    Use the function: What is does is copy the Form's DC to a PictureBox, then we save it by calling the SavePicture function.

    Make sure that the PictureBox (in the pBox argument) is invisible.
    VB Code:
    1. Private 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
    2.  
    3. Sub SaveScreen(vFrm As Form, pBox As PictureBox, sFileName As String)
    4.     Dim iWidth As Integer, iHeight As Integer
    5.    
    6.     pBox.Visible = False
    7.     pBox.AutoRedraw = True
    8.     vFrm.AutoRedraw = False
    9.     pBox.Move 0, 0, vFrm.ScaleWidth, vFrm.ScaleHeight
    10.     iHeight = vFrm.ScaleHeight / Screen.TwipsPerPixelY
    11.     iWidth = vFrm.ScaleWidth / Screen.TwipsPerPixelX
    12.     BitBlt pBox.hDC, 0, 0, iWidth, iHeight, vFrm.hDC, 0, 0, vbSrcCopy
    13.     SavePicture pBox.Image, sFileName
    14. End Sub
    And you would call it like:
    VB Code:
    1. SaveScreen Form1, Picture1, "C:\MyFile.bmp"

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