Solved

How to save all contents in a picture box?

Posted on 2002-04-07
5
145 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB error "Type mismatch" 2 60
Visual Basic Excel Formatting error 4 127
Question about INSTR  - need to extract data MS ACCESS query 6 59
Export Data to Different .csv Files 26 114
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

839 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