1. Timer usage
Settimer (1, 1000, null); // start timer 1, timing 1000 milliseconds, use the default processing function ontimer ()
Killtimer (1); // disable timer 1
Implementation of processing functions
Void cmfcview: ontimer (uint_ptr nidevent) // cmfcview, which can be changed based on project requirements. It only indicates a ownership {// todo: add the message processing program code and/or call the default switch (nidevent) {Case 1: {// afxmessagebox ("timer is running! "); // When the timer time reaches, a dialog box is displayed, indicating that the timer has been run. Imgprocontroller (); // regularly processes image break;} Case 2: {break;} default: {break;} cformview: ontimer (nidevent ); // The cformview class cannot be moved}
It is very convenient and simple to use, but there are two important points that need to be interconnected to make it work:
A. Declare afx_msg void ontimer (uint_ptr nidevent) in the public header file of the corresponding class );
B. on_wm_timer () should be added to the Message ing table, with an exclusive row in the format
Because I haven't used it for a long time and I can't remember it all for a while, Baidu just found out the problem through the Class Wizard after a long time. Therefore, record the case and try again !!!
2. File Path Extraction
We recommend that you use the cfiledialog class to overwrite the built-in "open" method to control the dialog box more accurately and to conveniently extract the file path and file name.
Cfiledialog DLG (true, null, null, ofn_filemustexist | ofn_pathmustexist | ofn_hidereadonly, // ofn_nochangedir indicates that the default directory "image (*. JPG ;*. PNG) | *. JPG ;*. PNG | video (*. avi ;*. MP4) | *. avi ;*. MP4 | all files (*. *) | *. * | ", // optional project constraints, note that the combination method is null); // the file type description and extension are separated by |, and the extension of the same type of files can be used; separated by |, and separated by |. DLG. m_ofn.lpstrtitle = _ T ("select an image or video file"); // The title name of the open file dialog box if (DLG. domodal ()! = Idok) // determine whether to get the image return;
Cstring cfiledialog: getpathname () to obtain the complete file name, including the directory name and extension c: \ test \ test1.txt
Cstring cfiledialog: getfilename () to obtain the complete file name, including the extension test1.txt.
Cstring cfiledialog: getextname () to obtain the complete file extension, for example, txt
Cstring cfiledialog: getfiletitle () to get the complete file name, excluding the directory name and extension such as test1
The getfilepath () function is used to obtain the path to open a file.
Getcurrentdirectory relative path, change at any time
If it is a working path, use getworkingdirectory
If it is the current executable program, use the absolute path of the getmodulefilename (null, P, size) application, basically unchanged
Hmodule module = getmodulehandle (0 );
Char Buf [max_path];
Getmodulefilename (module, Buf, sizeof BUF );