Amnon
asked on
Copy picture between applications
Hi,
I have two VB applications.
Both have picture box with picture inside and the AutoRedraw property is true.
I want that one application will copy its picture to the other (I have the destination picture box hWnd).
I'm doing the following:
DesDC = GetDC(DestHwnd)
BitBlt(DestHwnd, 0, 0, 1000, 1000, SourceDC, 0, 0, SRCCOPY)
The result is that the picture was copied but after moving
some window above the destination picture box is presenting
the old picture (not the one that I copied),
It's just like the AutoRedraw property of the destination
picture box is false (altough it was set to true).
Does anyone know how to copy the picture so the AutoRedraw will present the new picture and not the previous one ?
Thanks.
I have two VB applications.
Both have picture box with picture inside and the AutoRedraw property is true.
I want that one application will copy its picture to the other (I have the destination picture box hWnd).
I'm doing the following:
DesDC = GetDC(DestHwnd)
BitBlt(DestHwnd, 0, 0, 1000, 1000, SourceDC, 0, 0, SRCCOPY)
The result is that the picture was copied but after moving
some window above the destination picture box is presenting
the old picture (not the one that I copied),
It's just like the AutoRedraw property of the destination
picture box is false (altough it was set to true).
Does anyone know how to copy the picture so the AutoRedraw will present the new picture and not the previous one ?
Thanks.
I don't understand your question...
First application does the Command1 code
Second application does the Command2 code
Private Sub Command1_Click()
Clipboard.SetData Picture1.Picture
End Sub
Private Sub Command2_Click()
Picture2.Picture = Clipboard.GetData
End Sub
Second application does the Command2 code
Private Sub Command1_Click()
Clipboard.SetData Picture1.Picture
End Sub
Private Sub Command2_Click()
Picture2.Picture = Clipboard.GetData
End Sub
ASKER
I've tried this before but it was too slow.
I have to pass many picture between those applications
(one application is connected to a camera) and each picture
is about 0.5 MB and need to be stretched in the destination
applications.
I want economize the time it takes to pass the picture to
the clipboard and from the clipboard and copy the picture
directly to the destination.
I have to pass many picture between those applications
(one application is connected to a camera) and each picture
is about 0.5 MB and need to be stretched in the destination
applications.
I want economize the time it takes to pass the picture to
the clipboard and from the clipboard and copy the picture
directly to the destination.
That will hardly be faster...
I don't know exactly what you are doing, but this is a method I've tried and it works!
In app 1 you have a picturebox(no borders, autoredraw set to true), and a CommandButton.
In app2 you have a picturebox(same properties as above, but with a picture).
During app2 activation, Debug.Print Picture1.hDC, run the program.
Remember the hdc in the debug window, and then goto App 1, Command1_Click.
Type this:
BitBlt Picture1.hDC, 0, 0, 100, 100, [Debug's hdc goes here...], 0, 0, vbSrcCopy
Picture1.Refresh
This should copy the picture from App2 to App1
In app 1 you have a picturebox(no borders, autoredraw set to true), and a CommandButton.
In app2 you have a picturebox(same properties as above, but with a picture).
During app2 activation, Debug.Print Picture1.hDC, run the program.
Remember the hdc in the debug window, and then goto App 1, Command1_Click.
Type this:
BitBlt Picture1.hDC, 0, 0, 100, 100, [Debug's hdc goes here...], 0, 0, vbSrcCopy
Picture1.Refresh
This should copy the picture from App2 to App1
passing hdc between application works.
Well not on my machine (NT)
Well not on my machine (NT)
ASKER
BabyFace hello,
Your method wotks only if app#1 copy the picture from app#2
to its own PictureBox but not if app#1 copy its picture
to app#2 PictureBox as I need.
Thanks.
Your method wotks only if app#1 copy the picture from app#2
to its own PictureBox but not if app#1 copy its picture
to app#2 PictureBox as I need.
Thanks.
What about saving the picture from the first app in a common (shared) path and then loading it into your second app from file?
ASKER
SLE Hello,
This option is much to slow, the picture is coming from
camera and should,sometimes, be updated a few time in one second while other processes runing in background.
Thanks
This option is much to slow, the picture is coming from
camera and should,sometimes, be updated a few time in one second while other processes runing in background.
Thanks
If you know the hdc of the picturebox in app #2, you can do this from app #1:
BitBlt [Debug's hdc goes here...], 0, 0, 100, 100, Picture2.hDC, 0, 0, vbSrcCopy
BitBlt [Debug's hdc goes here...], 0, 0, 100, 100, Picture2.hDC, 0, 0, vbSrcCopy
why don't u use the capture screen (or a prefixed area of the screen) to a temp file and load it from the second app?
ASKER
If I'll do the following :
BitBlt [Debug's hdc goes here...], 0, 0, 100, 100, Picture2.hDC, 0, 0, vbSrcCopy
The picture will be copied but if I'll move another window
above it, the picture will be deleted even if
AutoRedraw = True.
BitBlt [Debug's hdc goes here...], 0, 0, 100, 100, Picture2.hDC, 0, 0, vbSrcCopy
The picture will be copied but if I'll move another window
above it, the picture will be deleted even if
AutoRedraw = True.
ASKER
If I'll do the following :
BitBlt [Debug's hdc goes here...], 0, 0, 100, 100, Picture2.hDC, 0, 0, vbSrcCopy
The picture will be copied but if I'll move another window
above it, the picture will be deleted even if
AutoRedraw = True.
I need to copy the picture to the Background image (or someything like that) of the picture box, in this way
every paint event of the picture box will paint the copied
picture.
BitBlt [Debug's hdc goes here...], 0, 0, 100, 100, Picture2.hDC, 0, 0, vbSrcCopy
The picture will be copied but if I'll move another window
above it, the picture will be deleted even if
AutoRedraw = True.
I need to copy the picture to the Background image (or someything like that) of the picture box, in this way
every paint event of the picture box will paint the copied
picture.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.