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 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

I have the same question (0)
  • Tim Wappat Profile Picture
    5,711 on at

    I think you will need to drop down to windows API to achieve that.

    This code project page shows more than you need, I guess GetForegroundWindow() would do you, I expect you will need to do some research around that and mapping the windows you want to trigger your code from in GP.

  • David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    14,095 Most Valuable Professional on at

    I don't believe that is possible with standard Visual Studio Tools code.  You will need to go low level to get the window in focus (as Tim says), then you can get the handle and the window title.  However, getting back to technical name of the window itself will be difficult.

    What are you trying to achieve? Understanding the bigger picture will help us suggest solutions.

    David

  • Community Member Profile Picture
    on at

    Thanks Tim & David,

    We have a legacy application in .net which use DexToNet (TamerSoft DexToNet) component to connect to dexterity. Now, we are converting it to use VS SDK instead. while migrating the existing code, We came across this requirement. 

    We have some logic in there which set the new form's location and size based on the size of the mdi client window of dex.  like, if the new form's size is larger then the dex form, reduce it. 

    Hope this gives you more idea.

    Thanks,

    Himal

  • David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    14,095 Most Valuable Professional on at

    Hi Himal

    If you know the Dexterity window, then obtaining the information is easy. The issue is dynamically getting the current window.

    Even in Dexterity there is no way to directly get the current window. The only method is to dynamically register triggers on the activate event of every window as it opens and get the trigger handler code to store the window name somewhere when the window gains focus.

    David

  • Tim Wappat Profile Picture
    5,711 on at

    I had not seen this component before. I can't immediately find an overview of what it is or does. From a forum post it looks like some kind of .NET interop into Dexterity?

    As David said above, I think this will be challenging from the Visual Studio add in.

    Perhaps there are clues from the existing code as to how that component achieves this. Do you have any method signatures? My guess would be that the component has a Dexterity side to it that has implemented functionality much as David describes.

  • Suggested answer
    Almas Mahfooz Profile Picture
    11,009 User Group Leader on at

    So many years ago I also need to find the current active window information in dexterity and I did this with 2 different way. One was to create a function in dexterity to use COM objects and use GetDexActiveWindow().
    And second method was to use command prompt commands and use some batch files to get the Dynamics GP active window, which I don't know still work in with windows 8 or not.[ I tried to search that code in my backups but hopeless. :( , I think I must gather all the codes to some handy and save place so don't run like mad when need them ]

    Anyway you can still use GetDexActiveWindow() to get the active window and do the needful.
    below are some helpful hints.

    The GetDexActiveWindow() method returns 4 string parameters that tell us the Form technical name,
    window technical name, dictionary name and window title. Shown below is an example of this code:

    Dim result As Boolean
    Dim mystr1 As String
    Dim mystr2 As String
    Dim mystr3 As String
    Dim mystr4 As String

    result = eEnterpriseApp.GetDexActiveWindow(mystr1, mystr2, mystr3, mystr4)

    MsgBox ("Form Name = " & mystr1)
    MsgBox ("Window Technical Name = " & mystr2)
    MsgBox ("Dictionary Name = " & mystr3)
    MsgBox ("Window Title = " & mystr4)

    automation-beyond.com/.../gp-automation-gui-capture-script


    I am in a little hurry, just login to reply your question, sorry can't help much.

  • Almas Mahfooz Profile Picture
    11,009 User Group Leader on at

    DexToNet is quite an old product, I remember having it's trial version on 2009. : )

  • Community Member Profile Picture
    on at

    Hi Tim/David,

    Yes, this component is very old and no longer supported. And that's the reason we re moving to VST. I was going through Microsoft.Dexterify.Shell and found a class "Microsoft.Dexterity.Shell.DexForm" that has ActiveForm property.

    Not  sure if that will do it. tried but getting null. :)

    Do you know if there is any documentation around Microsoft.Dexterity.Shell classes ?

    Thanks,

    Himal

  • Community Member Profile Picture
    on at

    Thanks Almas,

    I would give it a try with GetDexActiveWindow. Where can i get the reference for  eEnterpriseApp.GetDexActiveWindow ?

    Thanks,

    Himal

  • Tim Wappat Profile Picture
    5,711 on at

    Almas included the link to the script in her post

    automation-beyond.com/.../gp-automation-gui-capture-script

    This is Dex script, so you would have to create a Dexterity modification to include this script, then exposing that Dex code to .NET.

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 GP (Archived)

#1
mtabor Profile Picture

mtabor 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans