• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 156
  • Last Modified:

How to save all contents in a picture box?

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
Jerryleo
Asked:
Jerryleo
  • 2
  • 2
1 Solution
 
RichWCommented:
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
 
JerryleoAuthor Commented:
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
 
Richie_SimonettiIT OperationsCommented:
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
 
JerryleoAuthor Commented:
Thank you very much.
0
 
Richie_SimonettiIT OperationsCommented:
You are welcome.
Thanks for "A" grade!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now