Ax can open the same form multiple times through the menu. Some customers want to open the same form only once. If the second click, the original form is displayed at the top. Ax provides some APIs for doing this, and there are suitable portals for adding some processing.Code.
1. Modify the formrunclass method of class factory classfactory
Formrun formrunclass (ARGs)
{
# Formcachemark
Hwnd;
;
If (Infolog. globalcache (). isset (# formcachemark, argS. Name ()))
{
Hwnd=Infolog. globalcache ().Get(# Formcachemark, argS. Name ());
Winapi: bringwindowtotop (hwnd );
Return Null;
}
Return Classfactory: formrunclassonclient (ARGs );
}
Add a judgment to determine whether the current client has an instance of the form. If yes, the form is directly displayed at the frontend and null is returned.
2. Modify the init method of the syssetupformrun class, and save the hwnd of the current form after the Super () method for future calls.
Public Void Init ()
{
;
Super ();
Infolog. globalcache ().Set(# Formcachemark,This. Name (),This. Hwnd ());
Syssecurityformsetup: loadsecurity (This);
}
3. Modify the close method of the syssetupformrun class and remove the current form from the global cache when closing the form.
Public Void Close ()
{
Super ();
Infolog. globalcache (). Remove (# formcachemark,This. Name ());
}
OK, that's simple. The code is shown in the attachment.