Answered by:
PrintScreen

Question
-
Hi,
I want to know if we have an alternate function of Graphics.CopyFromScreen under Compact Framework. I want to make a screenshot (print screen) of a window of another running program and finally save it to a specific folder.
Thank you very muchTuesday, August 21, 2007 8:17 PM
Answers
-
Take a look at this blog post of mine:
http://blog.opennetcf.org/ayakhnin/PermaLink,guid,a5c9adc4-85d6-498e-8adf-0ba5fe9d0db7.aspx
Tuesday, August 21, 2007 10:52 PM -
You didn't declare the P/Invoke properly:
-Alex
Wednesday, August 22, 2007 3:54 PM
All replies
-
Take a look at this blog post of mine:
http://blog.opennetcf.org/ayakhnin/PermaLink,guid,a5c9adc4-85d6-498e-8adf-0ba5fe9d0db7.aspx
Tuesday, August 21, 2007 10:52 PM -
Compile and execute without error but the printscreen is black
Code SnippetConst SRCCOPY As Integer = &HCC0020
Public Function BitBlt(ByVal hdcDest As IntPtr, ByVal nXDest As Integer, ByVal nYDest As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hdcSrc As IntPtr, ByVal nXSrc As Integer, ByVal nYSrc As Integer, ByVal dwRop As Integer) As Integer
End Function
Private Sub mniPrintScreen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mniPrintScreen.Click
Snapshot("\save.bmp", Me.CreateGraphics, Me.btnModule1A.Bounds)
End Sub
Private Sub Snapshot(ByVal filename As String, ByVal gx As Graphics, ByVal rect As Rectangle)
Try
' Create compatible graphics
Dim bmp As Bitmap = New Bitmap(rect.Width, rect.Height)
Dim gxComp As Graphics = Graphics.FromImage(bmp)
' Blit the image data
BitBlt(gxComp.GetHdc(), 0, 0, rect.Width, rect.Height, gx.GetHdc(), rect.Left, rect.Top, SRCCOPY)
bmp.Save(filename, System.Drawing.Imaging.ImageFormat.Bmp)
' Cleanup
bmp.Dispose()
gxComp.Dispose()
Catch ex As Exception
MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
End Try
End Sub
I don't know if we have the posibility to take a snapshot of the mobile desktop?
Thx very muchWednesday, August 22, 2007 2:16 PM -
You didn't declare the P/Invoke properly:
-Alex
Wednesday, August 22, 2007 3:54 PM -
Wow!!!!
It work! Muchas gracias senior!
Final question! If I want to make a snapshot of an other application running. The other application will not be in vb.net. I want to make a screenshot of what I see behind the window that execute the snapshot script.
Thank
JP
Wednesday, August 22, 2007 6:37 PM -
Yes, it will make a snapshot of whatever is on the screen even if your application is not visible.
-Alex
Wednesday, August 22, 2007 7:30 PM