General dialog box

Source: Internet
Author: User

 

InWindows provides some general dialogs, such as the file selection dialog box.,

Color Selection dialog box,

Font selection dialog box.

InIn MFC, CFileDialog, CColorDialog, and CFontDialog are used. Generally, you do not need to derive a new class because the base class already provides common functions. In addition, after the dialog box is created and waits for the completion of the dialog box, you can use the member function to obtain the user's selection in the dialog box.

Use of the CFileDialog file selection dialog box: First, construct an object and provide corresponding parameters. The constructor prototype is as follows:
CFileDialog: CFileDialog (BOOL bOpenFileDialog, LPCTSTR success = NULL, LPCTSTR lpszFileName = NULL, DWORD dwFlags = Success | fail, LPCTSTR lpszFilter = NULL, CWnd * pParentWnd = NULL ); the parameters have the following meanings:

  • If bOpenFileDialog is set to TRUE, the open dialog box is displayed. If it is set to FALSE, the SAVE dialog file dialog box is displayed.
  • LpszDefExt specifies the default file extension.
  • LpszFileName specifies the default file name.
  • DwFlags indicates some specific styles.
  • LpszFilter is the most important parameter. It specifies the available file type and the corresponding extension. The parameter format is as follows:
    "Chart Files (*. xlc) | *. xlc | Worksheet Files (*. xls) | *. xls | Data Files (*. xlc ;*. xls) | *. xlc ;*. xls | All Files (*. *) | *. * | "; the file type description and extension are separated by |. files of the same type can be separated by the extension; separated by |, and ended with |.
  • PParentWnd is the parent window pointer.

The create file dialog box can be used.DoModal (), you can use the following function to get the user to choose after the return:

  • CString CFileDialog: GetPathName () to obtain the complete file name, including the directory name and extension c: estest1.txt
  • CString CFileDialog: Ge

Related Article

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.