Solved

save my own picture in file

Posted on 2001-06-11
4
167 Views
Last Modified: 2010-05-02
hi
as you know we can use BitBlt function to get capture from Dc to other Dc.
how i can save the new image whitch i capture it , to the file.
for examp:
Myret=bitblt(picture1.hdc,0,0,100,100,getdc(0),0,0,DropFlag)

when i write

SavePicture Picture1.Picture, "c:\mypic.bmp"

compiler say
thier is no picture

0
Comment
Question by:issamtaher
  • 3
4 Comments
 
LVL 38

Accepted Solution

by:
PaulHews earned 100 total points
ID: 6178864
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 Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long

Private Sub Command1_Click()
    Dim myret As Long
    Picture1.AutoRedraw = True
    myret = BitBlt(Picture1.hDC, 0, 0, 100, 100, GetDC(0), 0, 0, vbSrcCopy)
    Debug.Print myret
    Picture1.Refresh
    SavePicture Picture1.Image, "C:\windows\desktop\test.bmp"
End Sub

0
 
LVL 38

Expert Comment

by:PaulHews
ID: 6178911
The AutoRedraw is the important thing here.  It creates a persistent memory bitmap (necessary for valid picture object) when drawing operations are performed on the DC.
0
 
LVL 1

Author Comment

by:issamtaher
ID: 6178914
thank you for heilping me
yours issam taher
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 6178940
You're welcome
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…

809 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