Wednesday, 15 December 2010

How to open TIF Image files in Dynamics AX

Today I’m going to discuss about one of another important feature in Dynamics AX. As well as the Other Programming languages, Axapta is supporting ActiveX object handling.
ActiveX control is a small program, which contains set of instruction & functions. Sometimes it’s called as add-ons.

Generally we can create an image viewer using this ActiveX object. In standard AX is coming with “Microsoft Web Browser” class for handling the Image Viewer ActiveX Control. But this viewer is accepting limited image file formats such as .JPG, GIF…

So I’m going to explain, powerful image viewer ActiveX control which supports a lot of popular image file extension, including TIFF, MNG, JNG,  BMP, GIF, ICO, JPEG,  PCX, PNG, PSD, WMF, WBMP, TGA, PGX, RAS, PNM.

That image Viewer ActiveX Control & Type Library is coming with Microsoft Office Package. That Is called “Microsoft Office Document Imaging 2003 (MODI)” model.

Step 1: When ActiveX control is placed in your PC, we have to get those files in to the Axapta using Wrapper Class. That can be done as follows,

Tools \ Development Tools \ Wizards \ COM Class Wrapper Wizard & go “Next”

Step 2:  select the “Microsoft Office Document Imaging 12.0 Type Library”. & click “Next”

Step 3: Enter an element mask. That will be appended to the front of the all elements generated by Wizard. In my example I’ve chosen “INDMODI”. & click “Next”.

Step 4: Create a new form & add ActiveX Control by right click on the design
In the ActiveX browser select the “Microsoft Office Document Imaging Viewer Control 12.0”.

Step 5: we need to specify the image path to open the file. For that add following code to the form


//Declaring Variable
public class FormRun extends ObjectRun
{
    INDMODIDocument    modiDocument;
}

//Initialize the Image path
public void init()
{
   ;
    super();
    activex.filename("Z:\\Images\\TestImage.gfd");
}


public void run()
{
    try
    {
        if(activeX.document())
        {
            modiDocument = new UKMODIDocument(activeX.document());
            super();
        }
    }
    catch (Exception::Error)
    {
        activeX.filename('');
    }
}


//Clear the Memory & Buffer
public void close()
{
    super();
    modiDocument.Close();
    activex.filename('');
}


No comments:

Post a Comment