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 6590037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:15:01+00:00 2026-05-25T17:15:01+00:00

I am using VB.NET to try and capture a portion of the screen so

  • 0

I am using VB.NET to try and capture a portion of the screen so I found this code in several places to capture the whole screen:

Dim screenSize = SystemInformation.PrimaryMonitorSize
Dim bitmap = New Bitmap(screenSize.Width, screenSize.Height)
Using g As Graphics = Graphics.FromImage(bitmap)

    g.CopyFromScreen(New Point(0, 0), New Point(0, 0), screenSize)

End Using
bitmap.Save("c:\scratch\screenshot.png", System.Drawing.Imaging.ImageFormat.Png)

This works with no error throw and the file is created successfully but the resulting image is completely transparent (it is the correct size) – what am I missing?

This question relates to the same error but the solution is to use Win32 GDI which I want to avoid if possible

  • 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-25T17:15:02+00:00Added an answer on May 25, 2026 at 5:15 pm

    I decided to go along the print screen option in the end due to the issues with the CopyFromScreen method:

    'declarations
    Private Const VK_SNAPSHOT As Integer = &H2C
    
    <DllImport("user32.dll")>
    Public Function keybd_event(ByVal key As Integer, ByVal dummy As Integer, ByVal flags As Integer, ByVal info As IntPtr) As IntPtr
    End Function
    
    
    'Usage
    Dim loopCount As Integer = 0
    
    Clipboard.Clear()
    keybd_event(VK_SNAPSHOT, 0, 0, IntPtr.Zero)
    Application.DoEvents()
    
    Do Until Clipboard.ContainsImage Or (loopCount > 10)
        loopCount += 1
        System.Threading.Thread.Sleep(100)
        Application.DoEvents()
    Loop
    
    If Clipboard.ContainsImage Then
        Return Clipboard.GetImage
    Else
        Return Nothing
    End If
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was using .Net Reflector on an Internal App to try and understand what
I'm using the zlib.NET library to try and inflate files that are compressed by
I am using xml.net in web application When I try load xml through an
I'm using ASP.Net and whenever I create a script file or try to include
I am using a .Net HtmlTextWriter to generate HTML. try { htw.RenderBeginTag( HtmlTextWriterTag.Span );
I'm using the .NET TWAIN code from http://www.codeproject.com/KB/dotnet/twaindotnet.aspx?msg=1007385#xx1007385xx in my application. When I try
I try to add an addons system to my Windows.Net application using Reflection; but
I get the following error when I try to compile an asp.net site using
When I try to start Firefox using Process.Start and ProcessStartInfo (.NET) everything seems to
I am using jQuery to try and trigger a method when an ASP.NET (2.0)

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.