Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to save all contents in a picture box?

Posted on 2002-04-07
5
Medium Priority
?
152 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 60 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

670 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