Re: Capture the Computer Desktop
- From: "Mike Williams" <Mike@xxxxxxxxxxxxxxxxx>
- Date: Fri, 23 Sep 2005 09:28:24 +0100
"Doug van Vianen" <courses@xxxxxxxx> wrote in message
news:OVaNUa6vFHA.2292@xxxxxxxxxxxxxxxxxxxxxxx
> The problem is that I cannot detect the color in the border around
> the icon. Otherwise my routine works fine since when I draw a small
> rectangle with the unusual color onto the picture of the desktop it is
> found okay.
Hi Doug. I've looked at your full form code (posted in your other message)
and I'm getting quite a lot of "variable not defined" error messages, so
there are obviously variables in use that are defined elsewhere. The
"deskimage" variable, for example, is not defined in the code block you
posted. I assume that it is defined elsewhere as a StdPicture object or
something, but of course I cannot be sure of that and therefore I cannot
really give youur program a full test run. Also, I can see a few errors in
various parts of your code (although without seeinmg your entire project
code I can't say whether or not they would cause a problem). For example, in
one place you are using:
dpicdesktop.Move 0, 0, Screen.Width, Screen.Height
dpicdesktop.AutoRedraw = True
desk = GetDC(0)
BitBlt dpicdesktop.hdc, 0, 0, Screen.Width, _
Screen.Height, desk, 0, 0, vbSrcCopy
As you probably know, the BitBlt API always uses pixels as its units of
measurement (unless you specifically tell it to do otherwise, which you have
not done). You probably also know that the Screen.Width and Screen.Height
return the sizes in twips. For example, the "twip size" of an 800 x 600
display (running on a machine set to the standard 96 dpi setting) will be
12000 x 9000 twips. Therefore, your code above is asking BitBlt to blit a
massively large area 12000 x 9000 pixels! It won't be able to do that of
course, because the area it is blitting into is only 800 x 600 pixels (in
this specific example) and the BitBlt API will quite sensibly "clip" the
drawing appropriately, which effectively won't actually make a difference,
and your blit will therefore do exactly what you obviously wanted it to do
anyway. However, that is only in that specific example, and I wanted to
point it out to you just in case there are other places in your code where
failure to account properly for the different scale modes might cause it to
work not quite as you want it to.
As it happens, your CaptureScreen() Sub appears to work correctly (at least
it should capture the entire display and save it if it is called correctly
from other places in your code). However, as I've said, I can't really check
your code properly unles I can see all of your declarations and all of the
ways in which you use the various functions you have written. For example
there is a very distinct difference between Picture properties and Image
properties, and unless I can see all of your code I can't be sure that you
are using them properly.
Actually, I think it would probably be a good idea if you sent me your
entire VB project (either as separate files or as a complete zip file)
together with a detailed description of the problem you are currently having
and I'll have a look at it. If I can load your entire project into VB at
this end I should be able to see exactly what you are doing. If you would
like to do so then you can send all your project files (frm, bas, vbp, frx
and whatever elese there is, including any pictures you might be using) to
me at the following address. By the way, make sure that you also send me the
icon you are using. The colors in icons when displayed are not always what
you might expect them to be. If you want some code that will enable you to
check oput the actual displayed colour) manually with the mouse) at any
point on your display then post again (or, alternatively, you should be able
to amend your existing program to give it that ability). Anyway, my email
address is:
taximick47@xxxxxxxxxxx
By the way, if you're wondering about the rather strange address name it is
simply a "throw away" address that I sometimes use in order to, quite
sensibly, keep my "proper" address secret from public forums, which as you
probably know are often "farmed" by nasty "bots" that people write. The name
refers to the fact that I was a self employed taxi driver for the last
almost twenty years of my working life, and my "call number" was "47" ;-)
> How do I find out what colour depth is being used
> on my computer?
Do you mean how can you find out manually sitting at your computer, or how
to find out using VB code? If you're sitting at your computer it is slightly
different on different systems but basically you just right click on a blank
area of your desktop and select "properties" from the drop down menu. Then
click the "Settings" tab and you should see your colour depth (True Color 32
bit or High Color 16 bit or whatever). I would advise changing it to 32 bit
if it is set to a lower depth than that. The procedure might be slightly
different on a WinXP machine (I'm sittin' at my Win98 computer at the
moment), but it will be very similar. If, however, you mean how can you find
out this information from within a VB program then try this:
Option Explicit
Private Declare Function GetDeviceCaps Lib "gdi32" _
(ByVal hdc As Long, ByVal nIndex As Long) As Long
Private Const PLANES = 14
Private Const BITSPIXEL = 12
Private Sub Command1_Click()
Dim ClrDepth As Long
ClrDepth = GetDeviceCaps(Me.hdc, PLANES) * _
GetDeviceCaps(Me.hdc, BITSPIXEL)
Print ClrDepth & " bits per pixel"
End Sub
By the way, it was probably a bit pendantic of me to include the "Planes"
check. Out of interest, has anyone ever come across a Windows system with
more than one plane?
> PS: How come your e-mail address is specified as
> WhiskeyAndCoke when you drink gin and Coke®???
Obviously that address is really a dummy, but basically I'll drink almost
anything with Coke®. I love the stuff. Probably my favourite tipple is rum
and Coke (it's got to be Lamb's Navy Rum though!) but I also quite like
whisky and Coke (hope nobody in Scotland is reading this!) and I'll quite
happily drink my girl friend's gin with Coke if there's nothing else about
;-)
Actually, it feels a bit strange using the term "girl friend" at my age (my
eldest son is 40 years old!) ;-)
Mike
.
- References:
- Capture the Computer Desktop
- From: Doug van Vianen
- Re: Capture the Computer Desktop
- From: Doug van Vianen
- Capture the Computer Desktop
- Prev by Date: drag from VB textbox, drop into html textbox, possible?
- Next by Date: Re: Newbie: How to extract year from a Date object
- Previous by thread: Re: Capture the Computer Desktop
- Next by thread: Re: HTML from URL (and back)
- Index(es):
Relevant Pages
|