Solved

How to save all contents in a picture box?

Posted on 2002-04-07
5
142 Views
Last Modified: 2010-05-02
I am sorry for my poor English.

I make a legend with some lables, Lines and a frame. And put it into a picture box.

But I can't save the image with the legend.

Could anyone can tell me how to save all the contents in a picture box?

Thanks a lot!
0
Comment
Question by:Jerryleo
  • 2
  • 2
5 Comments
 
LVL 4

Expert Comment

by:RichW
ID: 6923862
Please be more specific.  What do you mean by you "can't save
the image with the legend?"

What exactly are you trying to do?  It sounds like you might
want to use a ListView control.

Are you putting the labels, lines and frame inside the
picturebox at runtime?



0
 

Author Comment

by:Jerryleo
ID: 6923881
I am sorry for my unclear expression.

First, I make a legend with some labels,lines and a frame. All these are putted inside the picturebox at design time.
For example, I put a frame into picture box, then put 5 lables and 5 lines into the frame.

Second, I draw a graphics in a picture box at runtime, such as several bars with different colors.

Then, I use savepicture statement to save the contents of the picture box to image file. It only saves the bars I draw in picture box to a image file.

I want save all contents in the picture box both the graphics and the legend to a image file.

How do I to do?
0
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 15 total points
ID: 6924045
Add your drawing code to this form and do a try:

VERSION 5.00
Begin VB.Form Form1
   Caption         =   "Form1"
   ClientHeight    =   4965
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   7185
   LinkTopic       =   "Form1"
   ScaleHeight     =   4965
   ScaleWidth      =   7185
   StartUpPosition =   3  'Windows Default
   Begin VB.PictureBox Picture2
      AutoRedraw      =   -1  'True
      Height          =   2205
      Left            =   3255
      ScaleHeight     =   2145
      ScaleWidth      =   3000
      TabIndex        =   2
      Top             =   2520
      Width           =   3060
   End
   Begin VB.PictureBox Picture1
      Height          =   2175
      Left            =   720
      ScaleHeight     =   2115
      ScaleWidth      =   3480
      TabIndex        =   0
      Top             =   150
      Width           =   3540
      Begin VB.Label Label1
         Caption         =   "Label1"
         Height          =   450
         Left            =   540
         TabIndex        =   1
         Top             =   615
         Width           =   1215
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

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_Click()
Const PIXEL = 3
      Picture1.ScaleMode = PIXEL
      Picture2.ScaleMode = PIXEL
      hDestDC& = Picture2.hDC
      x& = 0: y& = 0
      nWidth& = Picture2.ScaleWidth
      nHeight& = Picture2.ScaleHeight
      ' Assign information of the source bitmap.
      hSrcDC& = Picture1.hDC
      xSrc& = 0: ySrc& = 0
      ' Assign the SRCCOPY constant to the Raster operation.
      dwRop& = &HCC0020
      Suc& = BitBlt(hDestDC&, x&, y&, nWidth&, nHeight&, hSrcDC&, _
      xSrc&, ySrc&, dwRop&)
      SavePicture Picture2.Image, "c:\test.bmp"
End Sub

0
 

Author Comment

by:Jerryleo
ID: 6943886
Thank you very much.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6944621
You are welcome.
Thanks for "A" grade!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

759 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

18 Experts available now in Live!

Get 1:1 Help Now