LabWindows/CVI

Table of Contents
  • LabWindows/CVI Fundamentals
  • Creating Applications
  • Distributing Applications
  • Library Reference
  • Programmer Reference
  • Hardware Information

FileSelectPopupEx

int FileSelectPopupEx (char defaultDirectory[], char defaultFileSpec[], char fileTypeList[], char title[], int buttonLabel, int restrictDirectory, int restrictExtension, char pathName[]);

Purpose

Displays a file selection dialog box and waits for the user to select a file or cancel.

(Linux) The dialog box displayed with FileSelectPopupEx includes a Make Directory button, while the dialog box displayed with FileSelectPopup does not.

Notes Note  The underlying Windows SDK function used to create and run the FileSelectPopupEx dialog box does not work properly when the threading modelthreading model is multithread apartment (MTA). ActiveX functions use this thread type by default, and calling any ActiveX function initializes the thread to MTA. This might cause subsequent calls to the FileSelectPopupEx function to return an error. To ensure the FileSelectPopupEx dialog box works properly, LabWindows/CVI initializes the thread calling the FileSelectPopupEx function to COINIT_APARTMENTTHREADED prior to creating the dialog box. If you want to run in the default MTA threading model, consider calling the FileSelectPopupEx function from a different thread that does not call any ActiveX functions. You can explicitly set the ActiveX threading model for a thread using the CA_InitActiveXThreadStyleForCurrentThreadCA_InitActiveXThreadStyleForCurrentThread function.

Parameters

Input
Name Type Description
defaultFileSpec char [] String that specifies which value is displayed by default in the file type list of the dialog box. For example, "*.c" causes all files with the .c extension to be displayed. LabWindows/CVI adds a new file type item if needed.

If an actual file name is specified, such as "test.c", that name appears in the file name box when the dialog box is displayed and the extension of the file, "*.c", is selected by default in the file type list.

The default file specification (spec) cannot contain a directory path.

The maximum length of the default file spec is 255 bytes.
fileTypeList char [] List of file types, separated by semicolons, to display in the file type list of the dialog box when restrictExtension is FALSE.

For example, "*.c; *.h" allows the user to select "*.c" or "*.h" from the file type list. The all files, "*.*", option is always available.

You can group multiple file types under one entry in the drop-down list by enclosing the file types in parentheses and separating the file types by semicolons. You can include descriptive text along with the file types. For example, "JPEG Files (*.jpg;*.jpeg);PNG Files (*.png);*.bmp;" allows the user to see all JPEG file types at once, or to select "*.png" or "*.bmp" from the file type list.
title char [] Title of the dialog box.
buttonLabel int The label for the file select button. You can select from the following choices:

Button Label Value Description
OK VAL_OK_BUTTON Allows users to select a file
Save VAL_SAVE_BUTTON Allows users to save a file
Select VAL_SELECT_BUTTON (affects existing files only) Confirms the selected file exists
Load VAL_LOAD_BUTTON (affects existing files only) Displays an existing file
Note   If VAL_SELECT_BUTTON or VAL_LOAD_BUTTON is passed to the buttonLabel parameter, the FileSelectPopupEx function confirms the selected file exists. If the file does not exist, the function prompts the user to select an existing file.
restrictDirectory int Specify a nonzero value or select yes in the function panel to restrict the user from changing directories or drives.

Specify 0 or select no in the function panel to allow the user to change directories or drives.
restrictExtension int Specify a nonzero value or select yes in the function panel to limit the user to files with the default extension.

Specify 0 or select no in the function panel to allow the user to select files with any extension.
Output
Name Type Description

Return Value

Name Type Description
selectionStatus int The selection status or error codes generated during the function call.

0 VAL_NO_FILE_SELECTED
1 VAL_EXISTING_FILE_SELECTED
2 VAL_NEW_FILE_SELECTED

Negative values indicate that an error occurred.

Additional Information

Library: User Interface Library

Include file: userint.h

LabWindows/CVI compatibility: LabWindows/CVI 2012 and later

Examples

Refer to the following examples that use the FileSelectPopupEx function:

  • apps\daqmthread\daqMT.cws

    Open example
  • apps\uirview\uirview.cws

    Open example
  • internet\sendmail\sendmail.cws

    Open example
  • userint\graphlegend.cws

    Open example
  • userint\ICOViewer.cws

    Open example
  • userint\popups.cws

    Open example
  • userint\custctrl\cviogl\ogldemo.cws

    Open example

Log in to get a better experience