Loading WallPaper Into a Form For Transparency

I need to load the background wall paper into a form. The difficulty here
is when I move the form, I want what ever screen area  behind the form to be loaded into the form in a synchronized manner. That is the new location of the
form needs to be computed, the region
should be captured as a bitmap and loaded into the form for a transparent

Can someone give me pointers to do this rather than simply telling me to BitBlt.
I am half way thru and am not able to figure out how to capture the screen area and load into to the form while moving it.

Sorry I dont have more points. Any help will be greatly appreciated.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

set the form's AutoRedraw property to TRUE.
set a picture as the form's picture property.

 then, the Form Resize event should be like this :

Private Sub Form_Resize()
   With Form1
     .PaintPicture .Picture, 0, 0, .Width, .Height
   End With
End Sub

srirambmAuthor Commented:
Dear Sir,

You have not understood the question.
I want to paint the desktop into my form
and synchronise the areas under the form
into the form for a transparent effect.

I will only need to load portions of the
wallpaper into the form.

I hope you understand.

Thank you for answering
you are right. i have not read the Q carefully. sorry.
now, you want a lot ot things which demand a long API codes.
now suppose an expert gives you 200 lines API code that answers just a part of your problems ?
that's why i'm not even start to get involved when there is more then one Q in a Q.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

If you know how to read the registry you can read the values of:

Wallpaper File:

HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper


HKEY_CURRENT_USER\Control Panel\Desktop\TileWallpaper

If you do not know how to read the registry search EE, I am sure there are lots of questions regarding that, and I want to answer your question here.

Load the wallpaper file into a picture box that is the same size as the screen and is the farthest back control on your form.  If TileWallpaper is not 0 you need to tile it. Or if it is smaller then the screen you need to center it.  For either of these tasks you can use the picturebox's paintpicture method.  Then set the picturebox's left and top properties to the negitive of the form's top and left properties.  You will have to make adjustments for the height of the titlebar (if you are displaying one). The draw back to this method is that any icons, toolbars, or taskbars will not be displayed (just the picture).  If you want these things displayed in your background, you are going to have to use BitBlt to capture the screen.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
srirambmAuthor Commented:
I dont mind I f I need to bitblt anything. Is there any sample I can try?

I know how to get the wallpaper from the
registry et al. All I need is to get the
transparent effect. When I move my form,
the background (Whatever that is behind should show thru) should show thru.

Thanks for answering
Have bkgpic as a picturebox that is the farthest back control on the form.  Then try:

'Declarations section

Private Const SRCCOPY = &HCC0020

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 CreateDC Lib "gdi32" Alias "CreateDCA" _
   (ByVal lpDriverName As String, ByVal lpDeviceName As String, _
   ByVal lpOutput As Long, ByVal lpInitData As Long) As Long

Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long

Sub Form_Load()
    Dim picdc&
    With bkgPic
        .AutoRedraw = True
        picdc& = CreateDC("DISPLAY", "", "", 0&)
        tmp& = BitBlt(.hdc, 0, 0, scw!, sch!, picdc&, 0, 0, SRCCOPY)
        tmp& = DeleteDC(picdc&)
        .top= (-1) * me.top
        .left= (-1) * me.left
        .AutoRedraw = False
    End with
End Sub

then when you move the form make sure you reset the top and left of the bkgPic picturebox
srirambmAuthor Commented:
Good Technique, Thanks.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.