Показать сообщение отдельно
Старый 22.04.2011, 17:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,643 / 848 (80) +++++++
Регистрация: 28.10.2006
equalized: Dynamics ax take screenshots from FormControls
Источник: http://blog.equalized.be/2010/11/dyn...-formcontrols/
==============

Hi all,

Here is a little code snippet for you to take screen shots within a Dynamics Ax client.

X++:
public void run(FormControl _control)
{
    str                         SaveToFileName;
    System.Drawing.Bitmap           bitmap;
    System.Drawing.Graphics        graphics;
    System.Windows.Forms.Screen primaryScreen;
    System.Drawing.Rectangle       bounds;
 
    int                                       x, y, k, l;
    System.Int32                         width;
    System.Int32                         height;
 
    #define.FileName('DynamicsAx_Screenshot.png')
    ;
 
    try
    {
        // 5 for the My Documents folder
        SaveToFileName  = strfmt(@"%1\%2",WinApi::getFolderPath(5),#FileName);
 
        primaryScreen   = System.Windows.Forms.Screen::get_PrimaryScreen();
        bounds          = primaryScreen.get_Bounds();
 
        [x, y, k, l]    = WinApi::getWindowRect(_control.hWnd());
 
        width           = _control.widthValue();
        height          = _control.heightValue();
 
        // 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());
 
 
        bitmap.Save(SaveToFileName, System.Drawing.Imaging.ImageFormat::get_Png());
    }
    catch
    {
        error("The file could not be saved"); // TODO make label
    }
}
This snippets uses the size of your control and the position on your screen to create the screenshot



Источник: http://blog.equalized.be/2010/11/dyn...-formcontrols/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.

Последний раз редактировалось Poleax; 22.04.2011 в 17:27. Причина: код