Forms opening up with focus in background?

If you work with an installation where forms in MS Dynamics AX are opened in the background then the following code fix might help out here:

“Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability or fitness for a particular purpose. This mail message assumes that you are familiar with the programming language that is being demonstrated and the tools that are used to create and debug procedures.”

Add a new static, client-side method to Classes\Application, as below:

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();

}

}

Add a call to this from Application.startupPost(), like this:

if (hasGUI())

{

Application::DisableWindowGhosting();

}