From: Martin Trump on

> I could think of three issues with the code you posted:
>
> 1 - It would erase the clipboard, and this may annoy the user.

Accepted but you could save and restore it if necessary.

> 2 - The code you posted would capture the active window only, while the
> BitBlt method would capture any window unless it's obscured by other
> windows, in which case it captures the area in the desktop that it would
> usually occupy.

Yes, but I did say it could be adapted. Just omit the ALT stuff.

> 3 - You need to use "Set" with any object assignment, so use "Set
> pic2.Picture = Clipboard.GetData()".

Really? pic2.Picture = Clipboard.GetData() seems to work for me.
Am I deluding myself? Often happens, I'm no expert :-)

From: H-Man on
On Fri, 20 Nov 2009 09:23:17 +0000, Dee Earley wrote:

> On 20/11/2009 02:04, VbPro7 wrote:
>> Hi VB lovers,
>>
>> I'm using the following code to get a snapshot of the screen in a
>> StdPicture object.
>>
>> http://www.devx.com/vb2themax/Tip/19172
>>
>> However my problem is I need to get the space used (no of bytes) by the
>> image in memory. Is this possible? If not I would like to convert the
>> image into a JPG file and then get the size of file in bytes.
>> Size itself is not required actually. I just want to compare two images
>> and see if they are the same. The only way I can think of is to compare
>> there size/space in memory or disk. If there is another efficient way to
>> do this please advise.
>
> No, you can not relay on size to determine if they are the same.
> Nor can you rely on different (non bitmap) binary data to say they are
> different.
>
> Bitmaps in memory are a fixed (height x width x bytes per pixel) +
> header (with a few caveats for odd sizes and bit depths)
> Once compressed, the final image data may contain other data so you are
> unlikely to get exactly the same data for multiple encodes of the same
> image.
>
> The only way to reliably tell is to do a pixel by pixel comparison.
> If the images will have been subject to lossy compression, you will have
> to have a tolerance in there as well.
>
> What are you actually trying to achieve by seeing if the screen has changed?

right, size alone won't tell you anything for sure. That's what a ahsh
function is for. Using a simple CRC32 function on the two data sets would
tell you pretty much right away if the data is the same.


--
HK
From: Peter T on
"Martin Trump" <martin(a)wmeadow.demon.co.uk> wrote in message

>> 3 - You need to use "Set" with any object assignment, so use "Set
>> pic2.Picture = Clipboard.GetData()".
>
> Really? pic2.Picture = Clipboard.GetData() seems to work for me.

Yes both w/out Set work for me, in VBA too. I've never quite understood why.

Regards,
Peter T



From: Nobody on
"Peter T" <peter_t(a)discussions> wrote in message
news:%23V0DEoObKHA.4688(a)TK2MSFTNGP06.phx.gbl...
> "Martin Trump" <martin(a)wmeadow.demon.co.uk> wrote in message
>
>>> 3 - You need to use "Set" with any object assignment, so use "Set
>>> pic2.Picture = Clipboard.GetData()".
>>
>> Really? pic2.Picture = Clipboard.GetData() seems to work for me.
>
> Yes both w/out Set work for me, in VBA too. I've never quite understood
> why.

Looking at Object Browser(F2), the default property for both is "Handle". So
that line is equivalent to:

pic2.Picture.Handle = Clipboard.GetData().Handle


From: Peter T on

"Nobody" <nobody(a)nobody.com> wrote in message news:%
> "Peter T" <peter_t(a)discussions> wrote in message
>> "Martin Trump" <martin(a)wmeadow.demon.co.uk> wrote in message
>>
>>>> 3 - You need to use "Set" with any object assignment, so use "Set
>>>> pic2.Picture = Clipboard.GetData()".
>>>
>>> Really? pic2.Picture = Clipboard.GetData() seems to work for me.
>>
>> Yes both w/out Set work for me, in VBA too. I've never quite understood
>> why.
>
> Looking at Object Browser(F2), the default property for both is "Handle".
> So that line is equivalent to:
>
> pic2.Picture.Handle = Clipboard.GetData().Handle

AhHa, similar in VBA
MSForms.Image.Picture - Property Picture As StdPicture
StdPicture.Handle As OLE_HANDLE
Default member of stdole.StdPicture

Intuitively I guess .Handle = .Handle is a tad more efficient. Or is it, any
reason to use or not use Set?

Regards,
Peter T