zoukankan      html  css  js  c++  java
  • Using .net Code saved full Screen Resolution Image in Dynamics AX 2009

     Using .net Code saved as full Screen Resolution Image in Dynamics AX 2009

    Wrote by Jimmy Feb 11th 2011

    static void Jimmy_ImagesSavedFullScreen(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;  
        System.Exception                ex;
        #WINAPI  
        #define.FileName('DynamicsAx_Screenshot.png')  
    ;  
        try
        {  
            SaveToFileName  = strfmt(@"%1\%2",WinApi::getFolderPath(0),#FileName);//0
            /*
            #define.CSIDL_DESKTOP                   (0x0000)        // <desktop>
            #define.CSIDL_INTERNET                  (0x0001)        // Internet Explorer (icon on desktop)
            #define.CSIDL_PROGRAMS                  (0x0002)        // Start Menu\Programs
            #define.CSIDL_CONTROLS                  (0x0003)        // My Computer\Control Panel
            #define.CSIDL_PRINTERS                  (0x0004)        // My Computer\Printers
            #define.CSIDL_PERSONAL                  (0x0005)        // My Documents
            */
            if(winapi::fileExists(SaveToFileName,false))  
                winapi::deleteFile(SaveToFileName);  
            primaryScreen   = System.Windows.Forms.Screen::get_PrimaryScreen();  
            bounds          = primaryScreen.get_Bounds();  
       
            [x, y, k, l]    = WinApi::getWindowRect(infolog.hWnd());  
       
            width       = WinAPI::getSystemMetrics(#SM_CXSCREEN);  
            height      = WinAPI::getSystemMetrics(#SM_CYSCREEN);  
       
            bitmap          = new System.Drawing.Bitmap(width,height);  
       
            graphics        = System.Drawing.Graphics::FromImage(bitmap);  
            graphics.CopyFromScreen(x,y,0,0,bitmap.get_Size());  
       
            bitmap.Save(SaveToFileName, System.Drawing.Imaging.ImageFormat::get_Png());
        }
        catch(Exception::CLRError)    
        {
            ex = CLRInterop::getLastException();
            while( ex )
            {
            info( ex.get_Message() );
            ex = ex.get_InnerException();
            }
        }
        catch(Exception::Error)
        {
            error("The file could not be saved");
            global::exceptionTextFallThrough();
        }
        if(winapi::fileExists(SaveToFileName,false))  
            winapi::shellExecute(SaveToFileName);  
       
    }
    
  • 相关阅读:
    8种元素定位方式
    接口MD5加密如何测试?
    web自动化测试框架 —数据驱动测试
    等待方式
    全面开展测试需求分析
    字符串格式化(%方式 与 format方式)
    Python中八大基本数据类型之 集合
    Python中 __new__ 和 __init__ 的区别
    C/S模式与B/S模式的工作原理
    剑指offer--把二叉树打印成多行
  • 原文地址:https://www.cnblogs.com/Fandyx/p/1951114.html
Copyright © 2011-2022 走看看