Click here to Skip to main content
12,884,951 members (32,959 online)
Click here to Skip to main content
Add your own
alternative version


13 bookmarked
Posted 11 Aug 2005

Capture Window - Active Window to XYZ.BMP

, 11 Aug 2005 CPOL
Rate this:
Please Sign up or sign in to vote.
This article describes how to Capture active window of your application


The Capture window is a small application to capture the active window of your application. This program is something I wrote for one of my applications. But by the time I finished it, I thought it might be pretty useful for developers. It can be used to capture the working of the programs.

This project is not complete, it is a work-in-progress. There are numerous issues with the current version which need to be addressed. My long term goal is to develop this to "commercial quality".

I am going to continue to improve this application towards my goal. I will continue to post updates as I feel necessary.


Capture Window is a little program that I wrote when I was having to save win screen during the development of my application Tetris. This program gives a facility to save the window having score with name and quote as a BMP.


Just run the app. You'll see a screen as shown above. This lets you add your name and quote. Now just click on Save ScreenShot Button. This will generate a BMP file named as "Active Window.BMP".

This article is useful to those of my fellow programmers who are tired of trying to capture the active window to BMP.

Technical Details

Basically we use BitBlt() to get the current window. This usually works better than GetPixel() and SetPixel(). Using this function, we copy active window to Picturebox. Now we use SavePicture to save the active window as BMP.

Using the Code

API Declaration

Public 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

Button Event

Private Sub cmdScreenShot_Click()
frmCanvas.PicSaveScreen.Height = Me.ScaleHeight + 60
frmCanvas.PicSaveScreen.Width = Me.ScaleWidth + 60

BitBlt frmCanvas.PicSaveScreen.hDC, 0, 0, _
Me.ScaleWidth, Me.ScaleHeight, Me.hDC, 0, 0, vbSrcCopy

SavePicture frmCanvas.PicSaveScreen.Image, App.Path & "\Active Window.BMP"
End Sub


  • 12-Aug-2005 - Initial release of article


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer
India India
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralMy vote of 1 Pin
Yazeed Hamdan15-Jun-09 5:02
memberYazeed Hamdan15-Jun-09 5:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170424.1 | Last Updated 11 Aug 2005
Article Copyright 2005 by parinit
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid