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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Get object from handle

(0) ShareShare
ReportReport
Posted on by

Hello,

I have windows handle of object (windows handle)

How can I find the instance of object? (class)

Thanks :)

*This post is locked for comments

I have the same question (0)
  • Jonathan  Halland Profile Picture
    11,310 on at

    Hi Eitan, can you post a sample of the code you currently have E.G. the handle. What type are you using to store this handle?

  • Suggested answer
    DG Profile Picture
    1,226 on at

    I guess you are talking about an AX class. If yes, then use function 'classIdGet' to get the ID of the class involved.

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi,

    Windows handle will only give you "low level" class (something like Windows Forms AxToLevelFrame or AxPaneWnd) but you can't get X++ object out of it. Handle is intended to be used when calling WinApi methods.

    If you want to find a window by its handle - you should first build your own list of all opened windows - something like SysTaskRecorderRunningFormsManager::formlist()

  • Community Member Profile Picture
    on at

    I know exactly the class name.

    I am passing the hwnd() (of form object), need to retrieve the form itself, by only have the hwnd().

    I see function SysTaskRecorderRunningFormsManager::addFormToList().

    I succeed passing the formrun (this), and retrieving it elsewhere, but when I retrieving it from thread function 

    (like TutorialThread::runThread), SysTaskRecorderRunningFormsManager::getFormRunByHwnd(hwnd) returns null (that doesn't happen for non-thread methods).

    Thanks :)

  • Verified answer
    Community Member Profile Picture
    on at

    Hi,

    Sorry, I didn't get from your first message that you are talking about the multi-threaded case. 

    I would recommend first reading this discussion: How to load data in form asynchronous? It has a really good example from Brandon.

    The basic idea is that by calling Thread.run() you create a new AX session of Worker type. And since you can't access the UI object running in another AX session (its by the AX architecture) - my previous recommendation doesn't work for you.

    But if you combine SysTaskRecorderRunningFormsManager (or any other Global Cache based list)  and the Thread.executeInUIThread() then you should be able to meet your goal

  • Community Member Profile Picture
    on at

    OK.

    Thank you!!!

    Now understanding working with thread in AX - I solve the problem, using wisely executeInUIThread.

    Thanks :)

  • Community Member Profile Picture
    on at
    [deleted]
  • Verified answer
    Community Member Profile Picture
    on at

    Hi,

    Try: Thread.cancelJob(true) 

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans