LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Customizing Open File Dialog box with SDK

I need to customize a openfile dialog box. I'd want to prohibit the user to change the name and the extension of the file to open. And He must only see folders and the specified file. But I have some troubles to use the hook fonction and to send messages to the customize window.
I find a lot of samples but only in C++ or other languages.

Have you got some basic samples computing in C to help me? For example, hide the cancel button or others controls.

Thanks

P.lem
0 Kudos
Message 1 of 7
(3,593 Views)
You can do a lot of this using the CVI function FileSelectPopup(), without using the Windows SDK.
Open the function panel for FileSelectPopup(). You'll see options to Restrict Directory, Restrict Extension, Allow Cancel, Allow Make Directory.
For example, the following statement restricts the directory to D:\My Documents, allows only .xls extension, doesn't allow cancel, and doesn't allow Make Directory.
FileSelectPopup ("d:\\My Documents", "*.xls", "", "", VAL_LOAD_BUTTON, 1, 1, 0, 0, myPath);
The easiest way to use this function is to use the function panel to set it up. From the menu on a window for the .c file, goto Library >> User Interface >> Pop-up Panels >> File/Directory Popups (if you don't have the libraries flattened). Or, in the window for the .c
file, press P and enter FileSelectPopup.
0 Kudos
Message 2 of 7
(3,593 Views)
I know well fonction FileSelectPopup(), but it doesn't enough powerful for my application. I want to restrict the name of the file to open, because it have a specific format (in its name) according to the case. I know the name of the file to open when the user click on Open File button, so I would like to oblige the user to select only this file. It's necessary that the explorer window show only folders and the specified file.
I have a DLL computing in VC++ 6.0 who does it, but I work with Win XP and the DLL have a bug with this OS and I can't correct this bug because VC++ 6.0 have also a bug in Win XP in Debug mode.
The solution is to redo the DLL with CVI and the SDK. So I use GetOpenFileName(OPENFILENAME) function which open a FileOpen Popup and a associate
hook function which must customize my dialog box: Prohibit to change the file name, show only the specified file. And my problem is here: I don't know how I can do to change the properties of dialog box Open. The use is a little difficult and I have no sample in C to show how I must do.

Thanks

Pascal. L
0 Kudos
Message 3 of 7
(3,593 Views)
If you don't want the user to change the name of the file and don't want the user to be able to cancel, why do you want to show a File Open dialog box? Why not just a MessagePopup showing the name of the file with an OK button?
0 Kudos
Message 4 of 7
(3,593 Views)
Or if you want to just allow the user to change the directory, have you looked at DirSelectPopup?
Or, you could use FileSelectPopup, parse out the filename separate from the path, and use the path, ignoring the filename, or give a warning (using MessagePopup) if the filename was changed.
0 Kudos
Message 5 of 7
(3,593 Views)
Thank you for all your suggestions.
The latest was good for my problem but maybe a little boring for the user.
But finally I sucess to use the SDK functions.
I use GetOpenFileName (OPENFILENAME) who display a File Open Dialog box, and a hook function linked with the window (you must write int the structure OPENFILENAME the fields you need, see the SDK help in CVI). But be careful, You can compile GetOpenFileName function only if you compile on Visual C++. If you use Borland there is a linked problem (It doesn't find the function why ???)
Then you declare a hook function who will send messages to your File Open window (with SendMessage()), so you can hide some controls, or do another thing like change controls position ...
Tomorow I
will send my source, you can see it isn't so difficult, in fact.

BUT I have a another problem. I did a DLL with my function, and i use it in a project compiled with Borland. I attach My_DLL.lib (Borland) on my project, include the header file in the module where i use my function, and put my_DLL.dll in the project directory. I declare in my_DLL.c, EXPORT My_DLLL_Function(), and IMPORT My_DLL_Function() in the header file. However, I have a linked problem : undefined symbol my_Dll_function.
Maybe I have done a mistake or I 've forgotten something, or maybe it's again Windows XP. I don't know

if you've got an idea...
Thanks
0 Kudos
Message 6 of 7
(3,593 Views)
So you created a DLL function in VC++, call it in a Borland DLL, and then call the Borland DLL from CVI? It sounds like you're jumping through a lot of hoops.
I use VC++ and CVI to create DLLs. I don't know Borland.
I noticed two things in your message:
1. Are you exporting and importing the same function? I think you just need to do one or the other, depending of who's calling what from where.
2. Are you watching your spelling including case? In your message, you use 3 different spellings: My_DLLL_Function(), My_DLL_Function(), my_DLL_function()
0 Kudos
Message 7 of 7
(3,593 Views)