From: Martin Trump on
> I'm using the following code to get a snapshot of the screen in a
> StdPicture object.
>
> http://www.devx.com/vb2themax/Tip/19172

Wow! What a chunk of code!

I think this fragment I have used could be adapted to your needs.

Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte,
ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

AppActivate getaviname
keybd_event vbKeyMenu, 0, 0, 0 ' Press ALT
keybd_event vbKeySnapshot, 0, 0, 0 ' Press Prntscr
keybd_event vbKeySnapshot, 0, 2, 0 ' Release Prntscr
keybd_event vbKeyMenu, 0, 2, 0 'Release ALT
pic2.Picture = Clipboard.GetData()
etc.
then save the picture

> 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.

Comparing sizes of JPG's might be risky unless you know the level of
compression of each is the same.

HTH
From: Nobody on
"Martin Trump" <martin(a)wmeadow.demon.co.uk> wrote in message
news:6yaOm.25276$tF6.15319(a)newsfe28.ams2...
>> http://www.devx.com/vb2themax/Tip/19172
>
> Wow! What a chunk of code!
>
> I think this fragment I have used could be adapted to your needs.
>
> Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal
> bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
>
> AppActivate getaviname
> keybd_event vbKeyMenu, 0, 0, 0 ' Press ALT
> keybd_event vbKeySnapshot, 0, 0, 0 ' Press Prntscr
> keybd_event vbKeySnapshot, 0, 2, 0 ' Release Prntscr
> keybd_event vbKeyMenu, 0, 2, 0 'Release ALT
> pic2.Picture = Clipboard.GetData()
> etc.
> then save the picture

I could think of three issues with the code you posted:

1 - It would erase the clipboard, and this may annoy the user.

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.

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


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: Dave O. on

"Martin Trump" <martin(a)wmeadow.demon.co.uk> wrote in message
news:bJcOm.130761$9M4.112296(a)newsfe03.ams2...
>
>> 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.

If you knew how difficult that might be you would not say that.

The clipboard can contain the same information in several formats all of
which you would need to store and replace, for example a selection of a
Excel spreadsheet is stored in the clipboard as ALL of the following
clipboard formats:

Biff, Biff3, BIFF4, Biff5, Biff8, Bitmap, Csv, Data Interchange Format,
DataObject, Device Independent Bitmap, Embed Source, Enhanced Metafile, HTML
Format, Hyperlink, Link, Link Source, Link Source Descriptor, Locale
Identifier, Metafile, Microsoft Symbolic Link, Native, Object Descriptor,
ObjectLink, OEM Text, Ole Private Data, OwnerLink, Rich Text Format, Text,
Unicode Text, Unknown: -16639, Unknown: -16640, Unknown: 129, Unknown: 17,
Wk1 & XML Spreadsheet,

That is an extreme example but just a bit of plain text is in these formats:
Text, OEM Text, Unicode Text & Locale Identifier
Also if you've ever placed a list of files onto the clipboard using code
you'll know what fun that can be.

Regards
Dave O.





From: Dave O. on

"Larry Serflaten" <serflaten(a)usinternet.com> wrote in message
news:OrVTGohaKHA.6028(a)TK2MSFTNGP04.phx.gbl...
>
> "Dave O." <nobody(a)nowhere.com> wrote

> I seem to recall a similar discussion...
> http://groups.google.com/group/microsoft.public.vb.general.discussion/browse_thread/thread/a294f7e4aba0be1f/82bf4b082ec1c518?hl=en#82bf4b082ec1c518
>
> "A while back" ? How about 8 years! <g>
>
> LFS

That was a while wasn't it!
Well the technique seems to work well enough, thanks again for your help
back then when dinosaurs roamed the Earth.

Dave O.