Use of the cfiledialog file selection dialog box

Source: Internet
Author: User
Tags getcolor
From: http://blog.chinaunix.net/u1/34188/showart_264093.html

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, maid = NULL, maid =
Null, DWORD dwflags = ofn_hidereadonly | ofn_overwriteprompt, lpctstr
Lpszfilter = NULL, cwnd * pparentwnd = NULL); the parameter meaning is as follows:

  • 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 (*. *) | *. * | "; file type description and extension |
    Separated. the extensions of files of the same type can be separated. | is used to separate files of the same type, and | is used at the end.
  • Pparentwnd is the parent window pointer.

In the create file dialog box, you can use domodal (). After the result is returned, you can use the following function to get the user to choose from:

  • 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
  • Position cfiledialog: getstartposition () gets the first file location when multiple files are selected.
  • Cstring cfiledialog: getnextpathname (Position & Pos)
    If multiple files are selected, the next file location is obtained and the current file name is returned. However, the position must have been called.
    Cfiledialog: getstartposition () to obtain the initial position variable.

Use of the ccolordialog color selection dialog box: First, use ccolordialog: ccolordialog (
Colorref clrinit = 0, DWORD dwflags = 0, cwnd * pparentwnd = NULL
) Construct an object with clrinit as the initial color. Call domodal () to create a dialog box, and then call colorref
Ccolordialog: getcolor () to obtain the selected color value.

Cfontdialog font selection dialog box: First, construct an object and provide corresponding parameters. The constructor prototype is as follows:
Cfontdialog: cfontdialog (
Lplogfont lplfinitial = NULL, DWORD dwflags = cf_effects |
Cf_screenfonts, CDC * pdcprinter = NULL, cwnd * pparentwnd = NULL
); Construct an object. The parameter lplfinitial points to a logfong structure. If this parameter is set to null, the initial font is not set. Pdcprinter points
A dc object that represents the environment of the printer device. If this parameter is set, the selected font is used by the printer. Pparentwnd is used to specify the parent window. Create a dialog by calling domodal ()
Box to get the user to choose by calling the following function after the return:

  • Void cfontdialog: getcurrentfont (lplogfont lplf); used to obtain the attributes of the selected font. This function has a parameter that is a pointer to the logfont structure. The function writes various attributes of the selected font to this logfont structure.
  • Cstring cfontdialog: getfacename () to get the name of the selected font.
  • Int cfontdialog: getsize () to get the size of the selected font (in 10 pixels ).
  • Colorref cfontdialog: getcolor () to get the color of the selected font.
  • Bool cfontdialog: isstrikeout ()
    Bool cfontdialog: isunderline ()
    Bool cfontdialog: isbold ()
    Bool cfontdialog: isitalic ()
    Obtain other attributes of the selected font, including strikethrough, underline, bold, and italic.

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.