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);  
       
    }
    
  • 相关阅读:
    ABP WebApi的请求类型
    对服务器的文件或文件夹压缩
    VS运行遇到的那些坑
    asp.net core Api集成Swagger
    通过文件路径获取文件名
    读取服务器或者本地的文件夹下面的文件
    计算出 3 至 1000 范围内最大的十个素数,放入数组中,并计算出其累加和。
    LINUX 无法登入系统(2017-1-16)
    zynq里面的AXI总线(2017-1-11)
    学习随笔(2017-1-10)
  • 原文地址:https://www.cnblogs.com/Fandyx/p/1951114.html
Copyright © 2011-2022 走看看