Description:-
In this article we will she how to take screen shot using X++. Here i have Create System Bit Image to Take Bitmap Image and Save in where you want to save using FileSaveDialog Box. Using getSystemMetrics to get Height and Width of Screen to take Image and Capture and Save it to Using FileSaveDialog box in Dynamics Ax.
Code:-
In this article we will she how to take screen shot using X++. Here i have Create System Bit Image to Take Bitmap Image and Save in where you want to save using FileSaveDialog Box. Using getSystemMetrics to get Height and Width of Screen to take Image and Capture and Save it to Using FileSaveDialog box in Dynamics Ax.
Code:-
Static void ScreenShot(Args _args) { System.Drawing.Bitmap bitmap; System.Drawing.Graphics graphics; System.Windows.Forms.Screen primaryScreen; System.Drawing.Rectangle bounds; int x, y, k, l; str SaveToFileName; System.Int32 width; System.Int32 height; filename filename; FromTime startTime = timeNow(); int i; str dummyStr; str filepath; container confilter = [".jpg","*.jpg"]; #WINAPI //#define.FileName('DynamicsAx_Screenshot.jpg') ; try { for (i = 1 ; i <= 1000000; i++) { dummyStr += int2str(i); } primaryScreen = System.Windows.Forms.Screen::get_PrimaryScreen(); bounds = primaryScreen.get_Bounds(); [x, y, k, l] = WinApi::getWindowRect(infolog.hWnd()); //width = 1280;//_control.widthValue(); //height = 800;//_control.heightValue(); width = WinAPI::getSystemMetrics(#SM_CXSCREEN); height = WinAPI::getSystemMetrics(#SM_CYSCREEN); // TwC: used API CLRObject // BP Deviation Documented bitmap = new System.Drawing.Bitmap(width,height); graphics = System.Drawing.Graphics::FromImage(bitmap); graphics.CopyFromScreen(x,y,0,0,bitmap.get_Size()); } catch(exception::Error) { error("The file could not be saved"); } //Save File filepath = WinAPI::getSaveFileName( 0, confilter, "", "File Save Dialog", ".jpg", "Untitled"); // 5 for the My Documents folder //SaveToFileName = strfmt(@"%1\%2",WinApi::getFolderPath(5),#FileName); SaveToFileName = strfmt(@"%1",filepath); if(winapi::fileExists(SaveToFileName,false)) winapi::deleteFile(SaveToFileName); bitmap.Save(SaveToFileName, System.Drawing.Imaging.ImageFormat::get_Png()); if(winapi::fileExists(SaveToFileName,false)) winapi::shellExecute(SaveToFileName); }
Thanks for comments.....