Monday, July 3, 2017

AX 2012: Forms on opening hide behind in the back - 2° part

Hi Guys

About this topic the Microsoft workaround in some case doesn't helped me.
So, below you can find the code that definitely fix the issue!

Modify the StartupPost method of the Application Class and add these two lines:

if (hasGUI())
        Application::DisableWindowGhosting();


Lastly, created the "DisableWindowGhosting" static method like this:

client static void disableWindowGhosting()
{
    DLL DLL;

    DLLFunction DLLFunction;

    container con = WinAPI::getVersion();

    if (conpeek(con, 1) == 6) //Vista and Win7/Win2008R2 only
    {
        //this will disable window ghosting for this process only, for its lifespan only

        DLL = new DLL("USER32");

        DLLFunction = new DLLFunction(DLL,"DisableProcessWindowsGhosting");

        DLLFunction.call();
    }
}

That's it!

4 comments:

Ievgen Miroshnikov said...

Let me post a link to original blog https://blogs.msdn.microsoft.com/axsupport/2014/06/21/forms-opening-up-with-focus-in-background/

Denis Macchinetti said...

Hi Ievgen

You are right!

I had forgot the Microsoft original post.

Thank you
Denis

Santosh kumar Singh said...

Nice post and good quality contents keep it up.Feel free to give me some tips for my blog

http://daynamicsaxaptatutorials.blogspot.in/

vimal singh said...

Tried Adding new method and calling from StartupPost method,i kept debugger to verify code is hitting or not. Looks like Debugger hit it at starting of application but still Form is opening at back is there any thing else have to take care?