LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Restrict file list in file select popup?

Can I restrict the files in the FileSelectPopup() beyond by extension. That is, if I have 10 files with a particular extension, i.e. .dll, but I only want to allow the user to select from 3 particular dll files, can I somehow show only those 3 files in the FileSelectPopup() list?
0 Kudos
Message 1 of 6
(3,477 Views)
You could use the default file spec parameter in the FileSelectPopup(). For example. if you have some txt files, and you only want the user to select files that have the name test and then a single digit number, like test1.txt , text5.txt, etc, you could specify the default file spec as "test?.txt". This would only bring up those type of files for the user to chose. Similarly, you would user "test*.txt" if you want to access all txt files that start with "test"

If you do want more complex behavior (the names of the files are not very similar), you could make a custom panel that would do the task for you.

I hope this helps

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 2 of 6
(3,477 Views)
I do need the more complex behavior as you mention. So programatically I created a panel with a table control, a string control, an Ok and a Cancel button. These NewCtrl() functions are then followed by a do{} loop in which I use the GetUserEvent() function.

BTW - this is all done during application initialization and setup, before RunUserInterface() is called.

The control mode of the table control and both command buttons are set to Hot. I want it to behave like a FileSelectPopup() so I have a "do" loop right after the panel and control setup, in which I am using the GetUserEvent() function.

Like I mentioned, to make this modal, I am using the GetUserEvent() function inside a "do" loop. I would also like the function to get the name of th
e file selected from the table by the user and display it in the string control. This is, of course, inside the same "do" loop. So that when the user generates an event on the table, the GetUserEvent() will catch it and I can get the filename, and put it in the string control. However, the GetUserEvent() function only catches an EVENT_COMMIT or events queued by QueueUserEvent (1000 thru 10000). Since I am selecting a file in the table, not changing the name, an EVENT_COMMIT is not generated, only an EVENT_LEFT_CLICK or something like that.

So I tried installing a control callback to the table, TableCallback, and inside the TableCallback function I use QueueUserEvent to put an event on the queue. But the program never gets to the TableCallback (perhaps because RunUserInterface() has not been executed), and so it never queues the event and it never gets caught by the GetUserEvent(). So the only controls that work are the Ok and Cancel buttons.

How can I catch an event from my
table to allow me to get the selected filename and put it in the string control?

Thanks.
0 Kudos
Message 3 of 6
(3,477 Views)
Why not use RunUserInterface() instead of your do/while loop? Then you could implement functionality for the selection panel in the normal way, using callbacks. The callbacks for the OK and Cancel buttons can each call QuitUserInterface() with different parameters (say 0 and 1), so the return value from RunUserInterface() would tell you which button had been pressed.
--
Martin
Certified CVI Developer
0 Kudos
Message 4 of 6
(3,477 Views)
I'd like to implement a modal function much like the FileSelectPopup(), which returns a status and filename selected. This function will be called from the main() function, before I get to the main RunUserInterface. This seems like it should be straightforward, but I'm having difficulty.

I have attached a small project that shows what I'm trying to do. If you have a chance, take a look and let me know what I'm doing wrong, and what I need to do.

Thanks.
Download All
0 Kudos
Message 5 of 6
(3,477 Views)
Craig-

You can make any panel "modal" by using the InstallPopup() function. Then you could use RunUserInterface and callbacks as usual, and the user won't be able to "get behind" your panel.

I surely empathize with your desire to improve the file select pop-up, I've given up and used it as is; seems like NI could afford to make this commonly used popup a bit more sophisticated. My problems with the NI version are that you can't select multiple files, and you can't restrict folder navigation to a "downward" direction.

Good luck.
0 Kudos
Message 6 of 6
(3,477 Views)