web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

display Bitmap xx() in forms

(0) ShareShare
ReportReport
Posted on by

Hi there

I'm trying to display image on a form with a display bitmap method to feed a window control on a form.

I've seen the example on several blogs and followed them coding thing like this:

display Bitmap picture()

{

    container ret;

    // prepare container data from a bimap image

    return ret;

}

Then I placed a window control on the form and refered the datamethod to 'picture'.

However, every time the method is executed, AX freezes instead of showing the image. It makes no difference if I load the bitmap from a file or from the AOT node nor to return a null value - crashes every time.

Have the problem in AX 4.0, AX 2009 and AX 2012.

What's the trick to run this code?

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    239,680 Most Valuable Professional on at

    What if you place a breakpoint in your method - did you see where exactly AX freezes? And can you show us your actual code?

  • Community Member Profile Picture
    on at

    The client crashes before a debugger can appear ...

    See actual test code below:

    display Bitmap foo2()

    {

       Bitmap      bitmap;

       Bindata     binData;

       breakpoint; // never reached

       info("halli galli");

       binData = new BinData()

       // 1.bmp is a white 10x10pixel Bitmap from MS Paint ...

       if (binData.loadFile('c:\\1.bmp'))

       {

           bitmap = binData.getData();

       }

       return bitmap;

    }

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi,

    your code is not correct. You cannot do a "new BinData" after you did a info("halli galli"). So your method isn't saved correctly, thus ax is crashing. Fix your method (Variables first, then Initializers, then rest of code).

    Kind regards

    Andi

  • Martin Dráb Profile Picture
    239,680 Most Valuable Professional on at

    Andi is right, the code is not compilable. It would be in AX2012, if there wasn't also missing semicolon after new BinData().

    If even compiler complains, you can't expect it to work.

  • Community Member Profile Picture
    on at

    Yes, there was a error - a missing semicolon after 'new BinData()' - sorry was my fault, but the rest is OK,

    so, back to topic ;)

    display Bitmap foo2()

    {

      Bitmap      bitmap;

      Bindata     binData;

      breakpoint; // never reached

      info("halli galli");

      binData = new BinData();

      // 1.bmp is a white 10x10pixel Bitmap from MS Paint ...

      if (binData.loadFile('c:\\1.bmp'))

      {

          bitmap = binData.getData();

      }

      return bitmap;

    }

  • Verified answer
    Martin Dráb Profile Picture
    239,680 Most Valuable Professional on at

    You should either create image list with your image, set it to WindowControl.imageList() and returns image index in the display method, or not to use display method at all set WindowControl.image() directly.

    Now AX expects integer value (index in image list) and it gets some unexpected binary data instead.

  • Community Member Profile Picture
    on at

    Thank you, the Idea with the Image list does the trick:

    - Create ImageList

    - Add Icons from AOT to the ImageList

    - use display ImageRes xx() and return a index number from the ImageList

    I assume, that the 'display Bitmap xx()' pattern only works for images in legacy reports (AX 2009 and before)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 21

#2
dserp Profile Picture

dserp 4

#2
dekion Profile Picture

dekion 4

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans