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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

AX 2012: ActiveX field takes focus in form

(0) ShareShare
ReportReport
Posted on by 555

Hi experts!

I have a form with a group holding only one field and that is an ActiveX field of type "Adobe PDF Reader".

In my form I have some lines and every line contains a field with the name of the PDF file that I want to be shown in the ActiveX field when I select a line. So when I go from one line to another, the ActiveX field also changes so it shows the matching PDF file.

It works fine.

In the datasources "Active" method I call my ActiveX control like this: activeX.loadFile('myFile.pdf');

The problem is that the Activex field takes the focus every time loadFile is called. When I click on a line, it shows the correct PDF file, but when I press "arrow down" on the keyboard I don't move to the line below, but the PDF file moves a little inside the ActiveX field. (So if I do that a lot, I can soon see page two of the PDF file.)

How do I keep focus on the line and field, I am in?

Hope you can help...

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Rustem Galiamov Profile Picture
    8,072 on at
    RE: AX 2012: ActiveX field takes focus in form

    Hi!

    I have created the form with ActiveX field (like you are described) in the group. The form contains the grid also.  And the focus still remain on a grid when i move the cursor.

    Try to call myField.setFocus() method after activeX.loadFile('myFile.pdf').

  • Morten Steengaard Profile Picture
    555 on at
    RE: AX 2012: ActiveX field takes focus in form

    Hi,

    Thank you for your time.

    I am standing on a grid in the datasources "Active" method. How do I get an object that I can call setFocus on?

    I want the user to remain on the field in the same row as it was. I guess I have to get the current row and the current column and after "loadFile", I can call setFocus.

    But how do I get the current row and column so I can call setFocus on that object?

  • Suggested answer
    Rustem Galiamov Profile Picture
    8,072 on at
    RE: AX 2012: ActiveX field takes focus in form

    Just set AutoDeclaration property's value to YES on the field on the grid and then call setFocus(). The row will be the same, this method doesn't affect the row position.

  • Morten Steengaard Profile Picture
    555 on at
    RE: AX 2012: ActiveX field takes focus in form

    I still don't know which column (field) I am on. If I in the "Active" method calls "element.selectedControl().name()" it always returns the name of the grid and not the grid + the field like "myGrid_myField".

    AutoDeclaration is YES on every field in the grid, and I have tried calling setFocus() on the first field in the grid, but that doesn't change anything. The ActiveX field still steals my "arrow down" keystroke.

  • Rustem Galiamov Profile Picture
    8,072 on at
    RE: AX 2012: ActiveX field takes focus in form

    Could you share some screenshots of form design, activeX control properties and active() method code, please?

  • Morten Steengaard Profile Picture
    555 on at
    RE: AX 2012: ActiveX field takes focus in form

    Hope this helps:

    pastedimage1566377263647v1.jpeg8741.jpg2821.jpg

  • Morten Steengaard Profile Picture
    555 on at
    RE: AX 2012: ActiveX field takes focus in form

    I have copied my form and removed everything else from the form. So now it only has one grid (with one column) and one ActiveX-field.

  • Verified answer
    Rustem Galiamov Profile Picture
    8,072 on at
    RE: AX 2012: ActiveX field takes focus in form

    So, in the active() method put ActiveX.enabled(false); before ActiveX.loadFile().

    Then override mouseDown() method on the GroupPictureGroup methods and set ActiveX.enabled(true);

    Screenshot-2019_2D00_08_2D00_21-at-14.01.12.png 

    Screenshot-2019_2D00_08_2D00_21-at-14.01.06.png

  • Morten Steengaard Profile Picture
    555 on at
    RE: AX 2012: ActiveX field takes focus in form

    Wow, it works!

    I've done what you wrote, and now the grid and the field works perfectly.

    I have an extra question: If I move to page two in the pdf file, and then go one line up in my grid, then the other pdf file is also showing page two. The same goes for zooming etc.

    Is there a way to reset the field, so it forgets that the user wanted to see page two? (So that when I show a new pdf file, it always shows page one.)

  • Rustem Galiamov Profile Picture
    8,072 on at
    RE: AX 2012: ActiveX field takes focus in form

    Hmm..I have tested the behaviour that you are described. My form always reset the field...

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
AlissonGodoy Profile Picture

AlissonGodoy 2

#2
Community Member Profile Picture

Community Member 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans