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);  
       
    }
    
  • 相关阅读:
    对《软件工程》这门课的总结
    结对编程项目---四则运算
    PSP记录个人项目耗时情况
    代码复审
    是否需要有代码规范
    四则运算的实现(C++)重做
    四则运算器的实现
    学习进度总结
    通过阅读教材,所得的不懂的问题
    自我介绍
  • 原文地址:https://www.cnblogs.com/Fandyx/p/1951114.html
Copyright © 2011-2022 走看看