Visual C 5.0 programming experience (below)
Implementation Process Tips dialog box When you use Windows 95 to copy or delete an operation, the user must see the operational process prompt dialog with flying file animations. The addition of this feature not only allows us to cancel the operation at any time during the operation, but also make the file copy or delete the operation. In fact, when using Visual C for application design, we can also use the following method to add its own operational procedure dialog box in place, steps below. 1. Create a dialog class for each operational Process Tips dialog. For the convenience of the narrative, we only assume that the application requires an operational process prompt dialog and is the name of the corresponding dialog class with "cmodel". 2. Use the resource editor provided by Visual C to edit the prompt dialog, such as adding some text descriptions and animations. 3. In the CMODEL class's header file (MODEL.H), join two member variables: CWND * m_pparent; // Point to the frame class (or dialog class) of the prompt dialog, that is, its parent class "INT m_nid; // Record the ID number of the prompt dialog again to join the following two member functions: cmodel (cwnd * pparent = null); // Abandon the original constructor, or modify the original function into this The constructor of the pattern dialog box is bury create (); / / This function will call the create () function creation dialog box for creating a base class 4. In the model.cpp file, add the implementation of the corresponding function: cmodel :: cmodel (CWND) * PParent / * = null * /): cdialog (cdialog (cmodel :: IDD, pParent) {m_pparent = pParent; m_nid = cmodel :: IDd; // {{afX_DATA_INIT (CMODEL) // Note: The classwizard will add member initialization here //}} AFX_DATA_INIT} BOOL CMODEL :: Create () {Return CDialog :: Create (m_nid, m_pparent);} 5. Press CTRL and W to Click the ClassWizard button directly on the toolbar, open the ClassWizard dialog. . Select this prompt dialog class in the Class Name list box. After selecting the class name of the class in the Object IDS list box, select PostncDestroy message in the message (Messages) list box and double-click it, at this time ClassWizard A postncdestroy () function will be added to the dialog class. This function is called by the oncdestroy () function after the dialog window disappears. Therefore, some sweeping operations can be added to the function, such as data transfer, release pointer space, and the like. Void cmodel :: postncdestroy () {// Todo: add your specialized code here and / or call the base class delete this; cdialog :: postncdestroy ();} 6. In the header file to call the prompt dialog box, first The header of the CMODEL class, then declare a pointer to the object of the CMODEL class, such as m_dlg, and add "M_DLG = NULL," in this class of constructor.
Then, add the following sequence in the function that opens and closes the prompt dialog: if (m_dlg == null) {// If there is no active prompt dialog box, create a m_dlg = new cmodel (this); m_dlg-> Create (); getdlgitem -> enableWindow (false);} else // Otherwise, it activates it m_dlg-> setActiveWindow (); additionally, add the following statement to the place where the prompt dialog is to be closed: m_dlg-> destroyWindow () ; m_dlg = null; here, we already have your own process operation prompt dialog. However, it does not have an animation and the ability to cancel the operation at any time, and the reader may wish to try to join these features. Application Process For other applications in our design, it is likely to use other applications to complete a particular feature. For example, when we perform compression and decompression of many files for the transmission of data, one of our own design a compression / decompression program, then in the form of dynamic link library (DLL) or library Application is called. But more convenient and efficient practices are to use this existing excellent software, such as Arj.exe, etc., and call it in the form of a process, then close it at the appropriate time. The following will be used as an example, and the implementation process of the latter method is specifically described. 1. Create a member function in a class that needs to call Arj.exe for compression / decompression, it is known as createbat (), which is to generate a batch file. Arj.exe is called by the batch file and gives the specific compression / decompression parameters. Then, use the MS-DOS DIR command to generate a temporary file to be used as a flag that is completed as compressed / decompressed work. Editor's Note: CreateBat Source Codes Published http://www.computerworld.com.cn/98/skill/default.htm. Same. Welcome to visit! After the function is executed, a batch file will be generated. The content is roughly: arj a -v1440 compressed file name file name is compressed file name file name -Y -JM DIR> temporary file name Or: arj e -v1440 is decompressed path name file name to decompress the path name file name -y -jm Dir> temporary file name 2. You need to call Arj.exe for compression / decompression In the class, create a member function, it may be called Runbat (), which function is to create and execute the process to run the batch file generated above, and undo the process at the appropriate time. 3. Press the CTRL and W key or click the ClassWizard button on the toolbar or click the ClassWizard button directly to open the ClassWizard dialog. In the class name list box, select the class that needs to call Arj.exe for compression / decompression, select the class name of the class in the Object IDS list box, select the WM_TIMER message in the message (Messages) list box and double click It, at this time, ClassWizard adds an ontimer () function in this class. This function will check if the compression / decompression program has been executed at a certain time interval, ie check whether the temporary file as a flag already exists, and modifies the status variable "Search" in time to inform the Runbat () function ending process.