Copy picturebox contents to another form

Posted on 2006-04-29
Last Modified: 2010-05-01
Hi Experts
I have a picturebox on a form containing about 20 textboxs and labels.
 How can i copy this to another form? Using vb6
Thank you
Question by:isnoend2001
    LVL 85

    Expert Comment

    by:Mike Tomlinson
    You want to copy the controls to another form?  Or just a ~picture~ of the controls to another form?

    Author Comment

    Thanks for your reply
    I do not need the controls on another form just the picture of the controls with the textboxs and contents
    LVL 85

    Expert Comment

    by:Mike Tomlinson
    It would be something like...

    Option Explicit
    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

    Private Sub Form_Load()
        Me.ScaleMode = vbPixels
    End Sub

    Private Sub Command1_Click()
        Dim f2 As New Form2
        f2.ScaleMode = vbPixels
        f2.Picture1.Width = Me.Picture1.Width
        f2.Picture1.Height = Me.Picture1.Height
        f2.Picture1.BorderStyle = 0 ' none
        f2.Picture1.Appearance = 0 ' flat
        f2.Picture1.AutoRedraw = True
        f2.WindowState = vbMinimized
        BitBlt f2.Picture1.hdc, 0, 0, Picture1.Width, Picture1.Height, Me.Picture1.hdc, 0, 0, vbSrcCopy

        f2.WindowState = vbNormal
    End Sub


    Author Comment

    Hi Idle_mind
    Your example works however it only copies the first 5 letters in the top left label from source picbox  to top left of destination picturebox
    LVL 85

    Accepted Solution

    Make sure you have the ScaleMode of BOTH forms set to vbPixels.

    Author Comment

    I have both set to vbPixels, same problem.
    I have decided I do not need half the info from the first picture Box. I'm just going to manually put put the
    one's i need on the second form and populate them on the 2nd form load. Eg:name, address, job address etc
    Thanks for your response

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    VBA Modification 5 36
    VBA Check for Character 9 63
    Opening Remote & Local Data Connection 2 32
    Put text in a picture ASP.NET C# 2 27
    When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
    You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now