Notifications
Announcements
No record found.
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
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?
I guess you are talking about an AX class. If yes, then use function 'classIdGet' to get the ID of the class involved.
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()
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).
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
OK.
Thank you!!!
Now understanding working with thread in AX - I solve the problem, using wisely executeInUIThread.
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 4 Most Valuable Professional
Priya_K 4
MyDynamicsNAV 2