CaptureScreenToFile - Error


Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
I know that you want an answer here, but this is an issue with your API in your environment.  We use the Windows API to capture the screen, so if you have an issue on your Windows installation or environment, then it could present this type of error.

I am running Windows Vista as well and have tested this on several machines without issue.  You can see the attached screenshot that was created when I clicked the Button2 button on the form in the image.  But here are some things to check:

  1. You are trying to use the CaptureImageToFile.  But do you have sufficient permissions to write to the specified folder location?
  2. You may want to CaptureScreen method which returns an Image object.  You can then store that image in a database or whatever you like.  This is always good when you want to keep track of error logs or may have permission issues on a machine.

Attachments
temp.jpg (126 views, 243.00 KB)
Rogerio Mauri
Rogerio Mauri
StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)
Group: StrataFrame Users
Posts: 205, Visits: 629
???

Rogério Mauri Smile

Rogerio Mauri
Rogerio Mauri
StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)
Group: StrataFrame Users
Posts: 205, Visits: 629
??? Crying

Rogério Mauri Smile

Rogerio Mauri
Rogerio Mauri
StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)
Group: StrataFrame Users
Posts: 205, Visits: 629
Ivan... Boa Noite...

Dê uma olha neste tópico do forum MSDN. Acho que será necessário um ajuste nesse recurso.

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2459309&SiteID=1

Rogério Mauri Smile



Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hey Rogério.

No idea about what can be wrong... Tongue

Just a thought, but have you tried isolating the problem... maybe hardcoding the fileName, like "C:\". Also, trying a different format, .Bmp maybe.

Also, you could try the formats on this post:

http://forum.strataframe.net/FindPost13029.aspx

Also, Google gdi ErrorCode=-2147467259 , there are some solutions over there, might be a threading thing.

Rogerio Mauri
Rogerio Mauri
StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)
Group: StrataFrame Users
Posts: 205, Visits: 629
Rogerio Mauri (09/20/2008)

  - fileName = "C:\\Temp\\Tela.jgp"

- fileName = "C:\\Temp\\Tela.jpg"

Rogério Mauri Smile



Rogerio Mauri
Rogerio Mauri
StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)
Group: StrataFrame Users
Posts: 205, Visits: 629
Method returns GDI error.

  - Windows Vista
  - VS2005
  - fileName = "C:\\Temp\\Tela.jgp"



// Método para salvar screen em arquivo
private void CapturaScreen(string fileName)
{
     MicroFour.StrataFrame.Tools.
ScreenCapture.CaptureScreenToFile(fileName, System.Drawing.Imaging.ImageFormat.Jpeg);
}

System.Runtime.InteropServices.ExternalException was unhandled by user code
  Message="Erro genérico de GDI+."
  Source="System.Drawing"
  ErrorCode=-2147467259
  StackTrace:
       em System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
       em System.Drawing.Image.Save(String filename, ImageFormat format)
       em MicroFour.StrataFrame.Tools.ScreenCapture.CaptureScreenToFile(String FileName, ImageFormat Format)
       em NCClube.Forms.FormCracha.cmdFoto_Click(Object sender, EventArgs e) na C:\Users\Rogerio\Documents\Visual Studio 2005\Projects\StrataFrameProjects\NCClube\NCClube\Forms\FormCracha.cs:linha 111
       em System.Windows.Forms.Control.OnClick(EventArgs e)
       em System.Windows.Forms.Button.OnClick(EventArgs e)
       em System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       em System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       em System.Windows.Forms.Control.WndProc(Message& m)
       em System.Windows.Forms.ButtonBase.WndProc(Message& m)
       em System.Windows.Forms.Button.WndProc(Message& m)
       em System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m)
       em System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)
       em System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


Rogério Mauri Smile



GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search