Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6183295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:20:27+00:00 2026-05-24T01:20:27+00:00

I am on windows XP and I am trying to captrue a window. But

  • 0

I am on windows XP and I am trying to captrue a window.

But when I capture a window, I get the window title (Name & Icon) but the entire content of the window is black.

When trying to save the image, the whole image is transparent.

This is my code :

    [DllImport("User32.dll", SetLastError = true)]
    [return: MarshalAs(UnmanagedType.Bool)]
    private static extern bool PrintWindow(IntPtr hwnd, IntPtr hDC, uint nFlags);

    [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
    public static extern IntPtr GetForegroundWindow();

    [DllImport("user32.dll")]
    private static extern bool GetWindowRect(IntPtr handle, ref Rectangle rect);

    public void CaptureWindow(IntPtr handle)
    {
        Rectangle rect = new Rectangle();
        GetWindowRect(handle, ref rect);
        rect.Width = rect.Width - rect.X;
        rect.Height = rect.Height - rect.Y;
        try
        {
            Bitmap bmp = new Bitmap(rect.Width, rect.Height);
            Graphics memoryGraphics = Graphics.FromImage(bmp);
            IntPtr hdc = memoryGraphics.GetHdc();
            PrintWindow(handle, hdc, 0);
            ResultsPB.Image = bmp;
            memoryGraphics.ReleaseHdc(hdc);
        }
        catch (Exception)
        {
            throw;
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:20:28+00:00Added an answer on May 24, 2026 at 1:20 am

    Look at C# Capturing Direct 3D Screen.
    Print screen captures the visible area, not a handle.

    DirectX and OpenGL draw directly via hardware. With PrintScreen you can only capture handle screen which are drawn managed by Windows.

    If you only need the visible area use Graphics.CaptureFromScreen.

    I’ve tried BitBlt and PrintScreen with an OpenGL demo from http://magnum.dimajix.de/download/demos.shtml without success. PrintScreen only returned a blank bitmap and BitBlt return an old capture(probably from the first and only WM_PAINT message).

    Just try to start your game and listen to it’s window-messages. You will see there is no WM_PAINT message. So Windows doesn’t even know if there has anything changed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to capture the Tab key in a Windows Forms application and do
I am trying to use Windows.Media.Capture.CameraCaptureUI() of Metro Style app in WPF application in
I am working on an app on Windows Phone and trying to get data
I'm trying create a simple bookmarklet to capture the title and url of a
I'm trying to write a little app to capture keystrokes for a window under
I'm trying on Windows 7 to capture the console output of one jar (written
Is there some method to issue a screen capture(browser window content only) from the
I am trying to get camera feeds in Windows 8 metro style app so
I am trying to capture Window's active window changed event. Let's say if user
Like the question here , I am trying to capture images with Emgu. But

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.