Save form to image without load the form.
Save form to image without load the form.
Save form to image without load the form.
Save form to image without load the form.
Save form to image without load the form.
Save form to image without load the form. Save form to image without load the form. Save form to image without load the form. Save form to image without load the form. Save form to image without load the form. Save form to image without load the form. Save form to image without load the form. Save form to image without load the form.
Save form to image without load the form. Save form to image without load the form.
Save form to image without load the form.
Go Back  Xtreme Visual Basic Talk > > > Save form to image without load the form.


Reply
 
Thread Tools Display Modes
  #1  
Old 11-28-2016, 08:43 PM
munirah_malik munirah_malik is offline
Newcomer
 
Join Date: Nov 2016
Posts: 1
Default Save form to image without load the form.


Hi all. I want to save form image to file on form load. When I call command1_Click on form load. the image not save correctly. only blank picture capture. Do you know why? I used vb6.

Code:
Private Sub Form_Load()
Call Command1_Click
End Sub
Code:
Private Sub Command1_Click()
  SaveFormImageToFile frmSaveFormImageToFile, Picture1, "C:\Temp.bmp"
End Sub
Code:
Public Sub SaveFormImageToFile(ByRef ContainerForm As Form, ByRef PictureBoxControl As PictureBox, ByVal ImageFileName As String)
  Dim FormInsideWidth As Long
  Dim FormInsideHeight As Long
  Dim PictureBoxLeft As Long
  Dim PictureBoxTop As Long
  Dim PictureBoxWidth As Long
  Dim PictureBoxHeight As Long
  Dim FormAutoRedrawValue As Boolean
  
  With PictureBoxControl
    'Set PictureBox properties
    .Visible = False
    .AutoRedraw = True
    .Appearance = 0 ' Flat
    .AutoSize = False
    .BorderStyle = 0 'No border
    
    'Store PictureBox Original Size and location Values
    PictureBoxHeight = .Height: PictureBoxWidth = .Width: PictureBoxLeft = .Left: PictureBoxTop = .Top
    
    'Make PictureBox to size to inside of form.
    .Align = vbAlignTop: .Align = vbAlignLeft
    DoEvents
    
    FormInsideHeight = .Height: FormInsideWidth = .Width
    
    'Restore PictureBox Original Size and location Values
    .Align = vbAlignNone
    .Height = FormInsideHeight: .Width = FormInsideWidth: .Left = PictureBoxLeft: .Top = PictureBoxTop
    
    FormAutoRedrawValue = ContainerForm.AutoRedraw
    ContainerForm.AutoRedraw = False
    DoEvents
    
    'Copy Form Image to Picture Box
    BitBlt .hDC, 0, 0, FormInsideWidth / Screen.TwipsPerPixelX, FormInsideHeight / Screen.TwipsPerPixelY, ContainerForm.hDC, 0, 0, vbSrcCopy
    DoEvents
    SavePicture .Image, ImageFileName
    DoEvents
    
    ContainerForm.AutoRedraw = FormAutoRedrawValue
    DoEvents
  End With
End Sub
Reply With Quote
  #2  
Old 11-29-2016, 06:42 AM
Flyguy's Avatar
FlyguySave form to image without load the form. Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 19,164
Default

In the Form_Load event the Form has not been painted yet, so calling the Command1_Click will save an empty picture
Reply With Quote
Reply

Tags
form, dim, picturebox, doevents, forminsideheight, image, forminsidewidth, save, false, .align, containerform.autoredraw, .width, .height, formautoredrawvalue, size, pictureboxtop, pictureboxleft, load, command1_click, call, pictureboxwidth, imagefilename, picture, pictureboxheight, .top


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Save form to image without load the form.
Save form to image without load the form.
Save form to image without load the form. Save form to image without load the form.
Save form to image without load the form.
Save form to image without load the form.
Save form to image without load the form. Save form to image without load the form. Save form to image without load the form. Save form to image without load the form. Save form to image without load the form. Save form to image without load the form. Save form to image without load the form.
Save form to image without load the form.
Save form to image without load the form.
 
Save form to image without load the form.
Save form to image without load the form.
 
-->