Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

Getting the current open window in .net GP Add In

(0) ShareShare
ReportReport
Posted on by

I'm working on an addin where in i have the requirement of getting the current active window in Dynamics GP. I'm using .net to create my plug in and below two assemblies. 

1. Application.Dynamics

2. Microsoft.Dexterity.Bridge.

How can I achieve same ? 

Thanks in advance!

Himal

*This post is locked for comments

  • Almas Mahfooz Profile Picture
    11,009 User Group Leader on at
    RE: Getting the current open window in .net GP Add In

    Yes as I mentioned in my last post PDF name and page number.

  • Community Member Profile Picture
    on at
    RE: Getting the current open window in .net GP Add In

    Thank you all for your responses.

    If there is any code sample for using the trigger to get the current active window, would be greatly appreciated.

  • Almas Mahfooz Profile Picture
    11,009 User Group Leader on at
    RE: Getting the current open window in .net GP Add In

    What David explain is also have explained with code example on FUNCTLIB.pdf  page number 665. As David mentioned Security function call when windows open AND at other times.

    I have also used trigger against Security procedure and I don't know why my script which I call against the Security procedure always execute 4 times. Anyway best luck with your dexterity scripting. :)

  • Tim Wappat Profile Picture
    5,703 on at
    RE: Getting the current open window in .net GP Add In

    Do not make the mistake I originally made (but have now fixed), by unregistering the triggers when the form is closed.  As this will cause the trigger tags to increment every time a window is opened and closed. This will eventually cause the trigger tags to exceed 32768 and go to -32767 and then go to 0 and start duplicating already used tag numbers. This caused all kinds of issues. So keep the triggers registered and use the table to avoid registering more than once.

    I can imagine that was "fun", great reply David, thanks for sharing your experience.

    Tim.

  • Suggested answer
    David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    14,036 Most Valuable Professional on at
    RE: Getting the current open window in .net GP Add In

    Hi Hany

    The method I use to track active windows (already using this in GP Power Tools), is triggering before the Security procedure (not the function) as the procedure is called automatically when windows open. The function is called when windows open AND at other times.

    You can then register a cross dictionary trigger (so it can handle any product) on the Activate event of all windows in the form. You will need to store the dictionary, form, window and trigger tag details in a memory table.

    When the trigger fires, use Trigger_GetCurrentTag() to get the tag, do a reverse lookup on the memory table to identify the dictionary, form and window and store those results in global variables.

    Then you can look at the global variables to identify the last current window.

    You will also need to look in the table to see if that dictionary, form, window is already in the table (and so has a trigger), before registering your trigger.

    Do not make the mistake I originally made (but have now fixed), by unregistering the triggers when the form is closed.  As this will cause the trigger tags to increment every time a window is opened and closed. This will eventually cause the trigger tags to exceed 32768 and go to -32767 and then go to 0 and start duplicating already used tag numbers. This caused all kinds of issues. So keep the triggers registered and use the table to avoid registering more than once.

    David

  • Suggested answer
    Almas Mahfooz Profile Picture
    11,009 User Group Leader on at
    RE: Getting the current open window in .net GP Add In

    You are right David. Thanks for reminder.

    Hany, other way is registering a trigger against dynamics GP function "Security" and then get resource id from it. I have done this before when needed to know current window name.

  • David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    14,036 Most Valuable Professional on at
    RE: Getting the current open window in .net GP Add In

    Almas, just remember that using COM does not always work when running more than one instance of Dynamics or Dexterity on the workstation.

    It always communicates with the first launched instance and not with the current instance.

  • Suggested answer
    Almas Mahfooz Profile Picture
    11,009 User Group Leader on at
    RE: Getting the current open window in .net GP Add In

    Hany, the  GetDexActiveWindow() method we are talking in this post can be used to find the active window name, it  returns 4 string parameters that tell us the Form technical name, window technical name, dictionary name and window title. You can use it's in dexterity as well by adding com reference.

  • Community Member Profile Picture
    on at
    RE: Getting the current open window in .net GP Add In

    Hi Almas,

    you exactly right.

    I need to to something like this:

    if window SOP_Entry of form SOP_Entry is active then

      Do task

    end if;

    I couldn't find any function in dexterity to achieve this condition.

    isopen() function doesn't work as it doesn't show if the opened window is active or not.

    Thanks!!

  • Suggested answer
    Almas Mahfooz Profile Picture
    11,009 User Group Leader on at
    RE: Getting the current open window in .net GP Add In

    What exactly your objective is?

    The front most window is the active window,  If you will open Sales Transaction Entry Window and then open customer Window from it and then from customer window will open Shipping Method window then the 'Shipping window' is the active window.

    It seems you are coding something where you have to find which window is active and then on the basis of active window do some task.

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

#1
Almas Mahfooz Profile Picture

Almas Mahfooz 3 User Group Leader

Featured topics

Product updates

Dynamics 365 release plans