Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++ tool) WindowViewer

 

WindowViewer is a failed attempt to capture all windows as bitmaps.

 

WindowViewer was released on the 6th of Fubruary of 2010 and programmed in C++ using the IDE C++ Builder 6.0. It uses the STL, Boost and VCL libraries.

 

 

 

 

 

 

Why did it fail?

 

I attempted to use WindowViewer to view all the hidden windows the Windows Task Manager makes you aware of. WindowViewer does not show those: at the location of where this hidden window is, it obtains the bitmap of what is visible there.

 

 

 

 

 

Core code

 

//std::vector<boost::shared_ptr<TFormImage> > m_v
//TFormImage has one member, a TImage called Image
 
HWND handle = GetWindow(GetForegroundWindow(),GW_HWNDFIRST);
int index = 0;
 
while(handle)
{
  const int sz = 256;
  char buffer[sz];
  GetWindowText(handle,buffer,sz);
  const std::string text(buffer);
  if (text.empty())
  {
    handle = GetNextWindow(handle,GW_HWNDNEXT);
    continue;
  }
 
  if (index == static_cast<int>(m_v.size()))
  {
    boost::shared_ptr<TFormImage> i(new TFormImage(0));
    i->Image->Picture->Bitmap->PixelFormat = pf32bit;
    i->Caption = "";
    m_v.push_back(i);
  }
 
  RECT rect;
  GetWindowRect(handle,&rect);
  const int width = rect.right - rect.left;
  const int height = rect.bottom - rect.top;
 
  Graphics::TBitmap * b = m_v[index]->Image->Picture->Bitmap;
  assert(b);
  assert (b->PixelFormat == pf32bit);
 
  HDC dc = GetDC(handle);
  if (!dc)
  {
    handle = GetNextWindow(handle,GW_HWNDNEXT);
    continue;
  }
 
  m_v[index]->ClientWidth = width;
  m_v[index]->ClientHeight = height;
  b->Width = width;
  b->Height = height;
 
  BitBlt(b->Canvas->Handle, 0, 0, b->Width, b->Height, dc, 0, 0, SRCCOPY);
  b->Modified = true;
 
  ReleaseDC(handle,dc);
  handle = GetNextWindow(handle,GW_HWNDNEXT);
  ++index;
}

 

 

 

 

 

Licence

 

Window Viewer, tool to view all windows
Copyright (C) 2010 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict