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);  
       
    }
    
  • 相关阅读:
    Linux 命令
    g++/gcc
    emacs lisp
    vim 快捷键
    emacs快捷键
    Valgrind 例子
    Valgrind
    gprof
    cppcheck
    gdb常用命令
  • 原文地址:https://www.cnblogs.com/Fandyx/p/1951114.html
Copyright © 2011-2022 走看看