Avoid opening the same form multiple times

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.